PubChem MCP Server

PubChem MCP Server

๐Ÿงช Enable AI assistants to search and access chemical compound information through a simple MCP interface.

JackKuo666

Research & Data
Visit Server

README

PubChem MCP Server

smithery badge

๐Ÿงช Enable AI assistants to search and access chemical compound information through a simple MCP interface.

The PubChem MCP Server provides a bridge between AI assistants and PubChem's chemical database through the Model Context Protocol (MCP). It allows AI models to search for chemical compounds and access their detailed information in a programmatic way.

๐Ÿค Contribute โ€ข ๐Ÿ“ Report Bug

โœจ Core Features

  • ๐Ÿ”Ž Compound Search: Query PubChem compounds by name, SMILES, or CID โœ…
  • ๐Ÿงช Chemical Structure: Access molecular structures and identifiers โœ…
  • ๐Ÿ“Š Property Data: Retrieve detailed chemical and physical properties โœ…
  • ๐Ÿ”ฌ Advanced Search: Combine multiple parameters for precise queries โœ…
  • ๐Ÿงฌ Molecular Visualization: Generate and display molecular structures ๐Ÿ“
  • ๐Ÿ“ˆ Property Analysis: Compare properties across multiple compounds ๐Ÿ“
  • ๐Ÿ—ƒ๏ธ Local Storage: Save frequently used compounds for faster access ๐Ÿ“
  • ๐Ÿ“ Chemistry Prompts: Specialized prompts for chemical analysis ๐Ÿ“

๐Ÿš€ Quick Start

Installing via Smithery

To install PubChem Server for Claude Desktop automatically via Smithery:

Claude

npx -y @smithery/cli@latest install @JackKuo666/pubchem-mcp-server --client claude --config "{}"

Cursor

Paste the following into Settings โ†’ Cursor Settings โ†’ MCP โ†’ Add new server:

  • Mac/Linux
npx -y @smithery/cli@latest run @JackKuo666/pubchem-mcp-server --client cursor --config "{}" 

Windsurf

npx -y @smithery/cli@latest install @JackKuo666/pubchem-mcp-server --client windsurf --config "{}"

CLine

npx -y @smithery/cli@latest install @JackKuo666/pubchem-mcp-server --client cline --config "{}"

Installing Manually

Install using uv:

uv tool install pubchem-mcp-server

For development:

# Clone and set up development environment
git clone https://github.com/JackKuo666/PubChem-MCP-Server.git
cd PubChem-MCP-Server

# Create and activate virtual environment
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt

๐Ÿ“Š Usage

Start the MCP server:

python pubchem_server.py

Once the server is running, you can use the provided MCP tools in your AI assistant or application. Here are some examples of how to use the tools:

Example 1: Search for compounds by name

result = await mcp.use_tool("search_pubchem_by_name", {
    "name": "aspirin",
    "max_results": 3
})
print(result)

Example 2: Search for compounds by SMILES notation

result = await mcp.use_tool("search_pubchem_by_smiles", {
    "smiles": "CC(=O)OC1=CC=CC=C1C(=O)O",  # Aspirin's SMILES
    "max_results": 2
})
print(result)

Example 3: Get detailed information for a specific compound

result = await mcp.use_tool("get_pubchem_compound_by_cid", {
    "cid": 2244  # Aspirin's CID
})
print(result)

Example 4: Perform an advanced search with multiple parameters

result = await mcp.use_tool("search_pubchem_advanced", {
    "name": "caffeine",
    "formula": "C8H10N4O2",
    "max_results": 2
})
print(result)

These examples demonstrate how to use the four main tools provided by the PubChem MCP Server. Adjust the parameters as needed for your specific use case.

๐Ÿ›  MCP Tools

The PubChem MCP Server provides the following tools:

search_pubchem_by_name

Search for chemical compounds on PubChem using a compound name.

Parameters:

  • name (str): Name of the chemical compound
  • max_results (int, optional): Maximum number of results to return (default: 5)

Returns: List of dictionaries containing compound information

search_pubchem_by_smiles

Search for chemical compounds on PubChem using a SMILES string.

Parameters:

  • smiles (str): SMILES notation of the chemical compound
  • max_results (int, optional): Maximum number of results to return (default: 5)

Returns: List of dictionaries containing compound information

get_pubchem_compound_by_cid

