Skip to main content
Glama
lukasmki

Chemspace MCP Server

by lukasmki

search_substructure

Search for chemical compounds by substructure using SMILES strings to find synthesizable building blocks and screening compounds.

Instructions

Substructure search by SMILES

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
smilesYes
shipToCountryNoThe country you want your order to be shipped to as two-letter country ISO code, e.g DE, US, FRUS
countNoMaximum number of results on a page
pageNoNumber of the page
categoriesNoA list of product categories to searchCSSB - In-stock building blocksCSSS - In-stock screening compoundsCSMB - Make-on-demand building blocksCSMS - Make-on-demand screening compoundsCSCS - Custom request

Implementation Reference

  • The async handler function that implements the core logic of the 'search_substructure' tool. It performs a substructure search by posting the SMILES to the Chemspace API /v4/search/sub endpoint, authenticates with a token, and returns the JSON response.
    @mcp.tool(enabled=True)
    async def search_substructure(
        smiles: str,
        shipToCountry: Country = "US",
        count: ResultCount = 10,
        page: ResultPage = 1,
        categories: ProductCategories = ["CSSB", "CSMB"],
    ):
        """Substructure search by SMILES"""
    
        access_token = await mgr.get_token()
    
        async with httpx.AsyncClient() as client:
            r = await client.post(
                url="https://api.chem-space.com/v4/search/sub",
                headers={
                    "Accept": "application/json; version=4.1",
                    "Authorization": f"Bearer {access_token}",
                },
                params={
                    "shipToCountry": shipToCountry,
                    "count": count,
                    "page": page,
                    "categories": ",".join(categories),
                },
                files={
                    "SMILES": (None, smiles),
                },
            )
        r.raise_for_status()
        data = r.json()
    
        return data
  • Pydantic Annotated type definitions for input parameters used in the search_substructure tool (and other search tools): Country, ResultCount, ResultPage, ProductCategory, ProductCategories.
    Country = Annotated[
        str,
        Field(
            description="The country you want your order to be shipped to as two-letter country ISO code, e.g DE, US, FR"
        ),
    ]
    
    ResultCount = Annotated[
        int, Field(description="Maximum number of results on a page", ge=1)
    ]
    
    ResultPage = Annotated[int, Field(description="Number of the page", ge=1)]
    
    ProductCategory = Literal["CSSB", "CSSS", "CSMB", "CSMS", "CSCS"]
    
    ProductCategories = Annotated[
        List[ProductCategory],
        Field(
            description=(
                "A list of product categories to search"
                "CSSB - In-stock building blocks"
                "CSSS - In-stock screening compounds"
                "CSMB - Make-on-demand building blocks"
                "CSMS - Make-on-demand screening compounds"
                "CSCS - Custom request"
            ),
            min_length=1,
        ),
    ]
  • Invocation of register_tools(mcp, mgr) which defines and registers the search_substructure tool (via decorator) with the FastMCP server instance.
    register_tools(mcp, mgr)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'search' but fails to describe key traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what the search returns (e.g., results format, pagination). This leaves significant gaps in understanding the tool's behavior.

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 extremely concise with a single sentence 'Substructure search by SMILES', which is front-loaded and wastes no words. It efficiently communicates the core purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the complexity of a search tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, result handling, and differentiation from siblings, making it inadequate for the agent to fully understand and use the tool effectively.

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 high at 80%, providing good documentation for parameters like 'shipToCountry', 'count', 'page', and 'categories'. The description adds minimal value by specifying 'SMILES' as the search input, but it doesn't explain parameter interactions or usage beyond what the schema already covers, aligning with the baseline for high coverage.

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

Purpose3/5

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

The description 'Substructure search by SMILES' clearly indicates the action (search) and resource (substructures), but it's vague about what exactly is being searched (e.g., chemical compounds, databases) and doesn't distinguish it from sibling tools like 'search_exact' or 'search_similarity'. It states the purpose but lacks specificity and differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'search_exact' or 'search_similarity'. There's no mention of context, prerequisites, or exclusions, leaving the agent without direction on tool selection.

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

Install Server

Other Tools

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/lukasmki/chemspace-mcp'

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