cognee/cognee-mcp
Igor Ilic 38cdacbcb6
fix: Resolve issue with Gemini adapter (#1494)
<!-- .github/pull_request_template.md -->

## Description
Resolve Gemini Adapter issues:
 1. resolve embedding batch issue,
2. Resolve slowness because gemini tokenizer was sending word per word
to Googles API to count tokens (using OpenAI's local tokenizer to count
tokens for Gemini now)
 3. Update deprecated library and move to instructor

## Type of Change
<!-- Please check the relevant option -->
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Other (please specify):

## Pre-submission Checklist
<!-- Please check all boxes that apply before submitting your PR -->
- [ ] **I have tested my changes thoroughly before submitting this PR**
- [ ] **This PR contains minimal changes necessary to address the
issue/feature**
- [ ] My code follows the project's coding standards and style
guidelines
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added necessary documentation (if applicable)
- [ ] All new and existing tests pass
- [ ] I have searched existing PRs to ensure this change hasn't been
submitted already
- [ ] I have linked any relevant issues in the description
- [ ] My commits have clear and descriptive messages

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.
2025-10-07 18:04:18 +02:00
..
src fix: update UI server startup message to reflect dynamic frontend port 2025-09-27 20:11:39 +01:00
Dockerfile Merge main vol 4 (#1200) 2025-08-05 12:48:24 +02:00
entrypoint.sh fix: update entrypoint script to use cognee-mcp module 2025-09-25 20:42:40 +01:00
pyproject.toml fix: Resolve issue with Gemini adapter (#1494) 2025-10-07 18:04:18 +02:00
README.md Remove redundant instructions 2025-08-20 12:12:42 +01:00
uv.lock chore: Update lock files 2025-09-23 19:26:09 +02:00

Cognee Logo

cogneemcp - Run cognees memory engine as a Model Context Protocol server

Demo . Learn more · Join Discord · Join r/AIMemory

GitHub forks GitHub stars GitHub commits Github tag Downloads License Contributors

cognee - Memory for AI Agents  in 5 lines of code | Product Hunt

topoteretes%2Fcognee | Trendshift

Build memory for Agents and query from any client that speaks MCP  in your terminal or IDE.

Features

  • Multiple transports choose Streamable HTTP --transport http (recommended for web deployments), SSE --transport sse (realtime streaming), or stdio (classic pipe, default)
  • Integrated logging all actions written to a rotating file (see get_log_file_location()) and mirrored to console in dev
  • Local file ingestion feed .md, source files, Cursor rulesets, etc. straight from disk
  • Background pipelines longrunning cognify & codify jobs spawn offthread; check progress with status tools
  • Developer rules bootstrap one call indexes .cursorrules, .cursor/rules, AGENT.md, and friends into the developer_rules nodeset
  • Prune & reset wipe memory clean with a single prune call when you want to start fresh

Please refer to our documentation here for further information.

🚀 Quick Start

  1. Clone cognee repo
    git clone https://github.com/topoteretes/cognee.git
    
  2. Navigate to cognee-mcp subdirectory
    cd cognee/cognee-mcp
    
  3. Install uv if you don't have one
    pip install uv
    
  4. Install all the dependencies you need for cognee mcp server with uv
    uv sync --dev --all-extras --reinstall
    
  5. Activate the virtual environment in cognee mcp directory
    source .venv/bin/activate
    
  6. Set up your OpenAI API key in .env for a quick setup with the default cognee configurations
    LLM_API_KEY="YOUR_OPENAI_API_KEY"
    
  7. Run cognee mcp server with stdio (default)
    python src/server.py
    
    or stream responses over SSE
    python src/server.py --transport sse
    
    or run with Streamable HTTP transport (recommended for web deployments)
    python src/server.py --transport http --host 127.0.0.1 --port 8000 --path /mcp
    

You can do more advanced configurations by creating .env file using our template. To use different LLM providers / database configurations, and for more info check out our documentation.

🐳 Docker Usage

If youd rather run cognee-mcp in a container, you have two options:

  1. Build locally
    1. Make sure you are in /cognee root directory and have a fresh .env containing only your LLM_API_KEY (and your chosen settings).
    2. Remove any old image and rebuild:
      docker rmi cognee/cognee-mcp:main || true
      docker build --no-cache -f cognee-mcp/Dockerfile -t cognee/cognee-mcp:main .
      
    3. Run it:
      # For HTTP transport (recommended for web deployments)
      docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main
      # For SSE transport  
      docker run -e TRANSPORT_MODE=sse --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main
      # For stdio transport (default)
      docker run -e TRANSPORT_MODE=stdio --env-file ./.env --rm -it cognee/cognee-mcp:main
      
  2. Pull from Docker Hub (no build required):
    # With HTTP transport (recommended for web deployments)
    docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main
    # With SSE transport
    docker run -e TRANSPORT_MODE=sse --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main
    # With stdio transport (default)
    docker run -e TRANSPORT_MODE=stdio --env-file ./.env --rm -it cognee/cognee-mcp:main
    

Important: Docker vs Direct Usage

Docker uses environment variables, not command line arguments:

  • Docker: -e TRANSPORT_MODE=http
  • Docker: --transport http (won't work)

Direct Python usage uses command line arguments:

  • Direct: python src/server.py --transport http
  • Direct: -e TRANSPORT_MODE=http (won't work)

🔗 MCP Client Configuration

After starting your Cognee MCP server with Docker, you need to configure your MCP client to connect to it.

Start the server with SSE transport:

docker run -e TRANSPORT_MODE=sse --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main

Configure your MCP client:

Claude CLI (Easiest)

claude mcp add cognee-sse -t sse http://localhost:8000/sse

Verify the connection:

claude mcp list

You should see your server connected:

Checking MCP server health...

cognee-sse: http://localhost:8000/sse (SSE) - ✓ Connected

Manual Configuration

Claude (~/.claude.json)

{
  "mcpServers": {
    "cognee": {
      "type": "sse",
      "url": "http://localhost:8000/sse"
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "cognee-sse": {
      "url": "http://localhost:8000/sse"
    }
  }
}

HTTP Transport Configuration (Alternative)

Start the server with HTTP transport:

docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main

Configure your MCP client:

Claude CLI (Easiest)

claude mcp add cognee-http -t http http://localhost:8000/mcp

Verify the connection:

claude mcp list

You should see your server connected:

Checking MCP server health...

cognee-http: http://localhost:8000/mcp (HTTP) - ✓ Connected

Manual Configuration

Claude (~/.claude.json)

{
  "mcpServers": {
    "cognee": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "cognee-http": {
      "url": "http://localhost:8000/mcp"
    }
  }
}

Dual Configuration Example

You can configure both transports simultaneously for testing:

{
  "mcpServers": {
    "cognee-sse": {
      "type": "sse",
      "url": "http://localhost:8000/sse"
    },
    "cognee-http": {
      "type": "http", 
      "url": "http://localhost:8000/mcp"
    }
  }
}

Note: Only enable the server you're actually running to avoid connection errors.

💻 Basic Usage

The MCP server exposes its functionality through tools. Call them from any MCP client (Cursor, Claude Desktop, Cline, Roo and more).

Available Tools

  • cognify: Turns your data into a structured knowledge graph and stores it in memory

  • codify: Analyse a code repository, build a code graph, stores it in memory

  • search: Query memory supports GRAPH_COMPLETION, RAG_COMPLETION, CODE, CHUNKS, INSIGHTS

  • list_data: List all datasets and their data items with IDs for deletion operations

  • delete: Delete specific data from a dataset (supports soft/hard deletion modes)

  • prune: Reset cognee for a fresh start (removes all data)

  • cognify_status / codify_status: Track pipeline progress

Data Management Examples:

# List all available datasets and data items
list_data()

# List data items in a specific dataset
list_data(dataset_id="your-dataset-id-here")

# Delete specific data (soft deletion - safer, preserves shared entities)
delete(data_id="data-uuid", dataset_id="dataset-uuid", mode="soft")

# Delete specific data (hard deletion - removes orphaned entities)
delete(data_id="data-uuid", dataset_id="dataset-uuid", mode="hard")

Development and Debugging

Debugging

To use debugger, run: bash mcp dev src/server.py

Open inspector with timeout passed: http://localhost:5173?timeout=120000

To apply new changes while developing cognee you need to do:

  1. Update dependencies in cognee folder if needed
  2. uv sync --dev --all-extras --reinstall
  3. mcp dev src/server.py

Development

In order to use local cognee:

  1. Uncomment the following line in the cognee-mcp pyproject.toml file and set the cognee root path.

    #"cognee[postgres,codegraph,gemini,huggingface,docs,neo4j] @ file:/Users/<username>/Desktop/cognee"
    

    Remember to replace file:/Users/<username>/Desktop/cognee with your actual cognee root path.

  2. Install dependencies with uv in the mcp folder

    uv sync --reinstall
    

Code of Conduct

We are committed to making open source an enjoyable and respectful experience for our community. See CODE_OF_CONDUCT for more information.

💫 Contributors

contributors

Star History

Star History Chart