docs: generate real MCP tool reference pages - #133
Merged
Merged
Conversation
Adds scripts/gen-mcp-docs.mjs, following gen-docs.mjs's own generated-page convention: one .mdx per tool under content/docs/api/mcp/ (66 tools), derived from a committed snapshot of the native MCP server's per-tool JSON Schemas at scripts/mcp-source/. Each page gets a parameters table, a returns table, and the raw request/response JSON Schema. The schema `description` fields are Rust doc comments (internal type names, rustdoc intra-doc links, source-file/issue references) written for the crate's own contributors, not docs readers. cleanText()/synthesizeSummary() in the generator salvage the plain-English parts clause-by-clause and discard the rest, falling back to a short description derived from the tool's own wire name when nothing user-facing survives -- never publishing a mangled fragment. Rewrites content/docs/api/mcp/index.mdx (hand-written) to describe the real tool surface honestly, without inventing unverified connection commands. Wires an equivalent CI drift check alongside the existing gen-docs/ gen-openapi-docs ones, and registers the gen-mcp-docs npm script. closes #132 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WfhRbND7tjFJ4JeGZ9gHL5
…ption
ABBREV_PLACEHOLDER was a plain space, but unguardAbbreviations() restored
it with a blind text.split(' ').join('.') -- turning every space in the
string into a period, not just the sentinel it introduced. Every
generated tool page's Parameters/Returns prose came out as
"The.sheet.name." style corruption. Switch the sentinel to U+0000, which
cannot occur in JSON-sourced text, and regenerate.
Also stop typeLabel() from collapsing an over-long discriminated-union
branch to a bare "object": keep the literal `kind` (or similar) tag so a
reader can still tell union branches apart, and render a bare `const`
field's literal value instead of its generic type.
The committed tool-schemas.json snapshot carried the private core-pro
crate's raw Rust doc comments verbatim -- private repo name
(truecalc/studio), crate paths (crate::commands::CommandOutcome,
crate::document::...), an internal issue ref (pro#120), and internal
source file paths (envelope.ts, schema.ts). gen-mcp-docs.mjs's
cleanText()/isJargon() sanitizer was applied to the prose tables but
never to the raw JSON Schema block each page also dumps, so every one
of the 66 generated pages published this narration straight onto the
public docs site.
- sanitizeSchemaForDisplay() now cleans (or drops) every `description`
in the JSON Schema block before it's serialized, reusing the same
cleanText() pass already trusted for the prose tables.
- Re-ran the same cleaning pass over the checked-in tool-schemas.json
snapshot itself, so the committed source data carries no private
narration either -- confirmed idempotent: regenerating from the
scrubbed source reproduces byte-identical pages.
- Removed scripts/mcp-source/openapi.json: an unreferenced leftover
that named the private crate explicitly ("TrueCalc Pro command API")
and leaked further internal file paths; nothing in this repo reads it.
Verified: build, types:check, gen-mcp-docs drift check, test-docs
(67/67), and lint:enrichment all pass; swept all 66 generated pages
plus the source snapshot for the leaked patterns above -- none remain.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WfhRbND7tjFJ4JeGZ9gHL5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
content/docs/api/mcp/index.mdxstub (which described adifferent, now-removed tool crate) with a real generated reference for
the native MCP server's 66 tools.
scripts/gen-mcp-docs.mjsreads a schema snapshot and writes one.mdxpage per tool undercontent/docs/api/mcp/— title, a plain-language summary, a parameters table, a returns table, and the full
JSON Schema for both request and response.
content/docs/api/mcp/index.mdxrewritten with real content: whatthe server is, how it's connected to (stdio), and a table of the 66
tools grouped by area.
content/docs/api/mcp/meta.jsonregenerated to list all 66 pages.npm run gen-mcp-docsadded; CI gets a drift check mirroring theexisting
gen-docs/gen-openapi-docspattern(
git diff --exit-code -- content/docs/api/mcp).Fixed during independent verification (not in the original patch)
The tool descriptions in the source schema are Rust doc comments
written for the crate's own contributors — full of private-repo
references, internal crate paths, and internal issue IDs. The original
patch's
cleanText()/isJargon()pass correctly scrubbed those out ofthe prose parameter/return tables, but not out of the raw JSON
Schema block each page also dumps for completeness — so every one of
the 66 pages was about to publish that narration verbatim onto the
public site (private repo name, internal crate paths, an internal
issue reference, internal source file paths). Fixed by routing the
schema dump through the same cleaning pass before serializing, and by
re-running that same pass over the committed
tool-schemas.jsonsnapshot itself so the checked-in source carries none of it either
(confirmed idempotent — regenerating from the scrubbed snapshot
reproduces byte-identical pages). Also removed
scripts/mcp-source/openapi.json, an unreferenced leftover file thatnamed the private crate explicitly and leaked further internal paths;
nothing in this repo reads it.
Known gap (called out in the script's own header comment)
scripts/mcp-source/tool-schemas.jsonis a manually-placedsnapshot, not an automated cross-repo fetch — the schema data lives
in TrueCalc's private commercial-layer repo, so the
raw.githubusercontent.compatterngen-docs.mjsuses for the publictruecalc/corefunctions.jsondoesn't apply here without furtherwork (a GitHub App/token with private-repo read access, or the source
repo publishing schema dumps as a public release asset). Until that
exists, refreshing these pages means re-copying (and re-sanitizing)
tool-schemas.jsonby hand and re-runningnpm run gen-mcp-docs.Tracked as a follow-up per the issue's own scope note.
Verification
All run locally against this branch, not just reported:
npm run build— passes (static export)npm run types:check— passesnpm run gen-mcp-docs+git diff --exit-code -- content/docs/api/mcp— clean, no driftnpm run test-docs— 67/67 blocks passnpm run lint:enrichment— passes (516 files, 644 formulas)(
read-get-formats,format-set-conditional-format,history-undo,sheet-add,file-import,chart-insert,format-set-borders,edit-set-cell) plusindex.mdx— accurate,no leaked internal references, sensible fallback ("Nothing beyond
the standard MCP success envelope" / a field's description entirely
omitted rather than left half-jargon) when nothing was salvageable.
patterns above (repo names, crate paths, issue refs, internal file
paths) — none remain.
Test plan for reviewer
content/docs/api/mcp/foraccuracy against the tool's actual behavior
never-auto-merge rule)
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.