化学空间搜索服务

一个为Chemspace API提供封装的模型上下文协议(MCP)服务器,支持通过精确、子结构和相似性搜索查找可合成的构建块和筛选化合物。

  • by lukasmki
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 lukasmki/chemspace-mcp

使用说明

chemspace mcp

模型上下文协议(MCP)服务器,为Chemspace API提供包装,使人工智能代理能够搜索可合成的构建块,并通过精确、子结构和相似性搜索筛选化合物。

特性

  • 精确搜索:通过SMILES查找精确的分子匹配
  • 亚结构检索:查找含有特定亚结构的化合物
  • 相似性搜索:通过SMILES找到结构相似的化合物
  • 多种产品类别:在库存中搜索并按需制造化合物
  • 全球航运:使用ISO国家代码指定发货国家

需求

  • Python 3.13+
  • Chemspace API密钥

安装

先决条件

安装 uv:

# macOS
brew install uv

# Linux/WSL2  
curl -LsSf https://astral.sh/uv/install.sh | sh

设置

  1. 克隆存储库并导航到项目目录

  2. 将Chemspace API密钥设置为环境变量:

    export CHEMSPACE_API_KEY="your-api-key-here"
    
  3. 安装依赖项并运行:

    uv run chemspace-mcp
    

配置

与FastAgent一起使用

配置 example/fastagent.secrets.yaml此处设置的环境变量将覆盖shell中的变量:

anthropic:
  api_key: your-anthropic-api-key

mcp:
  servers:
    chemspace:
      env:
        CHEMSPACE_API_KEY: your-chemspace-api-key

然后使用FastAgent运行示例界面:

cd example
uv run --extra agent agent.py

用法

MCP服务器公开了以下工具:

search_exact

通过SMILES字符串搜索精确的分子匹配。

参数:

  • smiles (string):要搜索的SMILES字符串
  • shipToCountry (string):两个字母的ISO国家代码(默认值:“US”)
  • count (整数):每页最大结果数(默认值:10)
  • page (整数):分页页码(默认值:1)
  • categories (列表):要搜索的产品类别:
    • CSSB:现有积木
    • CSSS:库存筛选化合物
    • CSMB:按需构建模块
    • CSMS:按需生产筛选化合物
    • CSCS:自定义请求

搜索子结构

搜索含有特定亚结构的化合物。

参数: 同 search_exact

搜索_相似性

寻找结构相似的化合物。

参数: 同 search_exact

项目结构

chemspace-mcp/
├── src/
│   └── chemspace_mcp/
│       ├── __init__.py          # Entry point and MCP server initialization
│       ├── tools.py             # Tool definitions for chemical searches
│       └── tokenmanager.py       # Token management for API authentication
├── example/
│   ├── agent.py                 # Example FastAgent integration
│   ├── fastagent.config.yaml    # FastAgent configuration
│   └── fastagent.secrets.yaml   # Secrets configuration (not in version control)
├── pyproject.toml               # Project metadata and dependencies
└── README.md                    # This file

发展

依赖项

  • fastmcp>=2.13.1:核心MCP服务器框架
  • fast-agent-mcp>=0.2.25:FastAgent集成

许可证

MIT许可证

支持

对于问题或疑问,请在项目存储库上打开问题。