Skip to main content
Glama

calculate_ph

Compute pH, buffer recipes and ionisation fractions from pKa values, with exact charge balance and warnings when textbook approximations fail.

Instructions

Calculate pH, buffer composition and buffer recipes, with the working.

Solves the exact charge balance — the same one that draws the titration curve — and puts the textbook approximation next to it. Where the two disagree, the approximation has lost its assumptions and the answer says so instead of quietly being wrong.

Pick the topic: "weak_acid", "weak_base", "strong_acid", "strong_base", "buffer" (ratio and capacity), "buffer_recipe" (masses to weigh) or "ionisation" (charged and uncharged fraction of a drug at one pH). You supply the pKa values from the monograph or table.

Not this tool for: drawing pH against titrant volume, equivalence points or indicator choice (use generate_titration_curve), or drawing the species fractions across the whole pH range (use generate_species_distribution) — this one computes, those draw.

Args: topic: Which case to solve. concentration: Concentration in mol/L. pka: pKa of the acid, or of the conjugate acid of a base. pkb: pKb of the base. pka_values: All pKa values of a polyprotic acid, in order. acid_concentration: [HA] in mol/L. base_concentration: [A⁻] in mol/L. target_ph: Wanted pH ("buffer_recipe") or medium pH ("ionisation"). total_concentration: [HA] + [A⁻] in mol/L. volume_ml: Buffer volume in mL. acid_molar_mass: Acid component, g/mol. base_molar_mass: Base component, g/mol. drug_type: "acid" or "base" ("ionisation").

Input Schema

NameRequiredDescriptionDefault
pkaNo
pkbNo
topicYes
drug_typeNoacid
target_phNo
volume_mlNo
pka_valuesNo
concentrationNo
acid_molar_massNo
base_molar_massNo
acid_concentrationNo
base_concentrationNo
total_concentrationNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.7.0

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations, the description carries the full burden, and it does disclose meaningful behavior beyond the signature: the calculation solves the exact charge balance, reports the textbook approximation alongside it, and explicitly flags when the approximation's assumptions fail rather than returning a silently wrong number. It does not state that the tool is a pure computation with no side effects, nor mention precision/rounding or how the two results are labelled in the response — with an output schema present, the omission of return-format detail is minor.

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 definition is front-loaded: purpose first, then the disambiguation block, then a clean per-argument list. Every sentence carries information, though the metaphor-laden second paragraph ('the approximation has lost its assumptions') is slightly longer than needed to convey the same behavioral point.

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 13-parameter computational tool with no annotations, the description covers purpose, alternatives, the meaning of every parameter and the tool's output semantics, and an output schema exists so return values need not be explained. The only gap — which parameters apply to which topic — is partly addressed by the per-argument topic hints.

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

Parameters4/5

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

Schema description coverage is 0%, so the description does real work: it defines every one of the 13 parameters, including physical units (mol/L, mL, g/mol) and the distinction between pka ('of the acid, or of the conjugate acid of a base') and pkb. It also scopes two parameters to specific topics — target_ph applies to buffer_recipe/ionisation, drug_type to ionisation. It does not say which parameters are required per topic, and it never warns that all numeric parameters default to 0, which is the main risk with 12 optional numerics.

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 opening states a specific verb and resource — 'Calculate pH, buffer composition and buffer recipes' — and the topic enumeration names the exact cases solved. It explicitly distinguishes itself from generate_titration_curve and generate_species_distribution ('this one computes, those draw'), so an agent can route without opening any schema.

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?

It gives an explicit 'Not this tool for' block naming the two sibling alternatives and the condition that selects each (drawing pH vs titrant volume, drawing species fractions over the whole pH range). It also tells the agent to 'Pick the topic' and what data to supply ('You supply the pKa values from the monograph or table'), giving both selection and prerequisite guidance.

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