Implementation:24kchengYe MemoMind create mcp server
| Knowledge Sources | |
|---|---|
| Domains | MCP, API_Design |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Concrete tool for creating and configuring a FastMCP server with all MemoMind tools, multi-bank/single-bank modes, global tool filtering, and LLM argument tolerance.
Description
The create_mcp_server function creates a FastMCP server instance and registers all MemoMind tools on it. It handles:
- Mode selection: multi_bank=True (default) exposes all tools with bank_id parameters; single-bank mode excludes bank-management tools
- Global tool filtering: applies the env-level mcp_enabled_tools allowlist (intersection with the mode's tool set)
- Config setup: builds MCPToolsConfig with bank_id_resolver, api_key_resolver, tenant_id_resolver, and include_bank_id_param
- Tool registration: calls register_mcp_tools with the configured config
- Extension loading: loads and registers additional tools from MCP extension if configured
- Tool tolerance: _make_tools_tolerant wraps all tools to strip unknown arguments (e.g., "explanation", "reasoning") that LLMs frequently add
The server runs as an HTTP transport endpoint, registered via `claude mcp add --transport http hindsight http://localhost:8888/mcp/`.
Usage
Import this function when you need to create a configured MCP server for MemoMind. It is called by the API factory (create_app) when MCP is enabled.
Code Reference
Source Location
- Repository: MemoMind
- File: engine/hindsight_api/api/mcp.py
- Lines: L107-182
Signature
def create_mcp_server(
memory: MemoryEngine,
multi_bank: bool = True,
) -> FastMCP:
Import
from hindsight_api.api.mcp import create_mcp_server
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| memory | MemoryEngine | Yes | Engine instance |
| multi_bank | bool | No | If True, expose all tools with bank_id parameters (default True) |
Outputs
| Name | Type | Description |
|---|---|---|
| mcp | FastMCP | Configured FastMCP server with all tools registered |
Usage Examples
Creating an MCP Server
from hindsight_api.api.mcp import create_mcp_server
# Multi-bank mode (default): all tools with bank_id parameter
mcp = create_mcp_server(memory=memory_engine, multi_bank=True)
# Single-bank mode: tools scoped to one bank
mcp = create_mcp_server(memory=memory_engine, multi_bank=False)
# The server can be mounted on an ASGI app or run standalone
# For Claude Code: claude mcp add --transport http hindsight http://localhost:8888/mcp/