一个提供对BERtron API访问的模型上下文协议(MCP)服务器,该API聚合了来自多个生物和环境研究(BER)数据源的基因组和环境数据,包括EMSL、ESS-DIVE、JGI、MONET和NMDC。
# 直接运行而不安装
uvx --from git+https://github.com/ber-data/bertron-mcp.git bertron-mcp
# 或者先安装,然后运行
uvx --from git+https://github.com/ber-data/bertron-mcp.git bertron-mcp --version
git clone https://github.com/ber-data/bertron-mcp.git
cd bertron-mcp
make dev
pip install bertron-mcp
geosearch在指定距离内的地理坐标搜索实体。
参数:
latitude (float): 纬度坐标 (-90.0 到 90.0)longitude (float): 经度坐标 (-180.0 到 180.0)search_radius_km (float, 可选): 搜索半径,单位为公里(默认值:1.0)返回值: 包含实体、计数和元数据的QueryResponse
bbox_search在矩形地理边界框内搜索实体。
参数:
southwest_lat (float): 西南角纬度 (-90.0 到 90.0)southwest_lng (float): 西南角经度 (-180.0 到 180.0)northeast_lat (float): 东北角纬度 (-90.0 到 90.0)northeast_lng (float): 东北角经度 (-180.0 到 180.0)返回值: 包含边界框内实体的QueryResponse
entity_lookup通过唯一ID检索特定实体的详细信息。
参数:
entity_id (string): 实体的唯一标识符(例如:"nmdc:bsm-12-abc123")返回值: 包含完整元数据的Entity对象
advanced_query执行复杂的MongoDB查询,包括过滤、投影和排序。
参数:
filter_dict (dict, 可选): MongoDB过滤条件(例如:{"entity_type": "sample"})projection (dict, 可选): 需要包含或排除的字段(例如:{"name": 1, "coordinates": 1})skip (int, 可选): 用于分页跳过的文档数量(默认值:0)limit (int, 可选): 返回的最大文档数量(默认值:100)sort (dict, 可选): 排序条件(例如:{"name": 1} 表示升序)返回值: 包含匹配实体的QueryResponse
search_by_source查找来自特定BER数据源的实体。
参数:
source (string): BER数据源名称(EMSL, ESS-DIVE, JGI, NMDC, MONET)返回值: 包含指定来源实体的QueryResponse
search_by_type查找特定类型的实体。
参数:
entity_type (string): 实体类型(biodata, sample, sequence, taxon, jgi_biosample)返回值: 包含指定类型实体的QueryResponse
search_by_name使用正则表达式模式匹配搜索实体名称。
参数:
name_pattern (string): 要搜索的名称模式(支持正则表达式)case_sensitive (bool, 可选): 是否进行大小写敏感搜索(默认值:False)返回值: 包含匹配名称模式的实体的QueryResponse
health_check检查BERtron API的健康状态。
参数: 无
返回值: 包含web_server和database布尔状态的字典
为了防止响应过载和保护系统资源,实施了以下限制:
当应用限制时,工具会自动在响应元数据中报告约束:
{
"entities": [...],
"count": 1000,
"metadata": {
"constraints_applied": {
"requested_limit": 5000,
"actual_limit": 1000,
"reason": "超过最大限制1000"
}
}
}
以下工具接受可选的limit参数:
search_by_source(source, limit=100)search_by_type(entity_type, limit=100)search_by_name(name_pattern, case_sensitive=False, limit=100)advanced_query(filter_dict=None, limit=100, skip=0, ...)advanced_query 需要过滤条件以防止意外的全库导出安装开发依赖:
make dev
运行完整的测试套件:
make all
测试特定组件:
# API集成测试
make test-integration
# MCP协议测试
make test-mcp
make test-mcp-extended
# 使用Claude CLI测试
make test-claude-mcp
# 版本检查
make test-version
选项1:从GitHub(推荐)
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"bertron-mcp": {
"command": "uvx",
"args": ["--from", "git+https://github.com/ber-data/bertron-mcp.git", "bertron-mcp"]
}
}
}
选项2:本地开发
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"bertron-mcp": {
"command": "uv",
"args": ["run", "python", "src/bertron_mcp/main.py"],
"cwd": "/path/to/bertron-mcp"
}
}
}
从GitHub:
claude mcp add bertron-mcp "uvx --from git+https://github.com/ber-data/bertron-mcp.git bertron-mcp"
本地开发:
claude mcp add -s project bertron-mcp uv run python src/bertron_mcp/main.py
生产(发布到PyPI后):
claude mcp add -s project bertron-mcp uvx bertron-mcp
从GitHub:
goose session --with-extension "uvx --from git+https://github.com/ber-data/bertron-mcp.git bertron-mcp"
本地开发:
goose session --with-extension "uv run python src/bertron_mcp/main.py"
在佛罗里达州奥兰多附近100公里范围内搜索基因组样本:
> 使用bertron-mcp搜索纬度28.5383,经度-81.3792附近的实体,半径100公里
在覆盖黄石国家公园的边界框内搜索实体:
> 使用bbox_search在西南角(44.0, -125.0)和东北角(49.0, -110.0)之间查找实体
查找所有NMDC样本实体:
> 从NMDC数据源搜索所有样本实体
查找特定实体的详细信息:
> 使用entity_lookup获取实体ID "nmdc:bsm-12-abc123" 的详细信息
# 测试geosearch工具
echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "geosearch", "arguments": {"latitude": 28.5383, "longitude": -81.3792, "search_radius_km": 100.0}}, "id": 1}' | uv run python src/bertron_mcp/main.py
# 测试边界框搜索
echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "bbox_search", "arguments": {"southwest_lat": 44.0, "southwest_lng": -125.0, "northeast_lat": 49.0, "northeast_lng": -110.0}}, "id": 2}' | uv run python src/bertron_mcp/main.py
# 测试按数据源搜索
echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "search_by_source", "arguments": {"source": "NMDC"}}, "id": 3}' | uv run python src/bertron_mcp/main.py
# 测试带有过滤条件的高级查询
echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "advanced_query", "arguments": {"filter_dict": {"entity_type": "sample"}, "limit": 10}}, "id": 4}' | uv run python src/bertron_mcp/main.py
# 格式化和检查代码
make format
make lint
# 类型检查
make mypy
# 依赖分析
make deptry
# 构建包
make build
# 完整发布工作流
make release
BERtron聚合了来自以下数据源的数据:
git checkout -b feature/your-featuremake allgit commit -m "添加你的功能"git push origin feature/your-featureBSD-3-Clause