Connect the K0ntext MCP server to Claude Desktop (or other MCP-compatible AI assistants) to give your AI intelligent access to your codebase.
The Model Context Protocol (MCP) is a standard for AI assistants to access external tools and data. With K0ntext's MCP server, your AI can:
- Search your codebase semantically
- Retrieve specific files and context
- Query the knowledge graph
- Run intelligent analysis
- Check documentation drift
-
K0ntext installed:
npm install -g k0ntext
-
Claude Desktop (or another MCP-compatible client)
-
A project initialized with K0ntext:
cd your-project k0ntext init
The config location depends on your OS:
| Platform | Config Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Edit your claude_desktop_config.json:
{
"mcpServers": {
"k0ntext": {
"command": "npx",
"args": [
"-y",
"k0ntext",
"mcp"
],
"cwd": "/path/to/your/project"
}
}
}Important: Replace /path/to/your/project with your actual project path.
For multiple projects, use different server names:
{
"mcpServers": {
"k0ntext-project-a": {
"command": "npx",
"args": ["-y", "k0ntext", "mcp"],
"cwd": "/path/to/project-a"
},
"k0ntext-project-b": {
"command": "npx",
"args": ["-y", "k0ntext", "mcp"],
"cwd": "/path/to/project-b"
}
}
}Completely quit and restart Claude Desktop.
In a new Claude conversation, you should see k0ntext listed in the available MCP tools.
The K0ntext MCP server provides these tools:
| Tool | Description |
|---|---|
search_context |
Semantic search across indexed content |
get_item |
Retrieve specific context items by ID |
add_knowledge |
Store insights and facts |
analyze |
Run intelligent codebase analysis |
get_tool_configs |
View AI tool configurations |
query_graph |
Traverse knowledge graph |
get_stats |
Database statistics |
add_relation |
Add relationships between items |
find_path |
Find paths between items |
run_drift_check |
Check documentation sync |
Ask Claude:
"Search my codebase for how authentication is implemented"
Claude will use search_context to find relevant code.
Ask Claude:
"Get the item with ID abc123"
Ask Claude:
"Add to my knowledge base: The authentication system uses JWT tokens with a 1-hour expiration"
Ask Claude:
"Run an intelligent analysis of my codebase"
- Check config path: Ensure you're editing the correct config file
- Restart Claude: Completely quit and restart Claude Desktop
- Check project path: Verify
cwdpoints to a valid project with.k0ntext.db - Check logs: Look for MCP errors in Claude's developer console
Error: Database file not found: .k0ntext.db
Solution: Run k0ntext init in your project directory first.
If using intelligent analysis:
Error: OPENROUTER_API_KEY not set
Solution: Set your API key:
export OPENROUTER_API_KEY="your-key-here"Or add to your shell profile (~/.bashrc, ~/.zshrc, etc.).
Error: Port 3000 already in use
Solution: The MCP server uses stdio (not HTTP), so this shouldn't occur. If it does, ensure no other MCP servers are configured with the same name.
The current MCP server uses stdio transport. HTTP/SSE transport may be added in the future.
Available environment variables for the MCP server:
# Database location
export K0NTEXT_DB_PATH="/custom/path/.k0ntext.db"
# OpenRouter API key (for intelligent analysis)
export OPENROUTER_API_KEY="your-key-here"
# Log level
export K0NTEXT_LOG_LEVEL="debug" # debug, info, warn, errorK0ntext also provides 6 prompts for Claude:
| Prompt | Description |
|---|---|
analyze-codebase |
Analyze the entire codebase |
find-similar-code |
Find code similar to a pattern |
explain-architecture |
Explain system architecture |
review-changes |
Review recent code changes |
suggest-improvements |
Suggest code improvements |
check-drift |
Check documentation drift |
These prompts can be invoked directly from Claude Desktop.
- Full Documentation: https://github.com/SireJeff/k0ntext
- Troubleshooting: Troubleshooting Guide
- MCP Specification: https://modelcontextprotocol.io