A Node.js implementation of the Graphiti temporal knowledge graph system as a Model Context Protocol (MCP) server.
- Temporal Knowledge Graph: Build and query time-aware knowledge graphs
- Multiple Search Types: Semantic, keyword, and hybrid search capabilities
- MCP Integration: Full Model Context Protocol server implementation
- Multi-LLM Support: OpenAI-compatible API integration (supports OpenAI, Moonshot, etc.)
- Neo4j Database: High-performance graph database backend
- NPX Support: Easy installation and execution via NPX
npx @zhangzichao2008/mcp-graphitinpm install -g @zhangzichao2008/mcp-graphiti
graphiti-mcpgit clone https://github.com/steven0lisa/mcp-graphiti.git
cd mcp-graphiti
npm install
npm run build
npm startCreate a .env file in your project directory:
# Neo4j Database Configuration
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=neo4j_password
NEO4J_DATABASE=neo4j
# AI Model Configuration (统一配置)
# 支持任何OpenAI兼容的API服务,包括Moonshot、OpenAI、智谱AI等
# LLM和Embedding共享同一套配置
EMBEDDING_API_KEY=your_api_key_here
EMBEDDING_API_URL=https://open.bigmodel.cn/api/paas/v4/embeddings
EMBEDDING_MODEL=embedding-3
# Server Configuration
LOG_LEVEL=info
NODE_ENV=development
# Graphiti Configuration
GRAPHITI_DATABASE=neo4j
GRAPHITI_EMBEDDING_DIMENSION=1536Add this to your Claude Desktop configuration file:
{
"mcpServers": {
"graphiti": {
"command": "npx",
"args": ["@zhangzichao2008/mcp-graphiti"],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "neo4j_password",
"NEO4J_DATABASE": "neo4j",
"EMBEDDING_API_KEY": "your_api_key_here",
"EMBEDDING_API_URL": "https://open.bigmodel.cn/api/paas/v4/embeddings",
"EMBEDDING_MODEL": "embedding-3"
}
}
}
}Add text documents (episodes) to the knowledge graph.
Parameters:
episodes: Array of episode objects with:name: Episode titlecontent: Episode text contentsource_description: Optional source descriptionsource: Optional source identifierreference_time: Optional reference time
Search the knowledge graph using semantic, keyword, or hybrid search.
Parameters:
query: Search query stringnum_results: Number of results (1-100, default: 10)search_type: 'semantic', 'keyword', or 'hybrid' (default: hybrid)
Get entities by name and optionally by type.
Parameters:
name: Entity name to search forentity_type: Optional entity type filter
Get facts/relationships between entities.
Parameters:
source_node_name: Optional source entity nametarget_node_name: Optional target entity namefact_type: Optional relationship type
Check the health status of the Graphiti server.
npm installnpm run devnpm run buildnpm test
npm run test:coveragenpm run lint
npm run lint:fixThe project follows a modular architecture:
src/types/: TypeScript type definitionssrc/drivers/: Database drivers (Neo4j)src/llm/: LLM client implementationssrc/core/: Core Graphiti functionalitysrc/utils/: Utility functionssrc/mcp-server.ts: MCP server implementation
The main class that provides knowledge graph operations:
class Graphiti {
async addEpisodes(episodes: Episode[]): Promise<void>;
async search(query: string, numResults?: number, searchType?: string): Promise<SearchResult[]>;
async getEntities(name: string, entityType?: string): Promise<Node[]>;
async getFacts(sourceNodeName?: string, targetNodeName?: string, factType?: string): Promise<Edge[]>;
async healthCheck(): Promise<{ database: boolean; llm: boolean }>;
}| Variable | Description | Default |
|---|---|---|
NEO4J_URI |
Neo4j database URI | bolt://localhost:7687 |
NEO4J_USER |
Neo4j username | neo4j |
NEO4J_PASSWORD |
Neo4j password | Required |
NEO4J_DATABASE |
Neo4j database name | neo4j |
EMBEDDING_API_KEY |
AI model API key (OpenAI-compatible) | Required |
EMBEDDING_API_URL |
AI model API URL | https://api.openai.com/v1 |
EMBEDDING_MODEL |
AI model name | gpt-3.5-turbo |
GRAPHITI_EMBEDDING_DIMENSION |
Embedding vector dimension | 1536 |
LOG_LEVEL |
Log level | info |
NODE_ENV |
Node environment | development |
Apache 2.0 License
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite
- Submit a pull request
For issues and questions:
- GitHub Issues: https://github.com/steven0lisa/mcp-graphiti/issues
- Discord: [Join our Discord server]
Important: Never commit API keys or sensitive information to the repository. Always use environment variables for configuration.