Skip to main content
Glama

Version Framework MCP SDK License TypeScript Bun

公共托管服务器: https://pubchem.caseyjhand.com/mcp


工具

用于查询 PubChem 化学信息数据库的八个工具:

工具名称

描述

pubchem_search_compounds

通过名称、SMILES、InChIKey、分子式、子结构、超结构或 2D 相似度搜索化合物。

pubchem_get_compound_details

通过 CID 获取化合物的物理化学性质、描述、同义词、药物相似性和分类。

pubchem_get_compound_image

通过 CID 获取化合物的 2D 结构图 (PNG)。

pubchem_get_compound_safety

获取化合物的 GHS 危险分类和安全数据。

pubchem_get_compound_xrefs

获取外部数据库交叉引用(PubMed、专利、基因、蛋白质等)。

pubchem_get_bioactivity

获取化合物的生物活性概况:分析结果、靶点和活性值。

pubchem_search_assays

通过生物靶点(基因符号、蛋白质、基因 ID、UniProt 登录号)查找生物分析。

pubchem_get_summary

获取 PubChem 实体的摘要:分析、基因、蛋白质、分类学。

pubchem_search_compounds

通过五种搜索模式在 PubChem 中搜索化学化合物。

  • 标识符查找 — 将化合物名称、SMILES 或 InChIKey 解析为 CID(最多可批量处理 25 个)

  • 分子式搜索 — 通过 Hill 记法中的分子式查找化合物

  • 子结构/超结构 — 查找包含查询结构或被查询结构包含的化合物

  • 2D 相似度 — 通过 Tanimoto 相似度(阈值可配置)查找结构相似的化合物

  • 可选:使用属性填充结果,以避免后续的详细信息调用


pubchem_get_compound_details

通过 CID 获取详细的化合物信息。

  • 单次请求最多可批量处理 100 个 CID

  • 27 种可用属性:分子量、SMILES、InChIKey、XLogP、TPSA、复杂性、立体计数等

  • 可选:包含来自 PUG View 的文本描述(药理学、机制、治疗用途)

  • 可选:包含所有已知的同义词(商品名、系统名称、注册号)

  • 可选:根据获取的属性计算药物相似性评估(Lipinski 五规则 + Veber 规则)

  • 可选:获取药理学分类(FDA 分类、作用机制、MeSH 分类、ATC 代码)


pubchem_get_bioactivity

从 PubChem BioAssay 获取化合物的生物活性概况。

  • 返回分析结果(活性/非活性/不确定)、靶点信息(蛋白质登录号、NCBI 基因 ID)和定量值(IC50、EC50、Ki)

  • 按结果过滤以专注于活性结果

  • 每次请求上限为 100 个结果(研究充分的化合物可能有数千个)


pubchem_get_summary

获取四种 PubChem 实体类型的描述性摘要。

  • 分析 (AID)、基因 (Gene ID)、蛋白质 (UniProt 登录号)、分类学 (Tax ID)

  • 每次调用最多 10 个实体

  • 针对特定类型的字段提取,以获得清晰、结构化的输出

Related MCP server: PubChem MCP Server

特性

基于 @cyanheads/mcp-ts-core 构建:

  • 声明式工具定义 — 每个工具一个文件,框架处理注册和验证

  • 所有工具统一的错误处理

  • 可插拔的身份验证 (none, jwt, oauth)

  • 可替换的存储后端:in-memory, filesystem, Supabase, Cloudflare KV/R2/D1

  • 结构化日志记录,支持可选的 OpenTelemetry 追踪

  • 本地运行 (stdio/HTTP) 或通过 Docker 容器化运行

PubChem 特定功能:

  • 针对 PUG REST 和 PUG View API 的限速客户端(5 req/s,带自动排队)

  • 在 5xx 错误和网络故障时进行指数退避重试

  • 所有工具均为只读且幂等 — 无需 API 密钥

入门指南

公共托管实例

公共实例位于 https://pubchem.caseyjhand.com/mcp — 无需安装。通过可流式传输的 HTTP 将任何 MCP 客户端指向它:

{
  "mcpServers": {
    "pubchem": {
      "type": "streamable-http",
      "url": "https://pubchem.caseyjhand.com/mcp"
    }
  }
}

自托管 / 本地运行

添加到您的 MCP 客户端配置中(例如 claude_desktop_config.json):

{
  "mcpServers": {
    "pubchem": {
      "type": "stdio",
      "command": "bunx",
      "args": ["@cyanheads/pubchem-mcp-server@latest"],
      "env": {
        "MCP_TRANSPORT_TYPE": "stdio"
      }
    }
  }
}

先决条件

安装

  1. 克隆仓库:

git clone https://github.com/cyanheads/pubchem-mcp-server.git
  1. 进入目录:

cd pubchem-mcp-server
  1. 安装依赖:

bun install

配置

无需 API 密钥 — PubChem 的 API 可免费访问。

变量

描述

默认值

MCP_TRANSPORT_TYPE

