Protein MCP Server

Protein MCP Server

Enables searching, retrieving, and downloading protein structure data from the RCSB Protein Data Bank. Supports intelligent protein structure search, comprehensive data retrieval, and multiple file format downloads for bioinformatics research.

Category
Visit Server

README

蛋白质数据访问服务器 (Protein MCP Server)

🧬 基于 FastMCP 的蛋白质数据访问服务器,为生物信息学研究提供强大的蛋白质结构数据查询、获取和下载功能。

🎯 项目特色

工具精简优化 - 从8个工具优化为3个核心工具,减少62.5%复杂度 ✅ 功能完整保留 - 所有原有功能完整保留,无功能损失 ✅ 用户体验大幅提升 - 工具职责更清晰,学习成本更低 ✅ 代码质量优化 - 代码量减少39.2%,维护性显著提升 ✅ 多协议支持 - 支持stdio、http、sse三种传输协议

🚀 快速开始

方式一:uvx直接运行(推荐)

# 启动默认STDIO模式
uvx protein-mcp

# 启动HTTP服务器模式
uvx protein-mcp --transport http --port 8080

# 启动SSE实时模式
uvx protein-mcp --transport sse --port 8080

# 查看所有参数选项
uvx protein-mcp --help

方式二:从PyPI安装

# 安装最新版本
pip install protein-mcp

# 安装指定版本
pip install protein-mcp==0.1.5

# 升级到最新版本
pip install --upgrade protein-mcp

# 验证安装
protein-mcp --version

方式三:开发环境设置

# 克隆代码仓库
git clone https://github.com/gqy20/protein-mcp.git
cd protein-mcp

# 安装所有开发依赖
uv sync --dev

# 运行开发版本
uv run protein-mcp --transport http --port 8080

🛠️ 核心功能工具

1. 蛋白质结构搜索工具

智能搜索 - 支持多种搜索方式的蛋白质结构发现

# 获取热门蛋白质结构示例
find_protein_structures()

# 按关键词搜索(如:癌症靶点、激酶)
find_protein_structures(keywords="激酶", category="酶抑制剂")

# 按PDB ID精确查找
find_protein_structures(pdb_id="1A3N")

# 限制返回结果数量
find_protein_structures(max_results=10)

# 组合搜索条件
find_protein_structures(keywords="血红蛋白", category="氧气运输", max_results=5)

2. 蛋白质数据获取工具

综合数据 - 一次性获取完整的蛋白质信息包

# 获取所有类型数据
get_protein_data("1A3N", ["all"])

# 获取特定数据类型
get_protein_data("2HHB", ["basic", "sequence"])

# 获取指定链的数据
get_protein_data("1A3N", ["all"], chain_id="A")

# 自定义数据类型组合
get_protein_data("6VSB", ["basic", "structure", "sequence"])

3. 蛋白质结构文件下载工具

文件管理 - 下载和管理各种格式的蛋白质结构文件

# 获取PDB格式文件内容(默认)
download_structure("1A3N", "pdb")

# 下载mmCIF现代格式文件
download_structure("2HHB", "mmcif", save_local=True)

# 下载高性能MMTF二进制格式
download_structure("6VSB", "mmtf")

# 获取PDB文件但仅解析信息
download_structure("5G53", "pdb", save_local=False)

🌐 MCP客户端集成使用指南

Claude Desktop 集成

手动配置方式

步骤1:使用Claude Code的slash命令

# 添加MCP服务器到Claude Code
/mcp-server add protein-mcp

步骤2:创建Claude Code配置文件

创建或编辑文件:~/.claude/mcp.json

Claude Desktop 配置

创建或编辑 ~/.claude/mcp.json

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx",
      "args": ["protein-mcp"]
    }
  }
}

CodeX 配置

安装并添加MCP服务器:

# 安装到CodeX
mcp install protein-mcp

# 启动时自动加载
codex --mcp protein-mcp

创建 ~/.codex/mcp.json

{
  "servers": {
    "protein-mcp": {
      "command": "uvx protein-mcp"
    }
  }
}

高级配置选项

如需自定义参数,可扩展配置:

Claude Desktop 高级配置:

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx protein-mcp",
      "args": ["protein-mcp", "--transport", "stdio", "--port", "37787"],
      "env": {
        "PROTEIN_MCP_LOG_LEVEL": "debug",
        "PROTEIN_MCP_CACHE_DIR": "~/.cache/protein-mcp"
      }
    }
  }
}

