ChemGlyph

v0.2.0
io.github.random-orbit/chemglyph Checked 3 days ago Published 1 month ago

Publication-quality chemical structure and reaction rendering for AI agents.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

render_molecule

Draw a single chemical structure as PNG and return it as an image the chat client can display, plus canonical SMILES, formula, molecular weight, and warnings. Use this when the user asks to render a molecule from SMILES, InChI, or a molblock. Example: {"structure": "CC(=O)Oc1ccccc1C(=O)O", "name": "aspirin"}. Set fmt to 'svg' to also receive the SVG source as text for saving to a file; the PNG preview is always included. The PNG is also written to the user's Downloads/chemglyph folder and the file path is returned, because some chat clients do not render tool images. Set save to false to skip…

ParameterTypeDescription
structure *string
abbreviate
fmtstring
highlight_atoms
name
number
saveboolean
show_atom_indicesboolean
stylestring
transparentboolean

render_reaction

Draw a chemical reaction or synthesis route and return it as a PNG image the chat client can display. Use this when the user asks for a reaction scheme. Pass conditions as pre-formatted Unicode text (e.g. H₂SO₄); ChemGlyph does not parse formulas out of text. Example: {"steps": [{"reactants": ["c1ccccc1O", "CC(=O)OC(C)=O"], "products": ["CC(=O)Oc1ccccc1C(=O)O"], "conditions": {"above": "H₂SO₄ (cat.)", "below": "rt, 15 min"}, "yield": "89%", "arrow": "forward"}], "style": "screen"}. See docs/reaction_schema.md for the full schema. The PNG is written to the user's Downloads/chemglyph fol…

ParameterTypeDescription
spec *object
saveboolean

validate_structure

Validate a structure string and return errors plus automatic fixes. Use this when a SMILES may be malformed and you need a repair suggestion before rendering. Example: {"structure": "c1cccc1"} returns the fixed SMILES "C1CCCC1".

ParameterTypeDescription
structure *string

parse_name

Convert a chemical name into canonical SMILES, offline. Use this when the user gives a name like 'aspirin' or '阿司匹林' and you need SMILES. English IUPAC/common names resolve via OPSIN (needs the chemglyph[opsin] extra and a Java runtime); Chinese names resolve via the built-in dictionary, and unknown Chinese names return a clear error (this MCP tool cannot accept a translator callable — pre-translate to English yourself or use the library API).

ParameterTypeDescription
name *string