Skip to main content
Glama

Search Compounds

pubchem_search_compounds
Read-onlyIdempotent

Find PubChem compound CIDs by name, SMILES, InChIKey, formula, substructure, superstructure, or similarity, optionally including properties to avoid a separate details request.

Instructions

Search PubChem for chemical compounds by identifier (name, SMILES, or InChIKey, batched up to 25), molecular formula in Hill notation, substructure or superstructure containment, or 2D Tanimoto similarity. Returns a page of CIDs — reach matches past maxResults with offset. Optionally hydrate results with properties to avoid a follow-up pubchem_get_compound_details call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoRequired for substructure/superstructure/similarity searches. A SMILES string (e.g. "CC(=O)O") or PubChem CID as a string (e.g. "2244").
offsetNoZero-based index of the first CID to return. Pass the nextOffset from a previous call to read the following page. Identifier lookups resolve every match up front, so paging them is free; formula, substructure, superstructure, and similarity searches have to ask PubChem for offset + maxResults records to reach a page, so deep pages cost progressively more upstream — hence the 10000 ceiling. Default: 0.
formulaNoRequired for formula search. Molecular formula in Hill notation (e.g. "C6H12O6", "CaH2O2").
queryTypeNoRequired for structure/similarity searches. Format of the query: "smiles" or "cid".
thresholdNoSimilarity search only. Minimum Tanimoto similarity (70-100). 90+ for close analogs, 70-80 for scaffold hops. Default: 90.
maxResultsNoMaximum CIDs to return per page (1-200). Use offset to reach matches past this page. Default: 20.
propertiesNoOptional: fetch these properties for each result, avoiding a follow-up details call. E.g. ["MolecularFormula", "MolecularWeight", "CanonicalSMILES"].
searchTypeYesSearch strategy. "identifier": name/SMILES/InChIKey lookup. "formula": molecular formula. "substructure": find compounds containing the query as a substructure. "superstructure": find compounds that are themselves substructures of the query. "similarity": 2D Tanimoto similarity to the query.
identifiersNoRequired for identifier search. Array of identifiers to resolve (1-25). Examples: ["aspirin", "ibuprofen"] for name, ["CC(=O)OC1=CC=CC=C1C(=O)O"] for SMILES, ["BSYNRYMUTXBXSQ-UHFFFAOYSA-N"] for inchikey (27-char block format).
identifierTypeNoRequired for identifier search. Type of chemical identifier: "name", "smiles", or "inchikey".
allowOtherElementsNoFormula search only. When true, includes compounds with additional elements beyond the formula.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
capNoThe maxResults cap that was applied.
errorNoPresent when the call failed. Absent on success.
shownNoCIDs returned on this page.
noticeNoRecovery guidance when no compounds matched, when the offset runs past the matches observed, when identifiers failed to resolve, or when further pages remain. Absent when this page is complete and every identifier resolved.
offsetNoZero-based index of the first CID returned.
resultsNoMatching compounds.
truncatedNoTrue when matching CIDs remain past this page.
nextOffsetNoOffset to pass on the next call to continue past this page. Omitted when no further matches remain.
searchTypeNoSearch strategy used: identifier, formula, substructure, superstructure, or similarity.
totalFoundNoExact number of matching CIDs across all pages. Omitted when a formula, substructure, superstructure, or similarity search saturated the records it requested — PubChem returns no match count for those, so totalFoundAtLeast reports a floor instead.
totalFoundAtLeastNoLower bound on matching CIDs, reported in place of totalFound when the exact count is unavailable. At least this many match, and the true total may be higher; page further with offset to observe more.
unresolvedIdentifiersNoIdentifier-mode only: input identifiers that resolved to no CID. Omitted when every identifier resolved and for non-identifier searches.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed6 schema fields changedv0.6.1
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / additionalProperties
      Added value: +false
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedOutput schema / anyOf
      Added value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "results",
      +      "searchType",
      +      "offset"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / error
      Added value: +{
      +  "additionalProperties": {},
      +  "description": "Present when the call failed. Absent on success.",
      +  "properties": {
      +    "code": {
      +      "description": "JSON-RPC error code for this failure.",
      +      "maximum": 9007199254740991,
      +      "minimum": -9007199254740991,
      +      "type": "integer"
      +    },
      +    "data": {
      +      "additionalProperties": {},
      +      "properties": {
      +        "reason": {
      +          "description": "Machine-readable failure mode. Declared by this tool: `missing_identifier_args`: searchType is \"identifier\" but identifierType or identifiers were omitted `missing_formula`: searchType is \"formula\" but the formula field was omitted `missing_structure_args`: substructure/superstructure/similarity search missing query or queryType `invalid_cid_query`: structure/similarity search with queryType \"cid\" but query is not a positive integer CID Other values are possible when a failure originates below the handler.",
      +          "examples": [
      +            "missing_identifier_args",
      +            "missing_formula",
      +            "missing_structure_args",
      +            "invalid_cid_query"
      +          ],
      +          "type": "string"
      +        },
      +        "recovery": {
      +          "additionalProperties": {},
      +          "description": "Actionable next step for the caller.",
      +          "properties": {
      +            "hint": {
      +              "type": "string"
      +            }
      +          },
      +          "required": [
      +            "hint"
      +          ],
      +          "type": "object"
      +        },
      +        "retryable": {
      +          "description": "Whether retrying may succeed.",
      +          "type": "boolean"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "message": {
      +      "description": "Human-readable description of what went wrong.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "code",
      +    "message"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / required
      Removed value: -[
      -  "results",
      -  "searchType",
      -  "offset"
      -]
  2. Changed11 schema fields changedv0.6.0
    • changedInput schema / properties / maxResults / description
      Previous value: -"Maximum CIDs to return (1-200). Default: 20."New value: +"Maximum CIDs to return per page (1-200). Use offset to reach matches past this page. Default: 20."
    • changedInput schema / properties / maxResults / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Zero-based index of the first CID to return. Pass the nextOffset from a previous call to read the following page. Identifier lookups resolve every match up front, so paging them is free; formula, substructure, superstructure, and similarity searches have to ask PubChem for offset + maxResults records to reach a page, so deep pages cost progressively more upstream — hence the 10000 ceiling. Default: 0.",
      +  "maximum": 10000,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / nextOffset
      Added value: +{
      +  "description": "Offset to pass on the next call to continue past this page. Omitted when no further matches remain.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / notice / description
      Previous value: -"Recovery guidance when no compounds matched — echoes search strategy and suggests how to broaden. Absent when results were returned."New value: +"Recovery guidance when no compounds matched, when the offset runs past the matches observed, when identifiers failed to resolve, or when further pages remain. Absent when this page is complete and every identifier resolved."
    • addedOutput schema / properties / offset
      Added value: +{
      +  "description": "Zero-based index of the first CID returned.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / shown / description
      Previous value: -"CIDs returned after the maxResults cap."New value: +"CIDs returned on this page."
    • changedOutput schema / properties / totalFound / description
      Previous value: -"Total CIDs found before the maxResults cap."New value: +"Exact number of matching CIDs across all pages. Omitted when a formula, substructure, superstructure, or similarity search saturated the records it requested — PubChem returns no match count for those, so totalFoundAtLeast reports a floor instead."
    • addedOutput schema / properties / totalFoundAtLeast
      Added value: +{
      +  "description": "Lower bound on matching CIDs, reported in place of totalFound when the exact count is unavailable. At least this many match, and the true total may be higher; page further with offset to observe more.",
      +  "type": "number"
      +}
    • changedOutput schema / properties / truncated / description
      Previous value: -"True when CIDs were capped at maxResults — more matches exist than returned."New value: +"True when matching CIDs remain past this page."
    • changedOutput schema / required
      Previous value: -[
      -  "results",
      -  "searchType",
      -  "totalFound"
      -]New value: +[
      +  "results",
      +  "searchType",
      +  "offset"
      +]
  3. Changed1 schema field changedv0.2.5
    • addedOutput schema / properties / unresolvedIdentifiers
      Added value: +{
      +  "description": "Identifier-mode only: input identifiers that resolved to no CID. Omitted when every identifier resolved and for non-identifier searches.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  4. Changed3 schema fields changedv0.2.4
    • addedOutput schema / properties / cap
      Added value: +{
      +  "description": "The maxResults cap that was applied.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / shown
      Added value: +{
      +  "description": "CIDs returned after the maxResults cap.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / truncated
      Added value: +{
      +  "description": "True when CIDs were capped at maxResults — more matches exist than returned.",
      +  "type": "boolean"
      +}
  5. Changed9 schema fields changedv0.1.22
    • changedInput schema / properties / identifiers / description
      Previous value: -"Required for identifier search. Array of identifiers to resolve (1-25). Examples: [\"aspirin\", \"ibuprofen\"] for name, [\"CC(=O)OC1=CC=CC=C1C(=O)O\"] for SMILES."New value: +"Required for identifier search. Array of identifiers to resolve (1-25). Examples: [\"aspirin\", \"ibuprofen\"] for name, [\"CC(=O)OC1=CC=CC=C1C(=O)O\"] for SMILES, [\"BSYNRYMUTXBXSQ-UHFFFAOYSA-N\"] for inchikey (27-char block format)."
    • changedInput schema / properties / query / description
      Previous value: -"Required for substructure/superstructure/similarity searches. A SMILES string or PubChem CID (as string) for the query structure."New value: +"Required for substructure/superstructure/similarity searches. A SMILES string (e.g. \"CC(=O)O\") or PubChem CID as a string (e.g. \"2244\")."
    • changedInput schema / properties / searchType / description
      Previous value: -"Search strategy: \"identifier\" (name/SMILES/InChIKey lookup), \"formula\", \"substructure\", \"superstructure\", or \"similarity\"."New value: +"Search strategy. \"identifier\": name/SMILES/InChIKey lookup. \"formula\": molecular formula. \"substructure\": find compounds containing the query as a substructure. \"superstructure\": find compounds that are themselves substructures of the query. \"similarity\": 2D Tanimoto similarity to the query."
    • addedOutput schema / properties / notice
      Added value: +{
      +  "description": "Recovery guidance when no compounds matched — echoes search strategy and suggests how to broaden. Absent when results were returned.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / results / items / description
      Added value: +"Matching compound entry."
    • changedOutput schema / properties / results / items / properties / properties / description
      Previous value: -"Compound properties when requested."New value: +"Compound properties keyed by name (echoes input.properties; only present when requested)."
    • changedOutput schema / properties / searchType / description
      Previous value: -"The search strategy used."New value: +"Search strategy used: identifier, formula, substructure, superstructure, or similarity."
    • changedOutput schema / properties / totalFound / description
      Previous value: -"Total CIDs found (before maxResults cap)."New value: +"Total CIDs found before the maxResults cap."
    • changedOutput schema / required
      Previous value: -[
      -  "searchType",
      -  "totalFound",
      -  "results"
      -]New value: +[
      +  "results",
      +  "searchType",
      +  "totalFound"
      +]
  6. First observedv0.1.11

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations already establish read-only, open-world, and idempotent behavior, so the bar is appropriately lower. The description adds useful behavioral context: results are returned as a page of CIDs, offset pagination reaches matches past maxResults, and property hydration can eliminate a follow-up call. No behavioral claims contradict the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact at three sentences and front-loads the core search purpose before pagination and hydration details. Every sentence earns its place: search modes, output/paging behavior, and cross-tool optimization. There is no repetition of annotation or schema content beyond necessary orientation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's high complexity—11 parameters, five search modes, conditional requirements—the description, combined with the fully documented schema and existing output schema, is complete enough for correct invocation. The description explains the key output guarantee, pagination, and the optional hydration path. Nothing material is missing for an agent to select and call the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3 and the schema already documents every parameter with examples, defaults, constraints, and per-mode requirements. The main description adds little beyond the schema: it restates batching up to 25 identifiers and Hill notation, both of which already appear in the schema. This consistency is useful but does not meaningfully exceed the schema's parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description identifies a specific resource, PubChem compounds, and a precise action, search, with five enumerated modes: identifier, formula, substructure, superstructure, and similarity. It clarifies the primary output as CIDs and distinguishes itself from the sibling details tool by noting that property hydration avoids a follow-up pubchem_get_compound_details call. This makes the tool's purpose unambiguous and distinct from the other PubChem siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context for when to use this tool: when searching for compounds by identifiers, formula, structural containment, or similarity. It also provides one concrete routing cue—hydrate results with properties to avoid a second call to pubchem_get_compound_details. It does not explicitly enumerate exclusions or name all sibling alternatives, but the guidance is sufficient for typical agent selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/pubchem-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server