CodeX 高级配置:

{
  "servers": {
    "protein-mcp": {
      "command": "uvx protein-mcp",
      "args": ["protein-mcp", "--transport", "stdio"],
      "workingDirectory": "~/protein-workspace",
      "env": {
        "CODEX_LOG_LEVEL": "info",
        "PROTEIN_MCP_TIMEOUT": "120",
        "PROTEIN_MCP_MODEL": "gpt-4"
      }
    }
  }
}

使用方法

启动Claude Code后,您可以直接在对话中:

  1. 语音/文字输入

    用户:帮我搜索与癌症相关的激酶蛋白质结构
    Claude:正在调用find_protein_structures工具,搜索癌症激酶相关蛋白质...
    
  2. 自动工具调用:Claude会根据您的需求自动选择合适的工具

  3. 实时数据获取:支持蛋白质结构搜索、序列分析、文件下载等操作

高级配置选项

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx",
      "args": [
        "protein-mcp",
        "--transport", "stdio",
        "--port", "37787"
      ],
      "env": {
        "PROTEIN_MCP_LOG_LEVEL": "debug",
        "RCSB_API_TIMEOUT": "60",
        "PROTEIN_MCP_CACHE_DIR": "~/.cache/protein-mcp",
        "PROTEIN_MCP_MAX_RETRIES": "3",
        "RCSB_API_BASE_URL": "https://data.rcsb.org"
      }
    }
  }
}

CodeX 集成

安装和配置

步骤1:安装MCP服务器到CodeX

# 通过MCP CLI安装
mcp install protein-mcp

# 验证安装
mcp list

# 查看服务器详情
mcp describe protein-mcp

步骤2:创建CodeX配置文件

创建或编辑文件:~/.codex/mcp.json

{
  "servers": {
    "protein-mcp": {
      "command": "uvx",
      "args": [
        "protein-mcp",
        "--transport", "stdio"
      ],
      "workingDirectory": "~",
      "env": {
        "CODEX_LOG_LEVEL": "info",
        "PROTEIN_MCP_TIMEOUT": "120",
        "PROTEIN_MCP_MODEL": "gpt-4",
        "PROTEIN_MCP_WORKSPACE": "~/.workspace/protein-research"
      }
    }
  }
}

使用方式

启动CodeX后,在代码编辑器中:

  1. 智能代码提示:CodeX会根据上下文自动提示相关的蛋白质分析
  2. 工具快速调用:通过注释或特殊命令快速调用MCP工具
  3. 工作区集成:自动创建蛋白质研究工作区

CodeX专用配置

{
  "servers": {
    "protein-mcp": {
      "command": "uvx",
      "args": [
        "protein-mcp",
        "--transport", "stdio",
        "--log-level", "info"
      ],
      "workingDirectory": "~/protein-research",
      "env": {
        "CODEX_MODEL": "claude-3.5-sonnet",
        "CODEX_MAX_TOKENS": "10000",
        "CODEX_TEMPERATURE": "0.1",
        "PROTEIN_MCP_BATCH_SIZE": "20",
        "PROTEIN_MCP_AUTO_SAVE": "true"
      }
    }
  }
}

通用编程集成

方式1:Python客户端直接调用

import subprocess
import json
import asyncio

class ProteinMCPClient:
    def __init__(self, transport="stdio"):
        self.transport = transport

    async def start_server(self):
        # 启动MCP服务器进程
        self.process = await asyncio.create_subprocess_exec(
            "uvx",
            ["protein-mcp", "--transport", self.transport]
        )

    async def call_tool(self, tool_name, arguments):
        # 调用指定工具
        request = {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
                "name": tool_name,
                "arguments": arguments
            }
        }

        # 发送请求并获取响应
        response = await self.send_request(request)
        return response.get("result", {})

# 使用示例
client = ProteinMCPClient()
await client.start_server()

# 调用蛋白质搜索
result = await client.call_tool(
    "find_protein_structures_tool",
    {"keywords": "激酶", "max_results": 5}
)

方式2:HTTP REST API集成

import requests
import json

class ProteinMCPHTTPClient:
    def __init__(self, base_url="http://localhost:8080"):
        self.base_url = base_url

    def call_tool(self, tool_name, arguments):
        """通过HTTP API调用MCP工具"""
        url = f"{self.base_url}/mcp"

        # 调用蛋白质数据获取工具
        response = requests.post(url, json={
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
                "name": "get_protein_data_tool",
                "arguments": {
                    "pdb_id": "1A3N",
                    "data_types": ["all"]
                }
            }
        })

        return response.json().get("result", {})

