Skip to main content
Glama

modify_molecule

Transform or analyze molecules with structural verification. Supports name surgery, SMARTS reactions, and custom SMILES edits, returning a diff of atoms and bonds changed to confirm the modification.

Instructions

Analyze or transform a molecule with structural verification.

IMPORTANT: This is the ONLY correct way to modify a molecule. Never edit SMILES strings yourself and pass them directly to draw_molecule — always go through modify_molecule so you get an MCS-based structural diff to verify the change was correct.

Takes a molecule dict (at minimum {"smiles": "..."}) and applies one of 6 operations. Returns the modified molecule with a structural diff showing exactly what atoms/bonds were added, removed, or changed.

Operations: "analyze" — Inspect without modifying: functional groups, IUPAC names, formula, MW, prefix form. No extra kwargs needed. "name_surgery" — Modify via IUPAC name: add/remove substituents. Pass add=[{"locant": "2", "prefix": "fluoro"}] and/or remove=["methyl"] kwargs. "smarts" — Apply a SMARTS reaction transform. Pass smarts= "reaction SMILES" (e.g. "[c:1][F]>>[c:1][Cl]") or reaction_name= from list_reactions output. "set_smiles" — Use when you have edited a SMILES and want to verify the change. Pass the original mol_json and new_smiles=. The MCS diff will confirm exactly what was added/removed. Do NOT generate SMILES from scratch — use resolve_name. "set_name" — Set the display name. Pass new_name=. "reaction" — Apply a named template from list_reactions. Pass reaction_name= and optionally reagent={"smiles": ...} for binary reactions (coupling, etc.).

Args: mol_json: Source molecule dict with at least {"smiles": "..."}. operation: One of: "analyze", "name_surgery", "smarts", "set_smiles", "set_name", "reaction". add: For "name_surgery" — list of {"locant": str, "prefix": str} dicts. remove: For "name_surgery" — list of prefix strings to remove. new_smiles: For "set_smiles" — validated SMILES string. new_name: For "set_name" — new display name string. reaction_name: For "smarts"/"reaction" — template name. reagent: For "reaction" — dict with "smiles" key for the second reagent. smarts: For "smarts" — reaction SMARTS string. description: For "set_smiles" — optional context note.

Returns: For "analyze": ok, input_smiles, canonical_name, alternative_names, functional_groups, prefix_form, bracket_tree, formula, mw. For modifications: ok, input_smiles, output_smiles, input_name, output_name, aligned_names, diff (atoms_added, atoms_removed, atoms_changed, mcs_smarts, delta_formula, delta_mw), formula, mw.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addNo
removeNo
smartsNo
reagentNo
mol_jsonYes
new_nameNo
operationYes
new_smilesNo
descriptionNo
reaction_nameNo
Behavior4/5

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

No annotations were provided, so the description carries the full behavioral burden. It discloses that the tool returns a structural diff (atoms_added/removed/changed, mcs_smarts) and that it verifies changes, which is critical. However, it does not explicitly mention any side effects like permanence or permission requirements, and the analyze operation being read-only is only implicitly inferred. Overall it is transparent but falls short of exhaustive disclosure.

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?

Though lengthy, the description is well-structured with clear sections (overview, operations, args, returns). The critical instruction about being the only correct way is front-loaded, and each sentence serves a purpose for a tool with six operations. No fluff; complexity justifies length.

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 complexity—10 params, 6 operations, nested objects, and no output schema—the description is comprehensive. It details return fields for both analyze and modification modes, covers all param/operation combinations, and distinguishes from 30+ siblings. There is no missing information that an agent needs to call this tool correctly.

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 description coverage is 0%, and the description fully compensates by defining every parameter in context. Each operation lists which kwargs to pass (e.g., 'add=[{"locant": "2", "prefix": "fluoro"}]' for name_surgery) and explains the meaning of mol_json and operation. It even provides a SMARTS example, adding value far beyond the bare schema types and defaults.

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 clear, specific purpose: 'Analyze or transform a molecule with structural verification.' It enumerates six distinct operations with concrete examples (e.g., 'name_surgery' with add/remove kwargs, 'smarts' with reaction SMILES), and explicitly contrasts itself with draw_molecule and resolve_name, making it unambiguous which tool to use.

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

Usage Guidelines5/5

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

The description provides strong when/when-not guidance: 'This is the ONLY correct way to modify a molecule. Never edit SMILES strings yourself and pass them directly to draw_molecule.' It also explicitly directs when to use alternatives: 'Do NOT generate SMILES from scratch — use resolve_name.' For each operation it specifies exact inputs, leaving no ambiguity about applicability.

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