Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt

Use this file to discover all available pages before exploring further.

Connecting MCP to Cognee Cloud

The Cognee MCP server can connect to your Cognee Cloud tenant using the --serve-url and --serve-api-key flags. This lets any MCP-compatible client (Claude Desktop, Cursor, VS Code Copilot) work with your cloud-hosted knowledge graph.
Cognee MCPCognee Cloud
Where it runsLocally on your machineHosted by Cognee
Access methodMCP protocolcognee SDK via serve() or Cloud UI
AuthenticationBearer token (self-hosted)X-Api-Key header
API endpointsSelf-hosted backend endpoints such as /api/v1/remember and /api/v1/recallHosted SDK/client flow via serve()
Use caseAI IDE tools (Cursor, Claude Code, etc.)Cloud-managed knowledge graphs

Why API_URL only works with self-hosted Cognee backends

The MCP server’s API_URL / API_TOKEN mechanism is designed for self-hosted Cognee backends. When the MCP server runs in API mode, it:
  • Sends requests to self-hosted Cognee endpoints such as /api/v1/remember, /api/v1/recall, /api/v1/improve, and /api/v1/forget
  • Authenticates with Authorization: Bearer <token>
cognee-mcp --transport sse --port 8001 \
  --serve-url https://your-tenant.aws.cognee.ai \
  --serve-api-key your-api-key
Get your API Base URL and API key from the API Keys page in the Cognee Cloud console.
  • Authentication uses the X-Api-Key header, not a Bearer token
  • The recommended Cloud SDK flow connects through cognee.serve() rather than the MCP server’s API_URL bridge For the full setup guide, see Cloud MCP.
The older API_URL / API_TOKEN environment variables are designed for self-hosted Cognee backends, not Cognee Cloud. Use --serve-url and --serve-api-key for Cloud connections.

Other connection options

Run the MCP server in standalone mode (no Cloud connection). The server manages its own local knowledge graph.
# Standalone mode — requires LLM_API_KEY
LLM_API_KEY=sk-... cognee-mcp --transport sse --port 8001
This is the simplest way to add persistent memory to Cursor, Claude Code, Cline, and other MCP-compatible tools.
Access Cognee Cloud programmatically using the cognee SDK connected through serve(), which handles authentication and communication with the hosted service.
export COGNEE_SERVICE_URL="https://your-tenant.aws.cognee.ai"
export COGNEE_API_KEY="your-cognee-cloud-api-key"
import asyncio
import cognee

async def main():
    await cognee.serve()  # Reads COGNEE_SERVICE_URL and COGNEE_API_KEY
    await cognee.remember("...", dataset_name="my_dataset")
    results = await cognee.recall("...", datasets=["my_dataset"])
    print(results)

asyncio.run(main())
If you prefer not to use environment variables, pass both values directly:
await cognee.serve(
    url="https://your-tenant.aws.cognee.ai",
    api_key="your-api-key",
)
See the Cloud SDK guide for a complete walkthrough.
If you want multiple AI clients to share a single knowledge graph, run a self-hosted Cognee backend and point the MCP server at it using API_URL and API_TOKEN:
# 1. Start a self-hosted Cognee backend
docker run -e LLM_API_KEY=your_key -p 8080:8000 --rm -it cognee/cognee:main

# 2. Start MCP in API mode pointing to your backend
docker run \
  -e TRANSPORT_MODE=sse \
  -e API_URL=http://localhost:8080 \
  -e API_TOKEN=your_backend_token \
  -p 8000:8000 --rm -it cognee/cognee-mcp:main
See the MCP Quickstart for full details on this pattern.