# 使用示例
client = ProteinMCPHTTPClient()
protein_data = client.call_tool("get_protein_data_tool", {...})

方式3:直接导入Python模块

# 直接导入服务器创建函数
from protein_mcp import create_server

# 创建自定义服务器实例
server = create_server(
    name="my-protein-server",
    version="0.1.5"
)

# 启动服务器
server.run()

# 异步HTTP模式
import asyncio
async def start_http_server():
    await server.run_http_async(host="localhost", port=8080)

asyncio.run(start_http_server())

环境变量配置详解

基础配置

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx",
      "args": ["protein-mcp"],
      "env": {
        "PROTEIN_MCP_LOG_LEVEL": "debug",
        "RCSB_API_TIMEOUT": "60",
        "PROTEIN_MCP_CACHE_DIR": "~/.cache/protein-mcp",
        "PROTEIN_MCP_CACHE_DURATION": "3600",
        "PROTEIN_MCP_MAX_RETRIES": "3"
      }
    }
  }
}

高级配置

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx",
      "args": [
        "protein-mcp",
        "--transport", "stdio",
        "--concurrent-limit", "5"
      ],
      "env": {
        "PROTEIN_MCP_LOG_FORMAT": "json",
        "PROTEIN_MCP_VERIFY_SSL": "true",
        "RCSB_API_CUSTOM_ENDPOINT": "https://custom.rcsb.org/api",
        "PROTEIN_MCP_PROXY_URL": "http://proxy.company.com:8080",
        "PROTEIN_MCP_USER_AGENT": "Protein-MCP-Client/1.0"
      }
    }
  }
}

开发调试配置

{
  "mcpServers": {
    "protein-mcp": {
      "command": "uvx",
      "args": [
        "python", "-m", "protein_mcp.server",
        "--transport", "stdio",
        "--debug"
      ],
      "env": {
        "PROTEIN_MCP_LOG_LEVEL": "trace",
        "PROTEIN_MCP_LOG_REQUESTS": "true",
        "PROTEIN_MCP_LOG_RESPONSES": "true",
        "PROTEIN_MCP_PERFORMANCE_STATS": "true"
      }
    }
  }
}

🏗️ 项目架构

protein-mcp/
├── src/protein_mcp/           # 核心代码包
│   ├── __init__.py          # 包初始化
│   ├── server.py             # FastMCP服务器主逻辑
│   ├── tools.py              # 3个核心工具实现
│   └── utils.py              # 通用工具函数
├── tests/                   # 完整测试套件
│   ├── conftest.py           # pytest配置和夹具
│   ├── quick_test.py         # 快速功能验证
│   ├── test_*.py            # 各功能模块测试
│   └── README.md             # 测试说明文档
├── .github/workflows/        # CI/CD自动化流程
│   ├── code-quality.yml     # 代码质量检查和格式化
│   └── publish.yml         # 自动构建和PyPI发布
├── pyproject.toml          # Python包配置
├── pytest.ini              # pytest测试配置
├── .pre-commit-config.yaml  # 预提交钩子配置
├── .gitignore              # Git忽略文件配置
└── README.md               # 项目主文档

🔧 技术架构

核心技术栈

  • FastMCP框架 - 现代化的MCP服务器实现
  • RCSB PDB API - 权威的蛋白质结构数据库
  • Python 3.10+ - 现代Python特性和类型注解
  • 异步编程 - 高并发性能的网络请求处理
  • 多传输协议 - stdio、http、sse全支持

数据处理流程

  1. 智能API路由 - 根据请求类型自动选择最佳数据源
  2. 混合数据获取 - API + PDB文件解析的双重保障
  3. 自动降级机制 - API失败时无缝切换到文件解析
  4. 缓存优化 - 智能缓存减少重复请求

安全和性能

  • SSL证书验证 - 所有HTTPS连接强制SSL验证
  • 请求超时控制 - 可配置的网络请求超时
  • 内存优化 - 流式处理大文件,降低内存占用
  • 错误恢复 - 完善的错误处理和重试机制

📊 性能指标

