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

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

说明与用途

为 Cognee 构建了 FastMCP 服务器集成,使 MCP 客户端能够读写知识图谱,并通过所有单元测试。

问题

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

结果

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

工作流

  • 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.

证据

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

来源

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

来源

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.

来源

  • 记录日期: 2026-10-14T17:41:30.258Z