pubchem-mcp-server
Enables large language models to correctly query molecular databases and generate structure files
Documentation

PubChem MCP Server
A Model Context Protocol (MCP) server for retrieving chemical compound data from PubChem database.
Overview
PubChem MCP Server is a Python implementation of an MCP server that allows AI models to query chemical compound information from the PubChem database. It provides easy access to compound properties, 2D structures, and 3D molecular coordinates through a standard MCP interface.
Features
- Query compounds by name or PubChem CID
- Retrieve comprehensive compound data including:
- IUPAC name
- Molecular formula
- Molecular weight
- SMILES notation
- InChI and InChIKey
- Support for multiple output formats:
- JSON (default)
- CSV
- XYZ (3D structure)
- Built-in caching system to improve performance
- Automatic retry mechanism for API reliability
- Fallback 3D structure generation if PubChem 3D is unavailable
Requirements
- Python 3.8+
- Requests library
- RDKit (optional, for enhanced 3D structure handling)
Installation
From Source
# Clone the repository
git clone https://github.com/yourusername/pubchem-mcp-server.git
cd pubchem-mcp-server/python_version
# Install the package
pip install -e .
# For enhanced 3D structure handling, install with RDKit
pip install -e ".[rdkit]"MCP Configuration
To use the server with Claude or other MCP-capable AI models, add the following to your MCP configuration file:
{
"mcpServers": {
"pubchem": {
"command": "python3",
"args": ["/path/to/pubchem-mcp-server/python_version/mcp_server.py"],
"env": {
"PYTHONUNBUFFERED": "1"
},
"disabled": false,
"autoApprove": [
"get_pubchem_data",
"download_structure"
]
}
}
}Available Tools
get_pubchem_data
Retrieves chemical compound structure and property data.
Parameters:
- `query` (required): Compound name or PubChem CID
- `format` (optional): Output format - "JSON" (default), "CSV", or "XYZ"
- `include_3d` (optional): Whether to include 3D structure (only valid when format is "XYZ")
Example use:
pubchem
get_pubchem_data
{
"query": "aspirin",
"format": "JSON"
}download_structure
Downloads structure files for a compound.
Parameters:
- `cid` (required): PubChem CID
- `format` (optional): File format - "sdf" (default), "mol", or "smi"
- `filename` (optional): Custom filename for the downloaded structure
Example use:
pubchem
download_structure
{
"cid": "2244",
"format": "sdf"
}Project Structure
pubchem-mcp-server/
├── python_version/ # Python implementation
│ ├── mcp_server.py # Main MCP server script
│ ├── setup.py # Package installation script
│ ├── pubchem_mcp_server/ # Core package
│ │ ├── __init__.py
│ │ ├── pubchem_api.py # PubChem API interaction
│ │ ├── xyz_utils.py # 3D structure and XYZ format utilities
│ │ ├── server.py # MCP server implementation
│ │ ├── cli.py # Command-line interface
│ │ └── async_processor.py # Asynchronous request handling
└── LICENSECaching
The server uses a caching mechanism to improve performance:
- API responses are cached in memory
- 3D structure data is cached in `~/.pubchem-mcp/cache/`
License
This project is licensed under the MIT License - see the LICENSE file for details.
Frequently asked questions
What is pubchem-mcp-server?
pubchem-mcp-server is Enables large language models to correctly query molecular databases and generate structure files
How do I install pubchem-mcp-server?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is pubchem-mcp-server open source?
Yes — it is hosted on GitHub at https://github.com/PhelanShao/pubchem-mcp-server and has 3 stars.
Related MCP tools
Damn Vulnerable MCP Server Python-based implementation. Trusted by 1200+ developers. Trusted by 1200+ developers. Trusted by 1200+ developers.
A Model Context Protocol (MCP) server that enables secure interaction with MySQL databases Python-based implementation. Trusted by 900+ developers.
Query MCP enables end-to-end management of Supabase via chat interface: read & write query executions, management API support, automatic migration versioning...
Model Context Protocol with Neo4j Python-based implementation. Trusted by 700+ developers. Trusted by 700+ developers. Trusted by 700+ developers.
An MCP server that provides control over Android devices via adb Python-based implementation. Trusted by 500+ developers.
A Model Context Protocol (MCP) server for PostgreSQL databases with enhanced capabilities for AI agents. Python-based implementation.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP