Skip to main content
Glama
README.md
# PubChem MCP

[中文说明](README.zh-CN.md)

A small stdio MCP server for querying PubChem compound properties and structure images.

## Tools

- `query_pubchem`: returns formula, molecular weight, charge, SMILES, IUPAC name, atoms, bonds, and hydrogen-bond counts.
- `img`: returns PubChem structure-image URLs and MCP image objects.

## Setup

Requires Python 3.10+.

```text
python -m venv .venv
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
# macOS/Linux
source .venv/bin/activate

pip install -r requirements.txt
```

Add the server to an MCP client (replace both paths with absolute paths):

```json
{
  "mcpServers": {
    "pubchem": {
      "command": "C:\\path\\to\\pubchem-mcp\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\pubchem-mcp\\pcp_mcp.py"]
    }
  }
}
```

You can also start it directly with `python pcp_mcp.py`.

## Usage

- Properties: call `query_pubchem` with `{"compound_name": "aspirin"}`.
- Structure image: call `img` with `{"compound_name": "aspirin"}`.

## Notes

- Pass compound names in English; translate them before calling the tools if needed.
- Internet access to PubChem is required. A name may match multiple compounds.
- Image display depends on the MCP client; `img` also returns browser-ready URLs.
- PubChem data should be independently verified before safety-critical, medical, or regulatory use.