Gramps
STDIO连接MCP助手与Gramps家谱数据库的AI谱系研究服务器
连接MCP助手与Gramps家谱数据库的AI谱系研究服务器
Genealogy research with AI assistants is limited and frustrating:
Gramps MCP provides AI assistants with direct access to your Gramps genealogy database through a comprehensive set of tools. Your AI assistant can now:
Add Gramps MCP to your AI assistant and transform how you research family history:
Search for all descendants of John Smith born in Ireland before 1850
Create a new person record for Mary O'Connor with birth date 1823 in County Cork
Find all families missing marriage dates and suggest research priorities
No more manual data entry, no context switching between apps, no generic genealogy advice.
Ensure Gramps Web is Running:
Start the Server:
# Download the configuration curl -O https://raw.githubusercontent.com/cabout-me/gramps-mcp/main/docker-compose.yml curl -O https://raw.githubusercontent.com/cabout-me/gramps-mcp/main/.env.example cp .env.example .env # Edit .env with your Gramps Web API credentials # Start the server docker-compose up -d
That's it! The MCP server will be running at http://localhost:8000/mcp
If you prefer to run the server directly with Python:
# Install uv (if not already installed) curl -LsSf https://astral.sh/uv/install.sh | sh # Install dependencies uv sync
# HTTP transport (for web-based MCP clients) uv run python -m src.gramps_mcp.server # Stdio transport (for CLI-based MCP clients) uv run python -m src.gramps_mcp.server stdio
The HTTP server will be available at http://localhost:8000/mcp, while stdio runs directly in the terminal.
Create a .env file with your Gramps Web settings:
# Your Gramps Web instance (from step 1) GRAMPS_API_URL=https://your-gramps-web-domain.com # Without /api suffix - will be added automatically GRAMPS_USERNAME=your-gramps-web-username GRAMPS_PASSWORD=your-gramps-web-password GRAMPS_TREE_ID=your-tree-id # Find this under System Information in Gramps Web
Add to your Claude Desktop MCP configuration file (claude_desktop_config.json):
Using Docker (works with both pre-built and local images):
{ "mcpServers": { "gramps": { "command": "docker", "args": ["exec", "-i", "gramps-mcp-gramps-mcp-1", "python", "-m", "src.gramps_mcp.server", "stdio"] } } }
Using uv directly (if running without Docker):
{ "mcpServers": { "gramps": { "command": "uv", "args": ["run", "python", "-m", "src.gramps_mcp.server", "stdio"], "cwd": "/path/to/gramps-mcp" } } }
OpenWebUI recommends using the mcpo proxy to expose MCP servers as OpenAPI endpoints.
With uv:
uvx mcpo --port 8000 -- uv run python -m src.gramps_mcp.server stdio
With Docker:
uvx mcpo --port 8000 -- docker exec -i gramps-mcp-gramps-mcp-1 uv run python -m src.gramps_mcp.server stdio
HTTP Transport:
claude mcp add --transport http gramps http://localhost:8000/mcp
Stdio Transport (direct connection, more efficient):
# Using Docker claude mcp add --transport stdio gramps "docker exec -i gramps-mcp-gramps-mcp-1 sh -c 'cd /app && python -m src.gramps_mcp.server stdio'" # Using uv directly (requires local setup) claude mcp add --transport stdio gramps "uv run python -m src.gramps_mcp.server stdio"
Transport Choice: Use stdio for better performance and direct integration with CLI tools like Claude Code. Use HTTP when you need the server to handle multiple clients or prefer web-based access.
For any other MCP client, use the HTTP transport endpoint:
{ "mcpServers": { "gramps": { "url": "http://localhost:8000/mcp" } } }
src/gramps_mcp/
|-- server.py           # MCP server with HTTP transport
|-- tools.py            # Tool registry and exports
|-- client.py           # Gramps Web API client
|-- models.py           # Pydantic data models
|-- auth.py             # JWT authentication
|-- config.py           # Configuration management
|-- tools/              # Modular tool implementations
|   |-- search_basic.py
|   |-- search_details.py
|   |-- data_management.py
|   |-- tree_management.py
|   `-- analysis.py
|-- handlers/           # Data formatting handlers
`-- client/             # API client modules
Find all people with the surname "Smith" born in Ireland
Show me recent changes to the family tree in the last 30 days
Create a new person record for Patrick O'Brien, born 1845 in Cork, Ireland
Add a marriage event for John and Mary Smith on June 15, 1870 in Boston
Find all descendants of Margaret Kelly and show their birth locations
Show me statistics about my family tree - how many people, families, and events
What recent changes have been made to my family tree in the last week?
Connection refused errors: Ensure your Gramps Web API server is running and accessible at the configured URL.
Authentication failures: Verify your username and password are correct and the user has appropriate permissions.
Tool timeout errors: Check your network connection and consider increasing timeout values for large datasets.
Docker issues: Ensure Docker and Docker Compose are installed and running.
To enable debug logging, check your application logs with:
docker-compose logs -f
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.
We welcome contributions! Please see our Contributing Guide for details on: