API & MCP Integration
Run DiffContext as a local server and call it from your own tools,
scripts, or connect it to Claude Desktop as an MCP server.
🚀 Start the web server
pip install fastapi uvicorn
cd /path/to/Diffcontext
uvicorn diffcontext-service.backend.main:app --reload --port 8000
# Now open: http://localhost:8000/docs ← interactive API docs
📡 REST API Endpoints
POST
/upload
Upload a .zip of your project → get a repo_id
GET
/symbols?repo_id=abc123
List all functions in your project
POST
/blast
Get blast radius for a function
POST
/inline
Analyse pasted code (no upload needed)
POST
/compile
Get LLM-ready context string
Example — call from Python:
import requests
# 1. Upload your project
with open("myproject.zip", "rb") as f:
r = requests.post("http://localhost:8000/upload", files={"file": f})
repo_id = r.json()["repo_id"]
# 2. Get blast radius
r = requests.post("http://localhost:8000/blast", json={
"repo_id": repo_id,
"symbol": "./src/auth.py:validate_jwt"
})
print(r.json())
# 3. Get LLM context
r = requests.post("http://localhost:8000/compile", json={
"repo_id": repo_id,
"symbol": "./src/auth.py:validate_jwt",
"max_tokens": 8000
})
print(r.json()["context_text"]) # paste this into Claude
🤖 Connect to Claude Desktop (MCP)
1. Install MCP package:
pip install mcp
2. Add to Claude Desktop config:
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"diffcontext": {
"command": "python",
"args": ["/path/to/Diffcontext/diffcontext-service/mcp/mcp_server.py"]
}
}
}
3. Restart Claude Desktop, then ask:
"List all functions in /Users/me/myproject"
"What is the blast radius of ./src/auth.py:validate_jwt in /Users/me/myproject?"
"Compile context for ./service.py:onboard_user in /Users/me/myproject"