Skip to content

Add global search_docs tool and cross-resource doc discovery#181

Merged
titouanmathis merged 2 commits into
mainfrom
feat/mcp-docs-search
Jun 9, 2026
Merged

Add global search_docs tool and cross-resource doc discovery#181
titouanmathis merged 2 commits into
mainfrom
feat/mcp-docs-search

Conversation

@titouanmathis

@titouanmathis titouanmathis commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #180. Gives agents one front door to discover documentation across everything the server exposes, over one shared search index.

Motivation: the tools already had per-item discovery (productive action=help/schema, api_read describe), and #180 added a scripting-docs tool — but there was no way to search across them ("which resource/endpoint handles invoices?"), and two overlapping discovery tools was redundant surface.

What's added

  • search_docs — the single discovery tool. No query → a compact table of contents across domains (resources, raw API endpoints, run_script scripting API). A query → ranked cross-domain matches:
    • resources → compact matches + drill in via productive action="help"
    • raw API endpoints → compact matches + drill in via api_read describe
    • run_script scripting API → full matching section bodies, returned inline (search_docs owns the scripting docs, so it is the drill-in)
  • productive action=help + query — cross-resource help search (which resources match a term, and where).
  • api_read search="<term>" — discover documented endpoints by keyword; path is now optional (provide path or search).

All three are thin wrappers over pure, reused enginessearchResourceHelp, searchApiEndpoints, findDocSections — so the indexes can't drift from the real docs.

Consolidation (vs. the earlier iteration)

The separate run_script_search_docs tool is removed; its content now lives in search_docs. There was never content duplication (both read one DOC_SECTIONS source), but two discovery tools was redundant surface — collapsing to one is simpler to maintain and gives agents a single place to look. run/docs.ts is reduced to the shared content + matcher.

Token budget

Discovery content lives in tool responses, not schemas (TOC-first, drill-in on demand). The full TOOLS list stays modest and the heavy reference is never loaded wholesale.

Testing

  • Unit tests for each engine (help.test.ts, api-utils search, run/docs matcher) and the aggregator (search-docs.test.ts), plus api_read search-mode and the help-query path.
  • Integration tests drive search_docs (TOC, cross-domain query, full scripting sections), action=help query, and api_read search through the real binary.
  • 907 MCP unit + 60 integration tests pass; npm run check clean.

🤖 Generated with Claude Code

Give agents many ways to discover docs over one shared search index, so the
focused tools (action=help, api_read describe, run_script_search_docs) stay
while a single front door ties them together:
- New `search_docs` tool: no query returns a table of contents across domains
  (resources, raw API endpoints, run_script scripting API); a query returns
  ranked cross-domain matches, each pointing at the tool to drill in
- `productive` action=help now accepts a `query` for cross-resource search
- `api_read` accepts `search="<term>"` to discover endpoints by keyword (path
  is now optional; provide path or search)
- Reuses pure engines (searchResourceHelp, searchApiEndpoints, findDocSections)
  so nothing drifts; SKILL.md/CHANGELOG/tests updated

Co-authored-by: Claude <claude@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.82353% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.25%. Comparing base (4842304) to head (6d01ebf).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/mcp/src/handlers/index.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
+ Coverage   97.23%   97.25%   +0.01%     
==========================================
  Files         263      264       +1     
  Lines        8739     8802      +63     
  Branches     2716     2788      +72     
==========================================
+ Hits         8497     8560      +63     
  Misses        236      236              
  Partials        6        6              
Flag Coverage Δ
unittests 97.25% <98.82%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Drop the separate run_script_search_docs tool and fold the scripting reference
into the global search_docs, so there is one discovery front door instead of
two overlapping ones:
- search_docs now owns the run_script docs: it lists scripting topics in its
  table of contents and returns full matching section bodies on a query (it is
  the scripting drill-in, while resources/endpoints still point at
  action=help / api_read describe)
- run/docs.ts is reduced to the shared content + matcher (DOC_SECTIONS,
  docSectionTitles, findDocSections); the standalone renderer and the
  run_script_search_docs handler/tool/wiring are removed
- Update SKILL.md, CHANGELOG, and tests; tool list drops back to 7

Co-authored-by: Claude <claude@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@titouanmathis titouanmathis merged commit b60ab8e into main Jun 9, 2026
11 checks passed
@titouanmathis titouanmathis deleted the feat/mcp-docs-search branch June 9, 2026 23:13
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