Get the FREE Ultimate OpenClaw Setup Guide →

pubchem

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

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio phelanshao-pubchem-mcp-server python3 /path/to/pubchem-mcp-server/python_version/mcp_server.py \
  --env PYTHONUNBUFFERED="1"

How to use

This PubChem MCP Server provides a Python-based implementation that exposes PubChem chemical data through the MCP interface. It supports querying compounds by name or PubChem CID and returns rich data including IUPAC name, molecular formula, molecular weight, SMILES, InChI and InChIKey, with optional 3D structure data. Two primary tools are available: get_pubchem_data for retrieving compound properties and optionally a 3D structure, and download_structure for downloading structural files in formats like sdf, mol, or smi. You can configure the server in your MCP setup and invoke these tools through the standard MCP workflow. The server also includes a built-in cache to speed up repeated queries and an automatic retry mechanism to improve API reliability. If PubChem 3D data is unavailable, the server can generate a fallback 3D structure for compatibility.

How to install

Prerequisites:

  • Python 3.8+
  • pip (Python package manager)
  • Optional: RDKit for enhanced 3D structure handling

From Source Installation:

  1. Clone the repository: git clone https://github.com/yourusername/pubchem-mcp-server.git
  2. Change into the Python version directory: cd pubchem-mcp-server/python_version
  3. Install the package in editable mode: pip install -e .
  4. Optional: install RDKit-enabled extras for enhanced 3D support: pip install -e ".[rdkit]"

Notes:

  • Ensure your environment has network access to reach PubChem API endpoints.
  • If you plan to run multiple MCP servers, consider isolating environments (virtualenv/conda).
  • Verify PYTHONUNBUFFERED is set when running for real-time logs.

Additional notes

Tips and common issues:

  • If you encounter API rate limits, rely on the server's built-in caching to reduce repeated calls.
  • Ensure the environment variable PYTHONUNBUFFERED is set to 1 for clean log streaming when used with MCP orchestrators.
  • The server stores 3D structure caches under ~/.pubchem-mcp/cache/; ensure the home directory is writable by the running process.
  • RDKit is optional but recommended for accurate and robust 3D structure handling; install via the extra [rdkit] when available.
  • If you change the server path or configuration, update your MCP configuration accordingly to reflect the correct Python script location and arguments.

Related MCP Servers

Sponsor this space

Reach thousands of developers