Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building a Production-Ready FastMCP Server Integration for Cognee Knowledge Graphs

Description and use

A FastMCP server integration for Cognee was built, enabling MCP clients to ingest and query the knowledge graph, with all unit tests passing.

Problem

Context fragmentation limits autonomous AI agents because LLMs lose track of structured graph relationships across multi-turn sessions and disjointed tool calls.

Outcome

All 10 unit tests passed (100% green) in 0.06 seconds, confirming correct tool dispatching, error handling, and dataset segregation.

Workflow

  • 1. Deploy FastMCP server (server.py) exposing cognee_add_memory and cognee_search_memory tools.
  • 2. Configure Claude Desktop to use the server via claude_desktop_config.json.
  • 3. Use cognee_add_memory to ingest raw text or structured documents into Cognee’s ingestion pipeline, automatically cognifying and extracting entity relationships.
  • 4. Use cognee_search_memory to execute hybrid vector and graph queries for grounded context.
  • 5. Run pytest test suite to verify tool schema dispatching, error handling, case insensitivity, and dataset segregation.

Evidence

The integration lives under cognee/api/mcp/ and bridges standard MCP client requests directly into Cognee's engine.

Source

Implementation Snippet (server.py) Python from mcp.server.fastmcp import FastMCP import cognee mcp = FastMCP("Cognee-Context-Engine")

Source

Testing & Verification The integration includes a full mock test suite using pytest covering: Correct tool schema dispatching. Graceful handling of empty queries and malformed payloads. Case insensitivity and dataset segregation. Result: 10/10 unit tests passed (100% green) in 0.06 seconds.

Source

  • Record date: 2026-10-14T17:41:30.258Z