Skip to content

docs: generate real MCP tool reference pages - #133

Merged
hhimanshu merged 3 commits into
mainfrom
feat/mcp-docs-generation
Sep 2, 2026
Merged

hhimanshu merged 3 commits into
mainfrom
feat/mcp-docs-generation

Conversation

@hhimanshu

@hhimanshu hhimanshu commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces the content/docs/api/mcp/index.mdx stub (which described a
different, now-removed tool crate) with a real generated reference for
the native MCP server's 66 tools.

  • scripts/gen-mcp-docs.mjs reads a schema snapshot and writes one
    .mdx page per tool under content/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.mdx rewritten with real content: what
    the server is, how it's connected to (stdio), and a table of the 66
    tools grouped by area.
  • content/docs/api/mcp/meta.json regenerated to list all 66 pages.
  • npm run gen-mcp-docs added; CI gets a drift check mirroring the
    existing gen-docs/gen-openapi-docs pattern
    (git diff --exit-code -- content/docs/api/mcp).
  • Closes Generate real MCP tool reference pages from the native command schema dump #132.

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 of
the 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.json
snapshot 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 that
named 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.json is a manually-placed
snapshot
, not an automated cross-repo fetch — the schema data lives
in TrueCalc's private commercial-layer repo, so the
raw.githubusercontent.com pattern gen-docs.mjs uses for the public
truecalc/core functions.json doesn't apply here without further
work (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.json by hand and re-running npm 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 — passes
  • npm run gen-mcp-docs + git diff --exit-code -- content/docs/api/mcp — clean, no drift
  • npm run test-docs — 67/67 blocks pass
  • npm run lint:enrichment — passes (516 files, 644 formulas)
  • Manually read a fresh sample of generated pages
    (read-get-formats, format-set-conditional-format,
    history-undo, sheet-add, file-import, chart-insert,
    format-set-borders, edit-set-cell) plus index.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.
  • Swept the full diff and all 66 generated pages for the private-repo
    patterns above (repo names, crate paths, issue refs, internal file
    paths) — none remain.

Test plan for reviewer

  • Skim 3–4 generated pages under content/docs/api/mcp/ for
    accuracy against the tool's actual behavior
  • Confirm CI is green
  • Merge when satisfied (left unmerged per this repo's own
    never-auto-merge rule)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

hhimanshu and others added 3 commits September 3, 2026 01:12
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
@hhimanshu hhimanshu self-assigned this Sep 2, 2026
@hhimanshu
hhimanshu merged commit b222f29 into main Sep 2, 2026
2 checks passed
@hhimanshu
hhimanshu deleted the feat/mcp-docs-generation branch September 2, 2026 19:06
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.

Generate real MCP tool reference pages from the native command schema dump

1 participant