传输方式:stdio 或 http。

stdio

MCP_HTTP_PORT

HTTP 服务器端口。

3010

MCP_HTTP_HOST

HTTP 服务器主机。

localhost

MCP_AUTH_MODE

认证模式:none, jwt 或 oauth。

none

MCP_LOG_LEVEL

日志级别 (RFC 5424)。

info

STORAGE_PROVIDER_TYPE

存储后端。

in-memory

OTEL_ENABLED

启用 OpenTelemetry。

false

运行服务器

本地开发

  • 构建并运行:

    bun run rebuild
    bun run start:stdio   # or start:http
  • 运行检查和测试:

    bun run devcheck     # Lints, formats, type-checks
    bun run test         # Runs test suite

Docker

docker build -t pubchem-mcp-server .
docker run -p 3010:3010 pubchem-mcp-server

项目结构

目录

用途

src/mcp-server/tools/definitions/

工具定义 (*.tool.ts)。

src/services/pubchem/

带有限速和响应解析功能的 PubChem API 客户端。

scripts/

构建、清理、开发检查和树生成脚本。

开发指南

请参阅 CLAUDE.md 获取开发准则和架构规则。简而言之:

  • 处理程序抛出异常,框架捕获 — 工具逻辑中不使用 try/catch

  • 使用 ctx.log 进行特定领域的日志记录

  • 在 index.ts 桶文件中注册新工具

贡献

欢迎提交问题和拉取请求。提交前请运行检查:

bun run devcheck
bun run test

许可证

Apache-2.0 — 详情请参阅 LICENSE。

Available Tools

10 tools
pubchem_get_bioactivityGet BioactivityA
Read-onlyIdempotent
Inspect

Get a compound's bioactivity profile: which assays tested it, activity outcomes (Active/Inactive/Inconclusive), target identifiers (NCBI Gene ID, UniProt/GenBank accession), quantitative values (IC50, EC50, Ki, etc.), each assay's type (confirmatory, screening, summary, other), and the PubMed IDs it cites. Filter by outcome, a specific molecular target (NCBI Gene ID or protein accession), assay type, and/or activity name (e.g. IC50) to focus the profile, and rank by potency within the named measurements — e.g. "is this compound active against target T in confirmatory assays?" or "what is its lowest IC50 against T?".

Inputs: cid (required), sort, offset, assayType, +5 more. Returns: cap, cid, sort, error, +16 more

pubchem_get_compound_3d_structureGet Compound 3D StructureA
Read-onlyIdempotent
Inspect

Get one 3D conformer of a compound — atomic coordinates and bonds — for one CID: its default conformer, or the one conformerId names. format="json" (default) returns atoms and bonds parsed into structured fields; format="sdf" returns the raw V2000 SDF text for passthrough to docking, rendering, or conformer tools. Optionally lists the compound's other conformer IDs, each one a value for conformerId. Not every compound has computed 3D coordinates (large molecules, mixtures, and some salts do not).

Inputs: cid (required), format, maxAtoms, maxBonds, +3 more. Returns: cid, sdf, atoms, bonds, +12 more

pubchem_get_compound_detailsGet Compound DetailsA
Read-onlyIdempotent
Inspect

Get detailed compound information by CID. Returns physicochemical properties (molecular weight, SMILES, InChIKey, XLogP, TPSA, etc.), optionally with a textual description (pharmacology, mechanism, therapeutic use), known synonyms, drug-likeness assessment (Lipinski/Veber rules), and/or pharmacological classification (FDA classes, MeSH classes, ATC codes). Fetches up to 100 CIDs per call; CIDs past that are returned in unprocessed for a follow-up call.

Inputs: cids (required), properties, maxSynonyms, synonymOffset, +6 more. Returns: error, notice, compounds, truncated, +8 more

pubchem_get_compound_imageGet Compound ImageA
Read-onlyIdempotent
Inspect

Fetch a 2D structure diagram (PNG image) for a compound by CID.

Inputs: cid (required), size. Returns: cid, error, width, height, +2 more

pubchem_get_compound_interactionsGet Compound InteractionsA
Read-onlyIdempotent
Inspect

Get a compound's interaction data: drug-food interactions, and the molecular targets its bioassays name — one entry per target as kinds defines it, with its assay counts by outcome and most potent active value, Active targets first, most potent first. Each entry carries its originating source. Results are paged per kind, with the record total and the next offset reported for each. Drug-food coverage is richest for approved drugs; target covers any compound PubChem has assay data for, and pubchem_get_bioactivity lists one target's assays when given the entry's GeneID or accession. Drug-drug interactions (DrugBank) are unavailable while PubChem's SDQ service refuses automated requests: an explicit drug-drug request is reported in failedKinds while the other kinds still return.

Inputs: cid (required), kinds, offset, maxEntries. Returns: cid, error, notice, offset, +8 more

pubchem_get_compound_safetyGet Compound SafetyA
Read-onlyIdempotent
Inspect