Fetch detailed information about a chemical compound using its PubChem CID.

Parameters:

  • cid (int): PubChem Compound ID (CID)

Returns: Dictionary containing compound information

search_pubchem_advanced

Perform an advanced search for compounds on PubChem.

Parameters:

  • name (str, optional): Name of the chemical compound
  • smiles (str, optional): SMILES notation of the chemical compound
  • formula (str, optional): Molecular formula
  • cid (int, optional): PubChem Compound ID
  • max_results (int, optional): Maximum number of results to return (default: 5)

Returns: List of dictionaries containing compound information

Usage with Claude Desktop

Add this configuration to your claude_desktop_config.json:

(Mac OS)

{
  "mcpServers": {
    "pubchem": {
      "command": "python",
      "args": ["-m", "pubchem-mcp-server"]
      }
  }
}

(Windows version):

{
  "mcpServers": {
    "pubchem": {
      "command": "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\Python\\Python311\\python.exe",
      "args": [
        "-m",
        "pubchem-mcp-server"
      ]
    }
  }
}

Using with Cline

{
  "mcpServers": {
    "pubchem": {
      "command": "bash",
      "args": [
        "-c",
        "source /home/YOUR/PATH/mcp-hub/PubChem-MCP-Server/.venv/bin/activate && python /home/YOUR/PATH/mcp-hub/PubChem-MCP-Server/pubchem_server.py"
      ],
      "env": {},
      "disabled": false,
      "autoApprove": []
    }
  }
}

After restarting Claude Desktop, the following capabilities will be available:

Searching Compounds

You can ask Claude to search for chemical compounds using queries like:

Can you search PubChem for information about aspirin?

The search will return basic information about matching compounds including:

โ€ข Compound name

โ€ข CID (PubChem Compound ID)

โ€ข Molecular formula

โ€ข Molecular weight

Getting Compound Details

Once you have a CID, you can ask for more details:

Can you show me the details for compound with CID 2244?

This will return:

โ€ข IUPAC name

โ€ข Molecular formula

โ€ข Molecular weight

โ€ข SMILES notation

โ€ข InChI and InChIKey

โ€ข Physical and chemical properties

โ€ข Synonyms

๐Ÿ“ TODO

visualize_compound

Generate and display a 2D or 3D visualization of a chemical compound.

compare_compounds

Compare properties and structures of multiple compounds.

save_compound

Save a compound locally for faster access.

list_saved_compounds

List all saved compounds.

๐Ÿ“ Chemistry Prompts

The server will offer specialized prompts to help analyze chemical compounds:

Compound Analysis Prompt

A comprehensive workflow for analyzing chemical compounds that only requires a compound ID:

result = await call_prompt("deep-compound-analysis", {
    "compound_id": "2244"
})

This prompt will include:

  • Detailed instructions for using available tools
  • A systematic workflow for compound analysis
  • Comprehensive analysis structure covering:
    • Chemical structure and properties
    • Pharmacological properties
    • Biological activities
    • Applications and uses
    • Safety and toxicity information
    • Related compounds

๐Ÿ“ Project Structure

  • pubchem_server.py: The main MCP server implementation using FastMCP
  • pubchem_search.py: Contains example code for searching PubChem

๐Ÿ”ง Dependencies

  • Python 3.10+
  • FastMCP
  • asyncio
  • logging
  • pubchempy (for PubChem API access)
  • pandas (for data handling)

You can install the required dependencies using:

pip install mcp pubchempy pandas

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

This project is licensed under the MIT License.

โš ๏ธ Disclaimer

This tool is for research purposes only. Please respect PubChem's terms of service and use this tool responsibly.

Recommended Servers

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
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
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
Mathematica Documentation MCP server

Mathematica Documentation MCP server

A server that provides access to Mathematica documentation through FastMCP, enabling users to retrieve function documentation and list package symbols from Wolfram Mathematica.

Local
Python
kb-mcp-server

kb-mcp-server

An MCP server aimed to be portable, local, easy and convenient to support semantic/graph based retrieval of txtai "all in one" embeddings database. Any txtai embeddings db in tar.gz form can be loaded

Local
Python
Research MCP Server

Research MCP Server

The server functions as an MCP server to interact with Notion for retrieving and creating survey data, integrating with the Claude Desktop Client for conducting and reviewing surveys.

Local
Python