GitHub

MCP Integration

Use Functor memory tools with Claude Desktop, Claude Code, and any MCP-compatible client.

What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI assistants to connect with external tools and data sources. Claude Desktop, Claude Code, and other MCP-compatible clients can use Functor memory tools directly.

Quick Start

Step 1: Generate MCP Tools

Use the SDK to generate MCP-format tool definitions:

from functor_sdk import FunctorClient
from functor_sdk.tools import ToolRegistry, generate_mcp_tools
# Initialize client
client = FunctorClient(api_key="your-api-key")
# Discover and generate MCP tools
registry = ToolRegistry()
tools = registry.discover(client.memory)
mcp_tools = generate_mcp_tools(tools)
# Each tool has: name, description, inputSchema
print(f"Generated {len(mcp_tools)} MCP tools")

Step 2: Create Tool Handler

Create a handler function that executes tool calls:

from functor_sdk.tools import FunctorToolContext, create_mcp_handler
# Create context and handler
ctx = FunctorToolContext(client)
handler = create_mcp_handler(ctx)
# The handler function signature:
# async def handler(tool_name: str, arguments: dict) -> dict

Step 3: Integrate with MCP Server

Use the generated tools and handler in your MCP server:

from mcp.server import Server
from mcp.types import Tool
# Create MCP server
server = Server("functor-memory")
@server.list_tools()
async def list_tools():
return mcp_tools
@server.call_tool()
async def call_tool(name: str, arguments: dict):
result = await handler(name, arguments)
return result

Claude Desktop Configuration

Add Functor to your Claude Desktop configuration file:

Config File Location

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\\Claude\\claude_desktop_config.json
{
"mcpServers": {
"functor-memory": {
"command": "python",
"args": ["-m", "functor_sdk.mcp_server"],
"env": {
"FUNCTOR_API_KEY": "your-api-key",
"FUNCTOR_BASE_URL": "http://localhost:8000"
}
}
}
}

Claude Code Integration

For Claude Code, add Functor to your MCP configuration:

{
"mcpServers": {
"functor-memory": {
"command": "python",
"args": ["path/to/your/mcp_server.py"],
"env": {
"FUNCTOR_API_KEY": "your-api-key"
}
}
}
}

Complete MCP Server Example

Here's a complete MCP server implementation:

#!/usr/bin/env python3
"""Functor Memory MCP Server"""
import asyncio
import os
from mcp.server import Server
from mcp.server.stdio import stdio_server
from functor_sdk import FunctorClient
from functor_sdk.tools import (
ToolRegistry,
FunctorToolContext,
generate_mcp_tools,
create_mcp_handler,
)
# Initialize
client = FunctorClient(
api_key=os.getenv("FUNCTOR_API_KEY"),
base_url=os.getenv("FUNCTOR_BASE_URL", "http://localhost:8000")
)
# Generate tools
registry = ToolRegistry()
tools = registry.discover(client.memory)
mcp_tools = generate_mcp_tools(tools)
# Create handler
ctx = FunctorToolContext(client)
handler = create_mcp_handler(ctx)
# Create server
server = Server("functor-memory")
@server.list_tools()
async def list_tools():
"""Return all available memory tools."""
return [
{
"name": tool["name"],
"description": tool["description"],
"inputSchema": tool["inputSchema"]
}
for tool in mcp_tools
]
@server.call_tool()
async def call_tool(name: str, arguments: dict):
"""Execute a memory tool."""
try:
result = await handler(name, arguments)
return {"success": True, "result": result}
except Exception as e:
return {"success": False, "error": str(e)}
async def main():
async with stdio_server() as (read_stream, write_stream):
await server.run(read_stream, write_stream)
if __name__ == "__main__":
asyncio.run(main())

Example Tool Calls

Once configured, Claude can use Functor memory tools naturally:

User:

"Remember that I prefer Python over JavaScript for backend development"

Claude (using functor_personalization_add_preference):

I've stored your preference for Python over JavaScript for backend development. I'll remember this for future conversations.

User:

"What did we discuss yesterday about the API design?"

Claude (using functor_episodic_search):

Yesterday we discussed REST vs GraphQL for your API. You decided to use REST with OpenAPI documentation. We also talked about authentication using JWT tokens...

Available MCP Tools

All 71 memory tools are available in MCP format. Here are some commonly used ones:

Tool NameDescription
functor_episodic_createStore a conversation or interaction
functor_episodic_searchSearch past conversations
functor_semantic_add_factStore a knowledge fact
functor_personalization_add_preferenceStore user preference
functor_personalization_get_contextGet personalized context for user
functor_procedural_createStore a learned procedure

Full Reference

See the Tool Reference for the complete list of all 71 tools with parameters.