Get GHS (Globally Harmonized System) hazard classification and safety data for one or more compounds by CID. Returns signal word, pictograms, hazard statements (H-codes), and precautionary statements (P-codes) per compound, merged across sources, plus each source's own classification — its signal word, pictograms, H-codes with ECHA notifier agreement percentages, and notification counts — since sources often disagree. Reports ECHA "Not Classified" verdicts as their own status.

Inputs: cids (required). Returns: error, notice, results, unprocessed, +3 more

pubchem_get_compound_xrefsGet Compound Cross-ReferencesA
Read-onlyIdempotent
Inspect

Get external database cross-references for a compound: PubMed citations, patent IDs, gene associations, CAS and EC numbers with the number of source records that deposited each, other registry numbers, and taxonomy IDs. Results are paged per type — capped at maxPerType with the total count reported; reach the IDs past a page with offset. PubMed IDs come highest (most recently assigned) first and the other numeric types in ascending order; CAS and EC come most-attested first; the other string IDs keep PubChem's order. A type that fails to load is named in failedTypes while the others still return; the call fails only when a type fails and no type other than ProteinGI (which PubChem no longer serves) loads.

Inputs: cid (required), xrefTypes (required), offset, maxPerType. Returns: cid, error, xrefs, notice, +5 more

pubchem_get_summaryGet Entity SummaryA
Read-onlyIdempotent
Inspect

Get descriptive summaries for PubChem entities by ID. Supports assays (AID), genes (Gene ID), proteins (UniProt accession), and taxonomy (Tax ID). Up to 10 per call; identifiers past that are returned in unprocessed for a follow-up call.

Inputs: entityType (required), identifiers (required). Returns: error, notice, summaries, entityType, +4 more

pubchem_search_assaysSearch AssaysA
Read-onlyIdempotent
Inspect

Find PubChem bioassays associated with a biological target. Search by gene symbol (e.g. "EGFR"), protein name, NCBI Gene ID, or UniProt accession. Returns a page of assay IDs (AIDs) — page past maxResults with offset — which can be explored further with pubchem_get_summary.

Inputs: targetType (required), targetQuery (required), offset, maxResults. Returns: cap, aids, error, shown, +8 more

pubchem_search_compoundsSearch CompoundsA
Read-onlyIdempotent
Inspect

Search PubChem for chemical compounds by identifier (name, SMILES, InChI, or InChIKey, up to 25 per call), molecular formula in Hill notation, substructure or superstructure containment, 2D Tanimoto similarity, the compounds a bioassay (AID) found active or tested, or an accurate mass or molecular weight range. Returns a page of CIDs, each similarity hit with its Tanimoto score — reach matches past maxResults with offset. Optionally hydrate results with properties to avoid a follow-up pubchem_get_compound_details call.

Inputs: searchType (required), aid, query, offset, +12 more. Returns: cap, error, shown, notice, +11 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 10 tools

    Disambiguation4/5

    Each tool targets a distinct facet of PubChem data (search, details, 3D conformer, image, safety, xrefs, bioactivity, interactions, assay search, summaries), and the descriptions explicitly disambiguate the closest pairs: bioactivity is per-assay/per-target measurement data while interactions is per-target aggregation plus drug-food data. The main soft overlaps are pubchem_search_assays vs. pubchem_get_summary (AID) and the optional property hydration in pubchem_search_compounds vs. pubchem_get_compound_details, but these are explained clearly enough to guide selection.

    Naming Consistency4/5

    All tools share a pubchem_ prefix and use verb_noun form (search_/get_), which is highly predictable. There are minor deviations: most follow get_compound_X but pubchem_get_bioactivity drops the compound_ segment, and pubchem_get_summary names no resource at all, so the resource is not always inferable from the name alone.

    Tool Count5/5

    Ten tools is squarely in the well-scoped range for a chemical database server, and each one covers a distinct data type (search, properties, 3D, image, safety, xrefs, bioactivity, interactions, assays, summaries) without redundant entries.

    Completeness5/5

    The surface covers the full compound lifecycle: discovery (search by name/SMILES/formula/similarity/substructure), enrichment (properties, synonyms, drug-likeness, classification), structure (2D image, 3D conformer), safety, cross-references, bioactivity, target interactions, and assay lookup. No obvious dead ends for the stated PubChem domain; the only gap is a dedicated assay-detail tool, which pubchem_get_summary partially fills.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables comprehensive access to PubChem's chemical database with over 110 million compounds. Supports chemical searches, structure analysis, bioactivity data, safety information, and molecular property calculations through 30 specialized tools.
      30
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search and retrieve chemical compound information, structures, and physical properties from the PubChem database. It supports querying via compound names, SMILES notation, or CIDs to provide detailed molecular data for chemical analysis.
      5
      -
    • F
      license
      B
      quality
      D
      maintenance
      Extracts basic chemical information and drug data from the PubChem API. It enables users to retrieve molecular details such as SMILES, IUPAC names, molecular formulas, and synonyms for specific compounds.
      3
      11
      -