Gramps MCP 借助一套全面的工具,为人工智能助手提供对 Gramps 家谱数据库的直接访问。它能助力人工智能助手实现智能搜索、数据管理、树状分析、关系发现等功能,改变你研究家族历史的方式。
确保 Gramps Web 已运行:
启动服务器:
# 下载配置文件
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
# 使用你的 Gramps Web API 凭证编辑 .env 文件
# 启动服务器
docker-compose up -d
完成以上步骤后,MCP 服务器将在 http://localhost:8000/mcp 运行。
如果你倾向于直接使用 Python 运行服务器,可以按照以下步骤操作:
# 安装 uv(如果尚未安装)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 安装依赖项
uv sync
# HTTP 传输(适用于基于 Web 的 MCP 客户端)
uv run python -m src.gramps_mcp.server
# 标准输入输出传输(适用于基于 CLI 的 MCP 客户端)
uv run python -m src.gramps_mcp.server stdio
HTTP 服务器将在 http://localhost:8000/mcp 可用,而标准输入输出将直接在终端中运行。
创建一个 .env 文件,并配置你的 Gramps Web 设置:
# 你的 Gramps Web 实例(来自步骤 1)
GRAMPS_API_URL=https://your-gramps-web-domain.com # 不要加 /api 后缀 - 会自动添加
GRAMPS_USERNAME=your-gramps-web-username
GRAMPS_PASSWORD=your-gramps-web-password
GRAMPS_TREE_ID=your-tree-id # 在 Gramps Web 的系统信息中找到此 ID
# 下载配置文件
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
# 编辑 .env 文件,配置 Gramps Web API 凭证
# 启动服务器
docker-compose up -d
# 安装 uv(如果未安装)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 安装依赖项
uv sync
# 启动服务器
# HTTP 传输
uv run python -m src.gramps_mcp.server
# 标准输入输出传输
uv run python -m src.gramps_mcp.server stdio
创建 .env 文件,配置 Gramps Web 相关信息:
GRAMPS_API_URL=https://your-gramps-web-domain.com
GRAMPS_USERNAME=your-gramps-web-username
GRAMPS_PASSWORD=your-gramps-web-password
GRAMPS_TREE_ID=your-tree-id
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?
在 claude_desktop_config.json 文件中添加以下配置:
使用 Docker:
{
"mcpServers": {
"gramps": {
"command": "docker",
"args": ["exec", "-i", "gramps-mcp-gramps-mcp-1", "python", "-m", "src.gramps_mcp.server", "stdio"]
}
}
}
直接使用 uv:
{
"mcpServers": {
"gramps": {
"command": "uv",
"args": ["run", "python", "-m", "src.gramps_mcp.server", "stdio"],
"cwd": "/path/to/gramps-mcp"
}
}
}
使用 mcpo 代理 将 MCP 服务器作为 OpenAPI 端点暴露: 使用 uv:
uvx mcpo --port 8000 -- uv run python -m src.gramps_mcp.server stdio
使用 Docker:
uvx mcpo --port 8000 -- docker exec -i gramps-mcp-gramps-mcp-1 uv run python -m src.gramps_mcp.server stdio
HTTP 传输:
claude mcp add --transport http gramps http://localhost:8000/mcp
标准输入输出传输:
# 使用 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'"
# 直接使用 uv
claude mcp add --transport stdio gramps "uv run python -m src.gramps_mcp.server stdio"
使用 HTTP 传输端点:
{
"mcpServers": {
"gramps": {
"url": "http://localhost:8000/mcp"
}
}
}
src/gramps_mcp/
|-- server.py # 支持 HTTP 传输的 MCP 服务器
|-- tools.py # 工具注册与导出
|-- client.py # Gramps Web API 客户端
|-- models.py # Pydantic 数据模型
|-- auth.py # JWT 身份验证
|-- config.py # 配置管理
|-- tools/ # 模块化工具实现
| |-- search_basic.py
| |-- search_details.py
| |-- data_management.py
| |-- tree_management.py
| `-- analysis.py
|-- handlers/ # 数据格式化处理程序
`-- client/ # API 客户端模块
本项目采用 GNU Affero 通用公共许可证 v3.0 进行许可,请查看 LICENSE 文件以获取详细信息。
我们欢迎各方贡献!请查看 贡献指南 以了解: