Claude Code Integration
Claude Code is Anthropic’s command-line AI assistant. Cognee can connect to it in two ways:- Cognee memory plugin: recommended for Claude Code memory across sessions. The plugin captures prompts, tool traces, and assistant responses into session memory, injects relevant context on each prompt, and syncs session memory into the permanent knowledge graph at session end.
- MCP server: use this when you want Claude Code to call Cognee MCP tools from an existing Cognee MCP server.
Prerequisites
- Node.js and npm installed
- For plugin local mode:
LLM_API_KEY - For plugin Cloud or remote mode:
COGNEE_BASE_URLandCOGNEE_API_KEY - For MCP mode: Cognee MCP server running (see Quickstart or Local Setup)
Plugin Setup
1
Install Claude Code
2
Install the Cognee memory plugin
Install from your shell before launching Claude Code, so the first
claude session can bootstrap memory cleanly:3
Choose local or Cloud mode
- Local
- Cloud or remote
Local mode is the default. The plugin starts a local Cognee API at
http://localhost:8011. Only LLM_API_KEY is required; the Cognee API key is auto-minted if absent.4
Confirm the connection
On startup, Claude Code should show a Cognee Memory Connected system message.
SessionStart selects mode and sets up identity, UserPromptSubmit injects dataset-scoped context, PostToolUse captures tool traces, Stop writes the assistant’s answer, PreCompact preserves memory across context resets, and SessionEnd syncs the session into the permanent graph.
See the plugin README for sessions, datasets, and full configuration.
MCP Setup
Use MCP if you already run Cognee MCP and want Claude Code to call Cognee tools through the Model Context Protocol.1
Navigate to your project
2
Add the Cognee MCP server
Choose the command that matches how you started Cognee MCP:
- Docker (HTTP)
- Local (stdio)
Use this if you started Cognee MCP with Docker:This creates a configuration in your project’s
.mcp.json file that connects to the HTTP endpoint.Options:-s project: Stores configuration in the project and requires approval per project- Omit
-s project: Stores configuration at user level
3
Start Claude Code and approve MCP
4
Use Cognee tools
Claude Code will use Cognee tools when relevant to your requests. You can explicitly ask:
- “Remember this design note in Cognee”
- “Recall authentication patterns from Cognee”
- “Improve the project memory in Cognee”
Where MCP Configuration Lives
The MCP configuration is stored in.mcp.json in your project directory when you pass -s project, or in your user settings when you omit it. Claude Code reads this file when starting a session in that directory.
Need Help?
Join Our Community
Get support and connect with other developers using Cognee.