Skip to content

[kbn-docs-utils] Add MCP documentation tools and flat stats output#254836

Draft
clintandrewhall wants to merge 6 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/6-mcp-tools
Draft

[kbn-docs-utils] Add MCP documentation tools and flat stats output#254836
clintandrewhall wants to merge 6 commits intoelastic:mainfrom
clintandrewhall:feat/docs-utils/6-mcp-tools

Conversation

@clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Feb 25, 2026

Summary

Important

Depends on #254835. Merge that PR first, then rebase this branch onto main.

Adds two new MCP tools to kbn-mcp-dev-server for checking and fixing API documentation issues, along with the flat stats JSON infrastructure they consume.

Note

This PR is a subset of #247688 for ease of review.

This PR was written with Cursor and claude-4.5-opus-high.

  • check_package_docs quickly validates a plugin, package, or file and returns pass/fail with issue counts by category.
  • fix_package_docs returns detailed issues grouped by file with source snippets and fix templates for agent-assisted remediation.
  • Both tools support flexible targeting via plugin ID, manifest ID (@kbn/...), or file path with auto-detection.
  • A new --write flag on the check_package_docs CLI writes per-package stats.json files to target/api_docs/, which the MCP tools consume.
  • Shared utilities are extracted into docs_utils.ts (package resolution, target detection, stats generation) and get_link.ts (GitHub source link generation).

Commit structure

Commit Description
[kbn-docs-utils] Add flat stats JSON output, extract shared getLink utility Adds FlatStats interfaces, --write flag, flat_stats.ts, and extracts getLink into a shared module.
[kbn-mcp-dev-server] Add check_package_docs and fix_package_docs MCP tools Implements both MCP tools with shared docs_utils.ts, registers them in the server, and documents them in the README.
Tests Unit tests for both MCP tools and updated tests for the flat stats and getLink changes.

Notes

  • The FlatStats type is defined canonically in @kbn/docs-utils and replicated (not imported) in kbn-mcp-dev-server to avoid a direct package dependency; a comment links to the source of truth.

clintandrewhall and others added 6 commits February 24, 2026 21:05
…erformance

- Refactor metrics output to use structured table helpers (`printIssueTable`, `printMissingExportsTable`) and improve GitHub links with line-number anchors via `getLink`.
- Introduce two-pass plugin discovery so filtered builds receive an `allPlugins` list for accurate cross-reference resolution while scoping the TypeScript project to a single plugin's directory for faster compilation.
- Gate aggregate documentation (plugin directory, deprecation summaries) behind a check for both `pluginFilter` and `packageFilter` to avoid writing partial data.
…tility

- Add `--write` flag to `check_package_docs` CLI that writes per-plugin/package `stats.json` to `target/api_docs/` for MCP tools.
- Add `write` to `CliFlags` and `writeStats` to `CliOptions` with corresponding flag parsing.
- Extract `getLink` from `report_metrics.ts` into shared `get_link.ts` module, reused by both `report_metrics.ts` and `flat_stats.ts`.
…tools

- Add `check_package_docs` tool that runs doc validation on a plugin, package, or file and returns pass/fail status with issue counts by category.
- Add `fix_package_docs` tool that returns detailed issues grouped by file with source snippets and fix templates for agent-assisted remediation.
- Both tools support flexible targeting via plugin ID, manifest ID (`@kbn/...`), or file path with auto-detection.
- Document both tools in the `kbn-mcp-dev-server` README with parameter tables, example responses, and recommended workflow.
- Register both tools in the MCP server entry point.
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

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.

2 participants