FalkorDB-MCPServer is an MCP (Model Context Protocol) server that connects LLMs to FalkorDB
6.3K
A Model Context Protocol (MCP) server for FalkorDB, allowing AI models to query and interact with graph databases. FalkorDB MCP Server enables AI assistants like Claude to interact with FalkorDB graph databases using natural language. Query your graph data, create relationships, and manage your knowledge graph - all through conversational AI.
This server implements the Model Context Protocol (MCP)ā , allowing AI models to:
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"falkordb": {
"command": "npx",
"args": [
"-y",
"@falkordb/mcpserver@latest"
],
"env": {
"FALKORDB_HOST": "localhost",
"FALKORDB_PORT": "6379",
"FALKORDB_USERNAME": "",
"FALKORDB_PASSWORD": ""
}
}
}
}
You can run the server directly from the command line using npx:
Using inline environment variables:
# Run with stdio transport (default)
FALKORDB_HOST=localhost FALKORDB_PORT=6379 npx -y @falkordb/mcpserver
# Run with HTTP transport
MCP_TRANSPORT=http MCP_PORT=3005 FALKORDB_HOST=localhost FALKORDB_PORT=6379 npx -y @falkordb/mcpserver
Using a .env file:
# Using dotenv-cli to load environment variables from .env
npx dotenv-cli -e .env -- npx @falkordb/mcpserver
This is useful for:
Clone and install:
git clone https://github.com/FalkorDB/FalkorDB-MCPServer.git
cd FalkorDB-MCPServer
npm install
Configure environment:
cp .env.example .env
Edit .env:
# Environment Configuration
NODE_ENV=development
# FalkorDB Configuration
FALKORDB_HOST=localhost
FALKORDB_PORT=6379
FALKORDB_USERNAME= # Optional
FALKORDB_PASSWORD= # Optional
FALKORDB_DEFAULT_READONLY=false # Set to 'true' for read-only mode (useful for replicas)
# Logging Configuration (optional)
ENABLE_FILE_LOGGING=false
Build the project:
npm run build
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"falkordb": {
"command": "node",
"args": [
"/absolute/path/to/falkordb-mcpserver/dist/index.js"
]
}
}
}
Restart Claude Desktop and you'll see the FalkorDB tools available!
Once connected, you can ask Claude to:
"Show me all people who know each other"
"Find the shortest path between two nodes"
"What relationships does John have?"
"Run a read-only query on the replica instance"
Note: The query_graph tool now supports a readOnly parameter to execute queries in read-only mode using GRAPH.RO_QUERY. This is ideal for:
There's also a dedicated query_graph_readonly tool that always executes queries in read-only mode.
"Create a new person named Alice who knows Bob"
"Add a 'WORKS_AT' relationship between Alice and TechCorp"
"List all available graphs"
"Show me the structure of the user_data graph"
"Delete the old_test graph"
# Development with hot-reload
npm run dev
# Development with TypeScript execution (faster startup)
npm run dev:ts
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverage
# Lint code
npm run lint
# Lint and auto-fix issues
npm run lint:fix
# Build for production
npm run build
# Start production server
npm start
# Inspect MCP server with debugging tools
npm run inspect
# Clean build artifacts
npm run clean
# Full CI pipeline (test, lint, build)
npm run prepublish
src/
āāā index.ts # MCP server entry point
āāā services/ # Core business logic
ā āāā falkordb.service.ts # FalkorDB operations
ā āāā logger.service.ts # Logging and MCP notifications
āāā mcp/ # MCP protocol implementations
ā āāā tools.ts # MCP tool definitions
ā āāā resources.ts # MCP resource definitions
ā āāā prompts.ts # MCP prompt definitions
āāā errors/ # Error handling framework
ā āāā AppError.ts # Custom error classes
ā āāā ErrorHandler.ts # Global error handling
āāā config/ # Configuration management
ā āāā index.ts # Environment configuration
āāā models/ # TypeScript type definitions
ā āāā mcp.types.ts # MCP protocol types
ā āāā mcp-client-config.ts # Configuration models
āāā utils/ # Utility functions
āāā connection-parser.ts # Connection string parsing
The server supports two transport modes:
Used for direct integration with AI clients like Claude Desktop. Communication happens via standard input/output.
MCP_TRANSPORT=stdio
Exposes the MCP server over HTTP for remote or networked access. Supports multiple concurrent sessions via the MCP Streamable HTTP protocol.
MCP_TRANSPORT=http
MCP_PORT=3000
MCP_API_KEY=your-secret-api-key # Optional but recommended
When using HTTP transport, clients connect by sending a POST request with an initialize message. The server returns an Mcp-Session-Id header that must be included in subsequent requests. API key authentication is enforced via the Authorization: Bearer <key> header when MCP_API_KEY is set.
Testing HTTP transport:
Start the server:
MCP_TRANSPORT=http MCP_PORT=3000 npm start
Use the MCP Inspector to connect:
npx @modelcontextprotocol/inspector --transport streamable-http --url http://localhost:3000
Note:
npm run inspectuses stdio transport. For HTTP, start the server and inspector separately as shown above.
API Key Authentication:
When MCP_API_KEY is set, all HTTP requests must include an Authorization header:
MCP_TRANSPORT=http MCP_API_KEY=my-secret-key npm start
Clients must then send:
Authorization: Bearer my-secret-key
Requests without a valid key receive a 401 Unauthorized response. Auth is only enforced in HTTP mode ā stdio mode ignores MCP_API_KEY since only the parent process can communicate.
Using pre-built images from Docker Hub:
# Use the latest stable release
docker pull falkordb/mcpserver:latest
docker run -p 3000:3000 \
-e FALKORDB_HOST=host.docker.internal \
-e FALKORDB_PORT=6379 \
-e MCP_API_KEY=your-secret-key \
falkordb/mcpserver:latest
# Or use the edge version (latest main branch)
docker pull falkordb/mcpserver:edge
# Or pin to a specific version
docker pull falkordb/mcpserver:1.0.0
Building locally:
docker build -t falkordb-mcpserver .
docker run -p 3000:3000 \
-e FALKORDB_HOST=host.docker.internal \
-e FALKORDB_PORT=6379 \
-e MCP_API_KEY=your-secret-key \
falkordb-mcpserver
Or use with docker-compose alongside FalkorDB:
services:
falkordb:
image: falkordb/falkordb:latest
ports:
- "6379:6379"
mcp-server:
image: falkordb/mcpserver:latest # or use 'build: .' to build locally
ports:
- "3000:3000"
environment:
- FALKORDB_HOST=falkordb
- FALKORDB_PORT=6379
- MCP_TRANSPORT=http
- MCP_PORT=3000
- MCP_API_KEY=your-secret-key
depends_on:
- falkordb
For cloud-hosted FalkorDB instances:
FALKORDB_HOST=your-instance.falkordb.com
FALKORDB_PORT=6379
FALKORDB_USERNAME=your-username
FALKORDB_PASSWORD=your-secure-password
If you're connecting to a FalkorDB replica instance or want to ensure no write operations are performed, you can enable read-only mode by default:
FALKORDB_DEFAULT_READONLY=true
This will make all queries execute using GRAPH.RO_QUERY by default. You can still override this per-query by setting the readOnly parameter in the query_graph tool.
Use cases:
You can run multiple MCP servers for different FalkorDB instances:
{
"mcpServers": {
"falkordb-dev": {
"command": "node",
"args": ["path/to/server/dist/index.js"],
"env": {
"FALKORDB_HOST": "dev.falkordb.local",
"FALKORDB_DEFAULT_READONLY": "false"
}
},
"falkordb-prod-replica": {
"command": "node",
"args": ["path/to/server/dist/index.js"],
"env": {
"FALKORDB_HOST": "replica.falkordb.com",
"FALKORDB_DEFAULT_READONLY": "true"
}
}
}
}
Here's what you can do once connected:
// Claude can help you write queries like:
MATCH (p:Person)-[:KNOWS]->(friend:Person)
WHERE p.name = 'Alice'
RETURN friend.name, friend.age
// Or create complex data structures:
CREATE (alice:Person {name: 'Alice', age: 30})
CREATE (bob:Person {name: 'Bob', age: 25})
CREATE (alice)-[:KNOWS {since: 2020}]->(bob)
// And even analyze your graph:
MATCH path = shortestPath((start:Person)-[*]-(end:Person))
WHERE start.name = 'Alice' AND end.name = 'Charlie'
RETURN path
We welcome contributions! Please see our Contributing Guidelinesā for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSEā file for details.
Made with ā¤ļø by the FalkorDB team & Katie Mulliken
Content type
Image
Digest
sha256:a12b46009ā¦
Size
47.7 MB
Last updated
3 months ago
docker pull falkordb/mcpserver