PubChem Drug Information MCP Server
Extract drug information from the PubChem API using the MCP server to retrieve chemical, bioactivity, and safety data quickly and reliably.
npx -y @sssjiang/pubchem_mcp_serverOverview
The PubChem Drug Information MCP Server provides a lightweight HTTP service that wraps the PubChem REST APIs and exposes chemical, bioactivity, and safety information in a consistent, machine-friendly format compatible with Model Context Protocol (MCP) consumers. It acts as an intermediary between PubChem and applications (including LLM-based agents) that need quick, reliable access to structured drug-related data without having to orchestrate multiple PubChem endpoints.
This server is useful for developers building tools that need on-demand compound summaries, activity assays, toxicity flags, or downloadable property tables. By normalizing PubChem responses, caching common queries, and presenting results as predictable JSON objects, the MCP server simplifies integration into pipelines, interactive agents, and dashboards.
Features
- Unified MCP-compatible endpoints for compound data, bioassays, and safety summaries
- Query by CID, InChIKey, SMILES, or common name
- Aggregated chemical properties (formula, weight, synonyms, SMILES)
- Bioactivity and assay summaries (counts, top assays, IC50/EC50 examples)
- Safety information extraction (toxicity flags, LD50 where available)
- Optional caching and configurable TTL to reduce PubChem load
- Docker-ready and simple local run via Python
Installation / Configuration
Prerequisites: Python 3.9+ and Docker (optional).
Clone and install:
Environment configuration (.env example):
PORT=8080
LOG_LEVEL=info
CACHE_TTL=3600 # seconds
PUBCHEM_API_BASE=https://pubchem.ncbi.nlm.nih.gov/rest/pug
Run locally (example using Uvicorn):
Docker build and run:
Available Tools / Resources
The server exposes a small set of MCP-style endpoints that return JSON objects optimized for context injection into models or tools.
Endpoint summary:
| Method | Path | Query params | Purpose |
|---|---|---|---|
| GET | /mcp/compound | cid, inchikey, smiles, name | Compound summary — properties, synonyms, structure strings |
| GET | /mcp/bioassay | cid, inchikey | Bioactivity summary — assay counts, top activity values |
| GET | /mcp/safety | cid, inchikey | Safety/toxicity summary — LD50, toxicity flags, warnings |
| GET | /mcp/search | q | Simple search returning candidate CIDs for free-text queries |
| POST | /mcp/batch | cids:[] | Batch retrieval for multiple CIDs (aggregated) |
Example compound response (abridged):
Use Cases
LLM augmentation for scientific chatbots
- An agent can call /mcp/compound?cid=2244 to retrieve structured context for answering questions about aspirin (structure, synonyms, molecular weight) and then augment answers with assay or safety summaries from /mcp/bioassay and /mcp/safety.
Automated safety checks in pipelines
- Before adding a compound to a screening list, a pipeline POSTs a batch of CIDs to /mcp/batch and consumes safety warnings to filter or flag problematic entries.
Interactive dashboards and notebooks
- Use the search endpoint to map user-entered names to CIDs, then fetch properties and activity summaries for visualization in dashboards or Jupyter notebooks.
Concrete examples
- cURL: fetch compound summary for aspirin (CID 2244)
- Python: get bioassay summary and print top assay count
=
=
- Batch request (JSON POST)
Tips for Developers
- PubChem rate limits are modest; enable caching (CACHE_TTL) in production to reduce repeated lookups.
- Normalize identifiers early: use /mcp/search for free-text mapping to CIDs before downstream calls.
- Responses are designed to be small and model-friendly; fetch additional raw PubChem records only if you need full assay tables or documents.
Repository and issues: https://github.com/sssjiang/pubchem_mcp_server
This server is intended as a bridge between PubChem’s rich datasets and applications that require concise, structured drug context for automation, agents, and developer tools.