Building a Production-Ready FastMCP Server Integration for Cognee Knowledge Graphs
Описание и применение
Создана интеграция FastMCP для Cognee, позволяющая клиентам 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