PubChem MCP Server

PubChem MCP Server

Enables large language models to correctly query molecular databases and generate structure files

PhelanShao

Research & Data
Visit Server

README

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:

<use_mcp_tool>
<server_name>pubchem</server_name>
<tool_name>get_pubchem_data</tool_name>
<arguments>
{
  "query": "aspirin",
  "format": "JSON"
}
</arguments>
</use_mcp_tool>

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:

<use_mcp_tool>
<server_name>pubchem</server_name>
<tool_name>download_structure</tool_name>
<arguments>
{
  "cid": "2244",
  "format": "sdf"
}
</arguments>
</use_mcp_tool>

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
└── LICENSE

Caching

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.

Recommended Servers

mixpanel

mixpanel

Connect to your Mixpanel data. Query events, retention, and funnel data from Mixpanel analytics.

Featured
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python
Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.

Featured
TypeScript
MCP PubMed Search

MCP PubMed Search

Server to search PubMed (PubMed is a free, online database that allows users to search for biomedical and life sciences literature). I have created on a day MCP came out but was on vacation, I saw someone post similar server in your DB, but figured to post mine.

Featured
Python
dbt Semantic Layer MCP Server

dbt Semantic Layer MCP Server

A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.

Featured
TypeScript
Nefino MCP Server

Nefino MCP Server

Provides large language models with access to news and information about renewable energy projects in Germany, allowing filtering by location, topic (solar, wind, hydrogen), and date range.

Official
Python
Vectorize

Vectorize

Vectorize MCP server for advanced retrieval, Private Deep Research, Anything-to-Markdown file extraction and text chunking.

Official
JavaScript
Mentor MCP Server

Mentor MCP Server

Provides LLM Agents with AI-powered mentorship for code review, design critique, writing feedback, and brainstorming using the Deepseek API, enabling enhanced output in various development and strategic planning tasks.

Local
TypeScript
Excel Reader Server

Excel Reader Server

A Model Context Protocol (MCP) server that provides tools for reading Excel (xlsx) files, enabling extraction of data from entire workbooks or specific sheets with results returned in structured JSON format.

Local
Python
MATLAB MCP Server

MATLAB MCP Server

Integrates MATLAB with AI to execute code, generate scripts from natural language, and access MATLAB documentation seamlessly.

Local
JavaScript