Search PubChem compounds, properties, safety data, bioactivity, and cross-references.
One address for any MCP client. No sign-in needed on this server.
10 read
Grouped by tool name. At most: only reads or looks up information.
Odel charges nothing per call. The publisher may charge for its own service.
Search the PubChem chemical database for compounds, properties, safety data, bioactivity, cross-references, and entity summaries via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://pubchem.caseyjhand.com/mcp
Chemical compounds and bioassays from PubChem. Search compounds by name, formula, or structure; fetch properties, safety data, bioactivity, drug-food interactions, molecular targets, and 3D structures; and find bioassays by biological target.
| Tool | Description |
|---|---|
pubchem_search_compounds | Search for compounds by name, SMILES, InChI, InChIKey, formula, substructure, superstructure, or 2D similarity, or list the compounds a bioassay found active. |
pubchem_get_compound_details | Get physicochemical properties, descriptions, synonyms, drug-likeness, and classification for compounds by CID. |
pubchem_get_compound_image | Fetch a 2D structure diagram (PNG) for a compound by CID. |
pubchem_get_compound_3d_structure | Fetch a 3D conformer (atomic coordinates and bonds) for a compound by CID, as parsed JSON or raw SDF. |
pubchem_get_compound_xrefs | Get external database cross-references (PubMed, patents, genes, CAS and EC numbers, etc.). |
pubchem_get_compound_safety | Get GHS hazard classification and safety data for one or more compounds by CID (batch). |
pubchem_get_bioactivity | Get a compound's bioactivity profile: assay results, targets, activity values, assay types, and cited PubMed IDs; filter by outcome, molecular target, or assay type. |
pubchem_get_compound_interactions | Get a compound's drug-food interactions and the molecular targets its assays name, each with assay counts and the most potent active value. |
pubchem_search_assays | Find bioassays by biological target (gene symbol, protein, Gene ID, UniProt accession). |
pubchem_get_summary | Get summaries for PubChem entities: assays, genes, proteins, taxonomy. |
Compound and assay records are also exposed as URI-templated resources, backed by the same client methods as the tools; many MCP clients are tool-only and never surface resources.
| Resource | Description |
|---|---|
pubchem://compound/{cid} | Core physicochemical properties (JSON). |
pubchem://compound/{cid}/safety | GHS hazard classification (JSON). |
pubchem://compound/{cid}/image | 2D structure diagram (PNG). |
pubchem://compound/{cid}/xrefs | External cross-references (JSON). |
pubchem://compound/{cid}/bioactivity | Bioassay activity profile (JSON). |
pubchem://assay/{aid} | BioAssay summary (JSON). |
pubchem_search_compounds toolidentifierType + identifiers; name/SMILES/InChI/InChIKey, 25 per call, the rest returned in unprocessed), formula (formula, Hill notation, optional allowOtherElements), substructure/superstructure and 2D similarity (query + queryType; similarity threshold 70-100, default 90), or assay (aid; compounds the bioassay marked active, or every compound tested with activeOnly: false)maxResults is served at 200 and reported in cappedInputs); offset pages identifier and assay searches to the end of their matches, and formula, substructure, superstructure, and similarity searches to 10,000 (deeper fails with offset_ceiling_exceeded). Optional properties saves a follow-up pubchem_get_compound_details calltotalFound, or a totalFoundAtLeast floor when an upstream search saturated, and unresolvedIdentifiers for inputs with no CID. Fails with aid_not_found for an unknown AID and search_query_rejected (with a hint) for a query PubChem cannot searchpubchem_get_compound_details toolunprocessed); 27 available properties, defaulting to a core set of 14descriptionOffset/maxDescriptions, default 3, max 20) and classification (FDA, MeSH, ATC) cover the first 10 CIDs only, the rest listed in skippedCids. Optional synonyms (synonymOffset/maxSynonyms, default 20, max 100) and a Lipinski/Veber drug-likeness check cover every found CIDfound: false separates a nonexistent CID from a compound with no datapubchem_get_compound_image toolsize is "small" (100x100) or "large" (300x300, default)cid_not_found error when PubChem has no record for the CIDpubchem_get_compound_3d_structure toolformat="json" (default) returns parsed atoms (element + x/y/z) and bonds, format="sdf" returns the raw V2000 SDF textmaxAtoms/maxBonds cap the JSON preview (default 200 each); atomCount/bondCount always report the full totals, with any capping disclosed via enrichmentincludeRawSdf bypasses the default 500-line cap on the raw SDF textincludeAlternateConformerIds lists conformer IDs beyond the defaultno_3d_structure error when PubChem has no computed 3D coordinates (large molecules, mixtures, some salts)pubchem_get_compound_xrefs toolxrefTypes: CAS, EC, RN, RegistryID, PatentID, PubMedID, GeneID, ProteinGI, TaxonomyIDCAS and EC are the numbers deposited for the compound, every distinct value ordered by how many source records deposited it, with those counts in sourceCounts. RN is PubChem's unranked registry-number list: the CAS number sits beside deprecated and related CAS RNs and EC numbersProteinGI currently returns no data from PubChem; use GeneID for gene/protein associationsmaxPerType up to 500 (default 50), with one offset applied to every type; each type reports totalAvailable and truncated. PubMedID comes newest firstfailedTypes and the others still return; the call fails only when a type fails and no type other than ProteinGI (which PubChem no longer serves) loads. An empty result says whether the compound has none of the requested types or the CID may be mistypedpubchem_get_compound_safety toolunprocessed)classifications[] with each source's own label; precautionary statements carry a decoded flagstatus: ok, not_classified (notifiers found no GHS hazard), no_ghs_data (no deposited classification), or cid_not_found, so a bad CID never reads as "no hazards on file"pubchem_get_bioactivity tooloutcomeFilter (active/inactive/all, default all), targetGeneId/targetAccession, and assayType (any of confirmatory/screening/summary/other); an assay must pass every filter setassayType and the PubMed IDs it cites (pmids, newest first)offset reaches the rest. A multi-target assay reports the matched target and lists the others under otherTargetstotalAssays/activeCount/inactiveCount for the whole compound and filteredCount/returnedCount for the page; notices say whether there is no data, the filter excluded everything, or offset is past the endpubchem_get_compound_interactions toolkinds — drug-food (PUG View), target, drug-drug (DrugBank); default ["drug-food"], and an empty drug-food page points at targettarget gives one entry per target the compound's assay summary names: a Gene ID with the accessions the table pairs with it, or an identifier it never pairs. A Gene ID and an accession that no row pairs are separate entries even when they name the same protein (erlotinib's ERBB2 appears as accession:P04626 and as GeneID:2064). Each entry names the target from a batched gene or protein summary lookup, plus the GeneID: or accession: value pubchem_get_bioactivity filters on, and states the assay counts by outcome and the most potent Active value with its AID. Active targets come first, most potent first. If a name lookup fails or does not answer within a few seconds, the entries keep their identifier and the notice says somaxEntries per kind per page (max 50, default 10); offset counts records (targets, for target), up to 2,147,483,646. Each kind pages independently, reported in paging[] (totalRecords/nextOffset/truncated)failedKinds and the others still return. drug-drug comes from PubChem's SDQ service, which refuses automated requests, so it lands in failedKinds and a retry will not helppubchem_search_assays tooltargetType: genesymbol/proteinname (text), geneid (NCBI Gene ID), proteinaccession (UniProt)offset pages through the resultstargetQuery and a non-numeric geneidtotalFound and distinguishes "no match" from "offset past the end"pubchem_get_summary toolentityType: assay (AID), gene (NCBI Gene ID), protein (UniProt accession), or taxonomy (Tax ID); up to 10 identifiers per callunprocessed, and more than 1000 fails as too_many_identifiersinvalid: true row, and the call fails as invalid_identifier only when none is usablefound flag; fields depend on entityType (taxonomy: ordered lineage; gene: symbol/taxonomy; assay: method, the first 25 targets with targetCount, tested/active compound counts, lastDataChange)pubchem://compound/{cid} resourcepubchem_get_compound_details), as application/jsonpubchem_get_compound_details to select specific properties or add descriptions, synonyms, drug-likeness, and classificationpubchem://compound/{cid}/safety resourceapplication/json, including the per-source ghs.classifications and the contributor source liststatus (ok/not_classified/no_ghs_data/cid_not_found) is the only signal distinguishing a bad CID from a compound with no deposited classification — a resource read has no notice surfacepubchem://compound/{cid}/image resourcepubchem_get_compound_image for the 100x100 size optionpubchem://compound/{cid}/xrefs resourceRN, RegistryID, PubMedID, CAS (with sourceCounts) — up to 25 IDs per type, as application/json; the PubMed IDs are the 25 highest (most recently assigned), highest first. A type that fails to load is named in failedTypespubchem_get_compound_xrefs for the full set of xref types, a higher per-type cap, and offset pagingpubchem://compound/{cid}/bioactivity resourceapplication/json, each with its assayType and pmids, plus totalAssays/activeCount for the whole compound; a multi-target assay lists its further targets under otherTargetspubchem_get_bioactivity to filter by outcome, target, or assay type, raise the cap, or page with offsetpubchem://assay/{aid} resourceapplication/json — name, description, source, protocol, substance countsBuilt on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
PubChem-specific:
Timeout, and a cancelled call fails with RequestCancelledAgent-friendly output:
status and found flags let callers branch on data instead of matching error stringsunresolvedIdentifiers, skippedCids, failedKinds, and failedTypes rather than failing the whole calltruncated, shown/cap, and nextOffset; oversized batches are served up to the cap, with cappedInputs and unprocessed reporting the restreason (e.g. cid_not_found, missing_identifier_args, invalid_cid_query) with recovery textA public instance is available at https://pubchem.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"pubchem-mcp-server": {
"type": "streamable-http",
"url": "https://pubchem.caseyjhand.com/mcp"
}
}
}
Add the following to your MCP client configuration file.
{
"mcpServers": {
"pubchem-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/pubchem-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio"
}
}
}
}
Or with npx (no Bun required):
{
"mcpServers": {
"pubchem-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/pubchem-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio"
}
}
}
}
Or with Docker:
{
"mcpServers": {
"pubchem-mcp-server": {
"type": "stdio",
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/pubchem-mcp-server:latest"]
}
}
}
For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcp
git clone https://github.com/cyanheads/pubchem-mcp-server.git
cd pubchem-mcp-server
bun install
cp .env.example .env
# edit .env to override transport, session mode, storage, or logging defaults
| Variable | Description | Default |
|---|---|---|
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | Port for HTTP server. | 3010 |
MCP_HTTP_HOST | Host for HTTP server. | 127.0.0.1 |
MCP_SESSION_MODE | stateless, stateful, or auto. | stateless |
MCP_AUTH_MODE | Auth mode: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (RFC 5424). | info |
STORAGE_PROVIDER_TYPE | Storage backend. | in-memory |
OTEL_ENABLED | Enable OpenTelemetry. | false |
See .env.example for the full list of optional overrides.
Build and run:
# One-time build
bun run rebuild
# Run the built server
bun run start:stdio
# or
bun run start:http
Run checks and tests:
bun run devcheck # Lint, format, typecheck, security
bun run test # Vitest test suite
bun run lint:mcp # Validate MCP definitions against spec
docker build -t pubchem-mcp-server .
docker run --rm -p 3010:3010 pubchem-mcp-server
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/pubchem-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point — registers tools/resources and inits the PubChem client. |
src/mcp-server/tools/definitions/ | Tool definitions (*.tool.ts). |
src/mcp-server/resources/definitions/ | Resource definitions (*.resource.ts). |
src/services/pubchem/ | PubChem API client — rate limiting, retry, and response/SDF parsing. |
scripts/ | Build, clean, devcheck, and tree generation scripts. |
tests/ | Unit and integration tests. |
See CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for request-scoped loggingindex.ts barrel filesIssues are welcome. Run checks before submitting:
bun run devcheck
bun run test
Apache-2.0 — see LICENSE for details.