Inspiration

Inspiration

Context fragmentation is one of the most critical bottlenecks when building autonomous AI agents. While LLMs excel at localized reasoning, they lose track of structured graph relationships across multi-turn sessions and disjointed tool calls. We wanted to give AI agents persistent, deterministic memory backed by knowledge graphs without forcing developers to write complex Cypher queries or custom database glue code.

What it does

This project provides a production-grade FastMCP (Model Context Protocol) server integration for Cognee, allowing standard MCP clients (such as Claude Desktop and Cursor) to read and write directly to persistent knowledge graphs seamlessly.

Key capabilities:

  • cognee_add_memory: Ingests unstructured context or raw documents into Cognee's cognitive pipeline, automatically extracting entities and graph relationships.
  • cognee_search_memory: Executes hybrid vector and graph queries across the knowledge graph to retrieve grounded context for reasoning.
  • Standard Protocol Compliance: Implements the Model Context Protocol over standard I/O (stdio), making it plug-and-play with existing agent tools.

How we built it

  • FastMCP Framework: Leveraged FastMCP (mcp.server.fastmcp) to expose asynchronous, typed tools adhering to the Model Context Protocol specifications.
  • Cognee Core: Interfaced directly with Cognee's async ingestion (cognee.add, cognee.cognify) and retrieval (cognee.search) engines.
  • End-to-End Demo: Built a standalone interactive demo (demo_agent.py) simulating an agent ingesting context and retrieving structured graph memory.
  • Testing & Verification: Created a full mock unit test suite covering tool schema dispatching, malformed input handling, and dataset isolation with 10/10 tests passing.

Challenges we ran into

Handling asynchronous pipeline lifecycles over standard I/O streams while maintaining isolation between different dataset namespaces required careful exception boundaries and strict schema typing. Ensuring fallback execution for developers running without pre-configured vector databases was also critical.

Accomplishments that we're proud of

  • Delivered an upstream pull request directly to the official Cognee repository (topoteretes/cognee#5864).
  • Achieved 100% test pass rate across all tool dispatchers in under 0.1s.
  • Created an end-to-end reproducible developer experience requiring zero boilerplate.

What we learned

We learned how seamlessly the Model Context Protocol bridges agent reasoning loops with structured knowledge graphs, turning flat text retrievals into relational graph intelligence.

What's next for FastMCP Context Engine for Cognee

  • Adding direct Cypher graph traversal tools for advanced graph inspection.
  • Streaming memory updates over SSE (Server-Sent Events) for multi-agent swarms. ## What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for FastMCP Context Engine for Cognee Knowledge Graphs

Built With

  • cognee
  • fastmcp
  • graph-database
  • knowledge-graph
  • model-context-protocol
  • python
Share this project:

Updates

Submission history