化学分子计算平台
ChemMCP是一个基于模型上下文协议(MCP)的化学分子计算工具集合,提供19个专业的化学分子处理工具。支持网络搜索、分子量计算、原子计数等多种功能。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"ChemMCP": {
"args": [
"-m",
"chemmcp",
"--tools",
"WebSearch",
"MoleculeWeight",
"MoleculeAtomCount",
"MoleculeSimilarity",
"FunctionalGroups",
"SmilesCanonicalization",
"Iupac2Smiles",
"Smiles2Iupac",
"Smiles2Formula",
"Name2Smiles",
"Selfies2Smiles",
"Smiles2Selfies",
"Smiles2Cas",
"MoleculeSmilesCheck",
"ReactionSmilesCheck",
"MoleculeVisualizer",
"MoleculeCaptioner",
"MoleculeGenerator",
"MoleculeModifier"
],
"command": "/opt/miniconda3/envs/chemmcp/bin/python",
"env": {
"CHEMSPACE_API_KEY": "your_chemspace_api_key_here",
"LLM_MODEL_NAME": "openai/gpt-4o",
"OPENAI_API_KEY": "your_openai_api_key_here",
"PATH": "/opt/miniconda3/envs/chemmcp/bin:/usr/local/bin:/usr/bin:/bin",
"TAVILY_API_KEY": "your_tavily_api_key_here"
},
"toolCallTimeoutMillis": 300000
}
}
}
服务介绍
ChemMCP - Chemical Molecule Computation Platform
ChemMCP is a suite of chemical molecule computation tools based on the Model Context Protocol (MCP), providing 19 professional tools for handling chemical molecules.
🚀 Quick Start
Environment Requirements
- Python 3.11+ (Python 3.11 or 3.12 recommended)
- Conda environment manager
Installation Steps
-
Create a conda environment:
bash
conda create -n chemmcp python=3.11
conda activate chemmcp -
Install dependencies:
bash
pip install -r requirements.txt -
Install ChemMCP:
bash
pip install -e .
Installation Options
ChemMCP offers flexible installation options, allowing you to choose according to your needs:
Option 1: Basic Installation (Recommended)
bash
Installs core dependencies, supporting 17 tools
pip install -r requirements.txt
Supported Tools: All tools except MoleculeCaptioner and MoleculeGenerator
Option 2: Full Installation (Includes AI Tools)
bash
Method A: Using optional dependency groups
pip install -e ".[ai]"
Method B: Manually installing AI dependencies
pip install -r requirements.txt
pip install transformers>=4.20.0 torch>=1.9.0
Supported Tools: All 19 tools, including AI-driven molecular captioning and generation capabilities
Option 3: Development Environment
bash
Installs all dependencies and development tools
pip install -e ".[all,dev]"
Setting Up Environment Variables
Set the appropriate API keys based on the tools being used:
bash
Required for WebSearch tool
export TAVILY_API_KEY="your_tavily_api_key"
Required for LLM tools
export LLM_MODEL_NAME="openai/gpt-4o"
export OPENAI_API_KEY="your_openai_api_key"
Optional for ChemSpace tool (used as fallback if PubChem lookup fails)
export CHEMSPACE_API_KEY="your_chemspace_api_key"
🔧 Tool List
1. WebSearch - Web Search
Functionality: Performs web searches to obtain chemistry-related information
Input: Search query string
Output: Search results and relevant links
2. MoleculeWeight - Molecular Weight Calculation
Functionality: Calculates the molecular weight of a molecule
Input: SMILES structure string
Output: Numerical value of the molecular weight
3. MoleculeAtomCount - Atom Count
Functionality: Counts the number of each type of atom in a molecule
Input: SMILES structure string
Output: Count statistics for each atom type
4. MoleculeSimilarity - Molecular Similarity
Functionality: Computes the Tanimoto similarity between two molecules
Input: Two SMILES structure strings
Output: Similarity score (0-1)
5. FunctionalGroups - Functional Group Identification
Functionality: Identifies functional groups present in a molecule
Input: SMILES structure string
Output: List of detected functional groups
6. SmilesCanonicalization - SMILES Canonicalization
Functionality: Converts a SMILES string to its canonical form
Input: SMILES structure string
Output: Canonicalized SMILES string
7. Iupac2Smiles - IUPAC Name to SMILES
Functionality: Converts an IUPAC chemical name to SMILES format
Input: IUPAC chemical name
Output: Corresponding SMILES string
8. Smiles2Iupac - SMILES to IUPAC Name
Functionality: Converts a SMILES format to an IUPAC chemical name
Input: SMILES structure string
Output: Corresponding IUPAC chemical name
9. Smiles2Formula - SMILES to Molecular Formula
Functionality: Converts a SMILES format to a molecular formula
Input: SMILES structure string
Output: Molecular formula (e.g., C2H6O)
10. Name2Smiles - Common Name to SMILES
Functionality: Converts a common chemical name to SMILES format
Input: Chemical name
Output: Corresponding SMILES string
11. Selfies2Smiles - SELFIES to SMILES
Functionality: Converts a SELFIES format to SMILES format
Input: SELFIES string
Output: Corresponding SMILES string
12. Smiles2Selfies - SMILES to SELFIES
Functionality: Converts a SMILES format to SELFIES format
Input: SMILES structure string
Output: Corresponding SELFIES string
13. Smiles2Cas - SMILES to CAS Number
Functionality: Converts a SMILES format to a CAS registry number
Input: SMILES structure string
Output: Corresponding CAS registry number
14. MoleculeSmilesCheck - SMILES Validation
Functionality: Validates the syntactic correctness of a SMILES string
Input: SMILES structure stringOutput: Validation Result (Valid/Invalid)
15. ReactionSmilesCheck - Reaction SMILES Validation
Function: Validates the syntactic correctness of a reaction SMILES string.
Input: Reaction SMILES string
Output: Validation result (Valid/Invalid)
16. MoleculeVisualizer - Molecule Visualization
Function: Generates a 2D structure diagram of a molecule.
Input: SMILES molecular structure string
Output: Molecular structure image
17. MoleculeCaptioner - Molecule Description Generation
Function: Uses AI to generate a textual description of a molecule.
Input: SMILES molecular structure string
Output: Detailed textual description of the molecule
18. MoleculeGenerator - Molecule Generation
Function: Uses AI to generate a molecular structure based on a description.
Input: Textual description of the molecule
Output: Corresponding SMILES molecular structure
19. MoleculeModifier - Molecule Modification
Function: Performs chemical modifications and derivatizations on molecules.
Input: SMILES molecular structure string
Output: Options for modified molecular structures
📖 Usage Examples
bash
Start MCP server with specific tools
python -m chemmcp --tools WebSearch MoleculeWeight MoleculeAtomCount
Or use all tools
python -m chemmcp --tools WebSearch MoleculeWeight MoleculeAtomCount MoleculeSimilarity FunctionalGroups SmilesCanonicalization Iupac2Smiles Smiles2Iupac Smiles2Formula Name2Smiles Selfies2Smiles Smiles2Selfies Smiles2Cas MoleculeSmilesCheck ReactionSmilesCheck MoleculeVisualizer MoleculeCaptioner MoleculeGenerator MoleculeModifier
🔧 MCP Configuration
Add the following configuration to your MCP client configuration file:
json
{
"mcpServers": {
"ChemMCP": {
"command": "/opt/miniconda3/envs/chemmcp/bin/python", // How to find the path: conda activate chemmcp && which python
"args": [
"-m", "chemmcp",
"--tools",
"WebSearch",
"MoleculeWeight",
"MoleculeAtomCount",
"MoleculeSimilarity",
"FunctionalGroups",
"SmilesCanonicalization",
"Iupac2Smiles",
"Smiles2Iupac",
"Smiles2Formula",
"Name2Smiles",
"Selfies2Smiles",
"Smiles2Selfies",
"Smiles2Cas",
"MoleculeSmilesCheck",
"ReactionSmilesCheck",
"MoleculeVisualizer",
"MoleculeCaptioner",
"MoleculeGenerator",
"MoleculeModifier"
],
"toolCallTimeoutMillis": 300000,
"env": {
"TAVILY_API_KEY": "your_tavily_api_key_here",
"LLM_MODEL_NAME": "openai/gpt-4o",
"OPENAI_API_KEY": "your_openai_api_key_here",
"CHEMSPACE_API_KEY": "your_chemspace_api_key_here", // Optional: Only used when additional database lookups are needed
"PATH": "/opt/miniconda3/envs/chemmcp/bin:/usr/local/bin:/usr/bin:/bin" // How to find the path: conda activate chemmcp && echo $PATH
}
}
}
}
Notes:
-
How to Find the Correct Python Path:
bashActivate your conda environment
conda activate chemmcp
View the Python path
which python
Copy the output path and replace the path in the above configuration
-
Replace API keys with your actual keys.
-
CHEMSPACE_API_KEY is optional: It is only used as a fallback database by the
Iupac2Smilestool if the PubChem lookup fails. -
Ensure that your Python environment version is 3.11 or higher.
🛠️ Dependencies
- RDKit: Core library for molecular processing and computation.
- PubChemPy: Interface to the PubChem database.
- SELFIES: SELF-referencing Embedded Strings for molecules.
- rdchiral: Chiral molecule processing.
- synspace: Molecule space exploration and modification.
- tavily-python: Web search API.
- litellm: Unified LLM API interface.
- requests: HTTP request library.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
Note: Some tools require corresponding API keys. Make sure to set the environment variables correctly before use.