Skip to main content
Glama

extract_structures_from_image

Extract chemical structures from images and return SMILES with confidence scores and bounding boxes. Optionally detects text labels via OCR.

Instructions

Extract chemical structures from an image using DECIMER.

Takes a PNG, JPG, or PDF image and returns SMILES + confidence scores + bounding boxes for every detected chemical structure. Segments the image into individual structure regions automatically. Optionally detects nearby text labels via OCR.

DECIMER models download on first run (~570 MB to ~/.data/DECIMER-V2/). Requires: DECIMER, opencv-python, and optionally pytesseract/easyocr.

The returned SMILES should be passed through resolve_name or modify_molecule to verify and enrich — DECIMER SMILES may not be canonical and can have low confidence for complex structures.

Args: image_path: Path to PNG, JPG, or PDF file. detect_labels: Attempt OCR detection of text labels near structures. Requires pytesseract or easyocr; labels are null without an OCR library. Default True.

Returns: Dict with keys: ok, image_path, structures (list of: smiles, confidence in [0,1], bbox [x0,y0,x1,y1], label or null). Returns {ok: False, error: "..."} if DECIMER is not installed or extraction fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_pathYes
detect_labelsNo
Behavior5/5

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

With no annotations provided, the description carries the full behavioral burden and delivers thoroughly. It discloses that DECIMER models download on first run (with size and path), lists required dependencies, specifies that OCR is optional and labels default to null without libraries, details the return dictionary shape including error handling ({ok: false, error: ...}), and notes that SMILES may not be canonical or low-confidence for complex structures. This is exemplary transparency.

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

Conciseness4/5

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

The description is structured with clear sections (intro, requirements, usage, args, returns). It front-loads the core purpose and input/output types. While it is somewhat lengthy, every sentence adds essential information (dependencies, error behavior, downstream hints), so it is appropriately sized rather than bloated. A minor improvement would be splitting the 'Requires' note into a dedicated section for scannability.

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?

For a tool with only 2 parameters and no output schema, the description covers all necessary context: input formats, exact output structure, error handling, dependencies, model download behavior, and downstream verification advice. An agent has complete information to decide whether to call this tool and how to interpret its results. Nothing critical is missing.

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

Parameters5/5

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

Schema coverage is 0%, so the description must fully explain parameters, and it does. image_path is defined as 'Path to PNG, JPG, or PDF file,' and detect_labels is explained with its behavior, dependencies, and default (True). The description also explains what each parameter affects in the output, enabling correct argument values without schema assistance.

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 opens with a precise verb-resource-method statement: 'Extract chemical structures from an image using DECIMER.' It names the exact input formats and outputs, making the tool's purpose unambiguous and distinct from siblings like extract_structures_via_decimer_api (which implies a different execution mode) and other image/format converters.

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 implies usage context by specifying input types (PNG, JPG, PDF) and mentions DECIMER requires models to download, signaling a local execution setting. It does not explicitly contrast with extract_structures_via_decimer_api, but it does route downstream use by advising to pass results through resolve_name or modify_molecule for verification, which provides actionable guidance on when to use this tool in a workflow.

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/ZiChenWang114514/cdxml-toolkit-community'

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