{
  "openapi": "3.1.1",
  "info": {
    "title": "SMILES to 3D Coordinates (XYZ) with Force-Field Minimisation API",
    "version": "1.0.0",
    "summary": "Approximate 3-D structure from SMILES: XYZ and MOL with bond lengths, angles and energy.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://prooflinemoleculegeometry.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Approximate 3-D structure from SMILES: XYZ and MOL with bond lengths, angles and energy.",
        "description": "Turn a SMILES string or a 2-D MOL file into approximate 3-D coordinates: hydrogens are added, a start geometry is built from the 2-D layout and relaxed with a small UFF-style force field by conjugate gradients or steepest descent. You get XYZ and MOL files, the force-field energy by term, bond-length statistics, a ball-and-stick picture and any distances, angles or dihedrals you ask for. Approximate geometry, not quantum chemistry. Part of the Proofline math notebook and its Molecule Lab.\n\nMethodology:\n- Hydrogens are added, the 2-D layout (stress majorisation, then bond and angle refinement) gives x and y, and a seeded jitter gives z; hydrogens start away from their neighbours. Each start is first relaxed with soft repulsion only, then with the full force field.\n- Force field (UFF-inspired subset): bond stretch k(r − r₀)² with r₀ from Pyykkö’s single, double and triple covalent radii (aromatic in between); angle bend in cos θ with natural angles 109.47°/120°/180° from the hybridisation (UFF values for O, N, S, P in sp³, 60° and 88° in three- and four-membered rings); UFF-form torsions (3-fold sp³–sp³, 2-fold across double and aromatic bonds, 6-fold sp²–sp³); a planarity term for sp² centres; Lennard-Jones 12-6 with UFF van der Waals parameters for atoms three or more bonds apart (1-4 pairs halved).\n- Minimisation: Polak–Ribière+ conjugate gradients with a backtracking line search and restarts, or steepest descent; it stops when the largest gradient component is below 0.001 kcal/mol/Å. The structure is centred and turned so its longest extent lies along x.\n- Approximate geometry, not quantum chemistry: no charges, no solvent, no stereo; expect bond lengths within about ±0.03 Å and angles within a few degrees of experiment, and a local energy minimum (conformers are not searched).\n\nForce-field geometries are approximate and the energy is only meaningful to compare conformations of the same molecule. Nothing here is advice on handling chemicals safely.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "proofline_molecule_geometry",
        "x-owner-app": "proofline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProoflineMoleculeGeometryInput"
              },
              "examples": {
                "example1": {
                  "summary": "Ethanol with the C–O bond and the C–C–O angle",
                  "value": {
                    "structure": "CCO",
                    "measure": "2-3, 1-2-3"
                  }
                },
                "example2": {
                  "summary": "Benzene (planar ring)",
                  "value": {
                    "structure": "c1ccccc1",
                    "measure": "1-2, 1-2-3, 1-2-3-4"
                  }
                },
                "example3": {
                  "summary": "Butane: staggered carbon chain",
                  "value": {
                    "structure": "CCCC",
                    "measure": "1-2-3-4"
                  }
                },
                "example4": {
                  "summary": "Water by steepest descent",
                  "value": {
                    "structure": "O",
                    "method": "sd",
                    "starts": 1,
                    "measure": "2-1-3"
                  }
                },
                "example5": {
                  "summary": "Aspirin",
                  "value": {
                    "structure": "CC(=O)Oc1ccccc1C(=O)O",
                    "starts": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProoflineMoleculeGeometryResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ProoflineMoleculeGeometryInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "structure": {
            "title": "Structure",
            "description": "A SMILES string (CCO, c1ccccc1, [NH4+]), a MOL/SDF V2000 block or XYZ coordinates. SMILES subset: organic atoms B C N O P S F Cl Br I and aromatic b c n o p s, bracket atoms with isotope, hydrogens and charge, bonds - = # :, branches, ring numbers and %nn, dots between parts. Stereo marks are read but not used. At most 300 atoms including hydrogens.",
            "type": "string",
            "maxLength": 200000,
            "default": "CCO"
          },
          "format": {
            "title": "Format",
            "type": "string",
            "enum": [
              "auto",
              "smiles",
              "mol",
              "xyz"
            ],
            "default": "auto"
          },
          "method": {
            "title": "Minimiser",
            "type": "string",
            "enum": [
              "cg",
              "sd"
            ],
            "default": "cg"
          },
          "maxIterations": {
            "title": "Maximum iterations",
            "description": "Per start; minimisation stops earlier when the largest gradient is below 0.001 kcal/mol/Å.",
            "type": "integer",
            "minimum": 10,
            "maximum": 20000,
            "default": 2000
          },
          "starts": {
            "title": "Starting structures",
            "description": "Different seeded start geometries; the one with the lowest energy is kept.",
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 3
          },
          "measure": {
            "title": "Measure (optional)",
            "description": "Atom numbers of the result (hydrogens come after the heavy atoms): two for a distance, three for an angle, four for a dihedral, separated by commas.",
            "type": "string",
            "maxLength": 400,
            "default": ""
          }
        },
        "required": [
          "structure"
        ]
      },
      "ProoflineMoleculeGeometryResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "formula",
              "canonicalSmiles",
              "atoms",
              "method",
              "converged",
              "iterations",
              "rmsGradient",
              "energy",
              "starts",
              "startEnergies",
              "bondStats",
              "measurements",
              "xyz",
              "molfile",
              "coordinates"
            ],
            "properties": {
              "formula": {
                "type": "string"
              },
              "canonicalSmiles": {
                "type": "string"
              },
              "atoms": {
                "type": "integer"
              },
              "method": {
                "type": "string",
                "enum": [
                  "cg",
                  "sd"
                ]
              },
              "converged": {
                "type": "boolean"
              },
              "iterations": {
                "type": "integer"
              },
              "rmsGradient": {
                "type": "number"
              },
              "energy": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "bond",
                  "angle",
                  "torsion",
                  "inversion",
                  "vdw",
                  "total"
                ],
                "properties": {
                  "bond": {
                    "type": "number"
                  },
                  "angle": {
                    "type": "number"
                  },
                  "torsion": {
                    "type": "number"
                  },
                  "inversion": {
                    "type": "number"
                  },
                  "vdw": {
                    "type": "number"
                  },
                  "total": {
                    "type": "number"
                  }
                }
              },
              "starts": {
                "type": "integer"
              },
              "startEnergies": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "bondStats": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "bond",
                    "count",
                    "min",
                    "mean",
                    "max"
                  ],
                  "properties": {
                    "bond": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "min": {
                      "type": "number"
                    },
                    "mean": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    }
                  }
                }
              },
              "measurements": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "atoms",
                    "kind",
                    "label",
                    "value",
                    "unit"
                  ],
                  "properties": {
                    "atoms": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "distance",
                        "angle",
                        "dihedral"
                      ]
                    },
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "number"
                    },
                    "unit": {
                      "type": "string"
                    }
                  }
                }
              },
              "xyz": {
                "type": "string"
              },
              "molfile": {
                "type": "string"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "n",
                    "element",
                    "x",
                    "y",
                    "z"
                  ],
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "element": {
                      "type": "string"
                    },
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    },
                    "z": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}