基准测试结果

  • 搜索响应时间:< 2秒(基本搜索)
  • 数据获取时间:2-6秒(完整蛋白质信息)
  • 文件下载速度:1-10MB/秒(取决于网络和文件大小)
  • 并发处理能力:支持最多10个并发请求
  • 内存使用效率:处理大PDB文件时内存占用< 200MB

可靠性指标

  • API成功率:> 95%(在正常网络条件下)
  • 数据完整性:100%文件校验和错误检测
  • 服务可用性:7×24小时服务稳定性
  • 自动恢复能力:网络中断后自动重连和重试

🧪 测试体系

测试覆盖

# 运行所有测试
uv run pytest tests/ -v --cov=src/protein_mcp --cov-report=html

# 运行特定测试模块
uv run pytest tests/test_tools.py -v
uv run pytest tests/test_integration.py -v

# 性能基准测试
uv run pytest tests/test_performance.py -v

测试分类

  • 单元测试 - 每个工具函数的独立测试
  • 集成测试 - 多工具协作的端到端测试
  • 性能测试 - 响应时间和资源使用测试
  • 兼容性测试 - 不同Python版本和平台兼容性

🔧 开发指南

本地开发设置

# 1. 克隆仓库
git clone https://github.com/gqy20/protein-mcp.git
cd protein-mcp

# 2. 创建虚拟环境(推荐使用uv)
uv venv .venv
source .venv/bin/activate

# 3. 安装开发依赖
uv sync --dev

# 4. 安装预提交钩子
pip install pre-commit
pre-commit install

# 5. 运行开发服务器
uv run protein-mcp --transport http --port 8080

代码质量规范

# 代码格式化
uv run black src/ tests/

# 代码检查和修复
uv run ruff check src/ tests/ --fix

# 导入排序
uv run isort src/ tests/

# 类型检查
uv run mypy src/protein_mcp/

# 预提交检查
pre-commit run --all-files

贡献流程

  1. Fork仓库 - 在GitHub上fork项目
  2. 创建功能分支 - git checkout -b feature/your-feature
  3. 开发和测试 - 确保所有测试通过
  4. 提交代码 - git commit -m 'feat: add your feature'
  5. 推送分支 - git push origin feature/your-feature
  6. 创建Pull Request - 在GitHub上创建PR

提交信息规范

  • feat: 新功能
  • fix: 错误修复
  • docs: 文档更新
  • style: 代码格式化
  • refactor: 代码重构
  • test: 测试相关
  • chore: 构建工具、依赖更新等

📦 构建和发布

本地构建

# 构建分发包
uv build

# 构建源码包
uv build --sdist

# 验证构建结果
ls -la dist/

发布流程

# 1. 构建包
uv build

# 2. 检查包内容
twine check dist/*

# 3. 上传到PyPI(需要配置API token)
twine upload dist/*

# 4. 创建GitHub Release
gh release create v0.1.0 --title="Release v0.1.0" --notes="Release notes"

版本管理

# 更新版本号(修改pyproject.toml中的version字段)
# 然后提交和创建tag
git tag v0.1.1
git push origin v0.1.1

📚 API文档

工具列表

工具名称 功能描述 主要参数
find_protein_structures_tool 蛋白质结构搜索 keywords, category, pdb_id, max_results
get_protein_data_tool 蛋白质数据获取 pdb_id, data_types, chain_id
download_structure_tool 结构文件下载 pdb_id, file_format, save_local

参数说明

搜索参数

  • keywords: 关键词搜索(支持中英文)
  • category: 分类筛选(如:酶抑制剂、膜蛋白等)
  • pdb_id: 精确PDB ID查找
  • max_results: 最大返回结果数量(默认10)

数据类型

  • basic: 基本信息(标题、作者、分辨率等)
  • sequence: 氨基酸序列信息
  • structure: 二级结构和配体信息
  • all: 包含所有数据类型

文件格式

  • pdb: 标准PDB格式(推荐,人类可读)
  • mmcif: 大分子晶体信息文件(现代标准)
  • mmtf: 高性能二进制格式(最快下载)

🌟 支持和社区

获取帮助

  • GitHub Issues: https://github.com/gqy20/protein-mcp/issues
  • 文档: https://github.com/gqy20/protein-mcp#readme
  • PyPI: https://pypi.org/project/protein-mcp/

许可证

MIT License - 详见 LICENSE 文件


🧬 Protein MCP Server - 为生物信息学研究提供专业、高效的蛋白质数据访问服务!

蛋白质,让研究更简单! 🎉

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured