Skip to content

Agent examples: an LLM driving the MCP tools (real runs, replayed in CI) - #16

Merged
drthyang merged 1 commit into
mainfrom
claude/mcp-examples
Sep 28, 2026
Merged

drthyang merged 1 commit into
mainfrom
claude/mcp-examples

Conversation

@drthyang

Copy link
Copy Markdown
Owner

The first worked examples from the LLM-usage plan. Both were run for real by Claude (Opus 5.5) in Claude Code against the materia MCP server, then written up in docs/AGENT_EXAMPLES.md.

Examples

1. Look at a structure before any data (Mn₃Ga). The prompt asks for the space group, the Wyckoff sites, the first Cu Kα reflections, and any unphysical distance. The model answered in 4 calls, passing refs between them:

  • P6₃/mmc, with Mn on 6h (one free coordinate) and Ga on 2d (no free coordinates);
  • 100 at 18.9°, 101 at 27.8°, 2-10 at 33.0°, 200 at 38.3°;
  • the shortest contact is Mn–Mn at 2.665 Å, which is normal.

2. A PDF fit block by block, then local vs average (GaTa₄Se₈, X-ray, 1.5–28 Å).

Block Rw
scale + cell 35.3 %
+ anisotropic ADPs 19.3 %
+ Qdamp/Qbroad 12.2 %
+ δ1 8.61 %
+ positions 8.33 % (the demo's published fit is 8.12 %)

The run states three judgement calls:

  • Qdamp freed even though no calibration standard ships with the data.
  • Qbroad dropped because it sat at its bound.
  • δ1 rather than δ2 (one correlated-motion law).

It then ran a boxcar scan. The 1.5–7.5 Å box fits worst (11.0% against 3–6%), and U(Se2) nearly doubles with r while the cell stays flat. A reverse scan agrees within the esds, so the drift is in the data. Conclusion: the local structure differs from the cubic average, and naming the distortion needs a lower-symmetry model.

Keeping the page honest

  • examples/mcp/ holds the app's bundled demo data as plain files, so a model can load them by path. It also includes the MnO CIF and a POWGEN .irf for the Rietveld example that comes next.
  • src/mcp/examples.test.ts does two jobs:
    • Every file must equal its TypeScript source; UPDATE_MCP_EXAMPLES=1 rewrites them.
    • Each example's tool sequence is replayed through an MCP client, and the page's claims are asserted. It takes about 33 s. MCP_EXAMPLES_FULL=1 adds each block's Rw and the reverse scan (about 80 s), which I ran and which passes.
  • Speed: refining all the blocks at once reaches the same minimum (Rw 8.33%, Qdamp 0.0439, δ1 1.778), which keeps the CI replay short.

Next

  • Example 2 (Rietveld with the skill): needs check_cell_symmetry and export_bundle. This session's materia server was started before those merged, so it has to be reconnected before that run can be recorded.
  • Example 3 (magnetic structure from leftover peaks): needs a synthetic dataset designed first.

Both are listed under "Other planned work" in AGENT_TOOLS.

Tests: 196 files, 1,490 tests pass. tsc -b and eslint . are clean.

🤖 Generated with Claude Code

…al runs

docs/AGENT_EXAMPLES.md — two worked examples, each run for real by Claude
(Opus 5.5) in Claude Code against the `materia` server:

1. Look at a structure before any data (Mn₃Ga): space group, Wyckoff sites,
   first Cu Kα reflections, shortest contact — four calls on refs.
2. (Example 4 in the plan) GaTa₄Se₈ X-ray PDF fitted block by block — scale
   + cell 35.3 %, ADPs 19.3 %, Qdamp 12.2 %, δ1 8.61 %, positions 8.33 %
   (demo: 8.12 %) — with the judgement calls stated (Qdamp freed without a
   standard, Qbroad at its bound dropped, δ1 not δ2); then a boxcar scan: the
   1.5–7.5 Å box fits worst and U(Se2) doubles with r while the cell stays
   flat; the reverse scan agrees, so the drift is in the data.

examples/mcp/ holds the app's bundled demo data as plain files (plus MnO and
a POWGEN .irf for the Rietveld example to come). src/mcp/examples.test.ts
keeps both honest: the files must equal their TS sources (UPDATE_MCP_EXAMPLES=1
rewrites them), and each example's tool sequence is replayed through an MCP
client with the page's claims asserted (~33 s; MCP_EXAMPLES_FULL=1 adds each
block and the reverse scan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drthyang
drthyang merged commit 1be28ad into main Sep 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant