feat(mcp): rewrite API URLs as get_api_reference refs with member-level lookups#1698
feat(mcp): rewrite API URLs as get_api_reference refs with member-level lookups#1698dkalinovInfra wants to merge 5 commits into
Conversation
- Introduced new scripts for rewriting API URLs for Angular, Blazor, React, and Web Components in package.json. - Updated compression scripts to preserve specific API reference links verbatim. - Implemented a new script (rewrite-api-links.ts) to convert existing API documentation URLs to a standardized format. - Enhanced the extractMember function to support member-targeted lookups in API documentation. - Updated API reference handler to prioritize member lookups over section requests. - Added validation for member names in schemas, ensuring they are trimmed and within character limits. - Improved test coverage for member extraction and API reference handling.
There was a problem hiding this comment.
Pull request overview
This PR enhances the @igniteui/mcp-server documentation pipeline by (1) extending get_api_reference to support member-level lookups (and making section filtering work on real llms-full.txt shapes), and (2) adding a deterministic, non-LLM rewrite step that converts infragistics.com API links in prepared markdown into mcp:get_api_reference?... references resolved at tool-call time.
Changes:
- Extend
get_api_referencewith optionalmembersupport (plus defensiveComponent#memberparsing) and implement bullet-syntax inference sosection=properties|methods|eventsworks even without##headings. - Add
scripts/rewrite-api-links.ts+ tests, and wire it into all platform pipelines (inject → rewrite-api-urls → diff → compress ...). - Update compression prompts and developer docs to preserve
mcp:get_api_reference?...URIs verbatim and document the new pipeline step/tool behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/igniteui-mcp/igniteui-doc-mcp/src/tools/schemas.ts | Adds member param to get_api_reference schema and clarifies section precedence. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tools/handlers.ts | Implements member lookup, Component#member parsing, and precedence over section. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tools/constants.ts | Updates tool description to document member usage and error behavior. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts | Adds extractMember and implements flat-bullet inference fallback for extractSection. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/tools/schemas.test.ts | Updates schema tests for Blazor platform support and new member field. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/tools/handlers.test.ts | Adds coverage for member-targeted lookup and Component#member parsing. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/scripts/rewrite-api-links.test.ts | New tests for per-platform URL rewrite patterns and skip behavior. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/lib/api-doc-search.test.ts | Adds tests for bullet inference in extractSection and for extractMember. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/rewrite-api-links.ts | New deterministic link rewriter script + canonical-name index builder. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/compress-*-docs.ts | Updates prompts to require preserving mcp:get_api_reference?... URLs verbatim. |
| packages/igniteui-mcp/igniteui-doc-mcp/package.json | Adds rewrite scripts and inserts them into incremental/full pipelines. |
| packages/igniteui-mcp/igniteui-doc-mcp/DEVELOPMENT.md | Documents new rewrite step and new get_api_reference parameters/behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Member-targeted lookup takes precedence over section. | ||
| if (member) { | ||
| const match = extractMember(content, member); | ||
| if (match) { | ||
| const text = `${entry.component}.${member} (${match.section}):\n${match.line}`; | ||
| return { content: [{ type: "text", text }] }; |
There was a problem hiding this comment.
Fixed in 0197c68. Added a name field to MemberMatch that captures the actual member name as found in the markdown, and extractMember now returns it alongside section and line. The response header in handlers.ts now uses match.name instead of the user-supplied member, so it always reflects the canonical casing from the API docs regardless of how the user typed the member name.
Agent-Logs-Url: https://github.com/IgniteUI/igniteui-cli/sessions/39f2785e-9b7b-4932-8b02-5f988d34033d Co-authored-by: dkalinovInfra <130121354+dkalinovInfra@users.noreply.github.com>
Description
Adds deterministic
mcp:get_api_reference?...references for API documentation links in the MCP server's compiled docs, and extendsget_api_referenceto resolve those references at call time.Two coordinated changes:
Member-aware
get_api_reference— the tool gains an optionalmemberparameter that returns only one property/method/event line instead of the full component entry.section(properties/methods/events) is now functional too — it walks the bullet list and emits only matching bullets, classified by syntax (method = signature, event =EventEmitter<T>orEventCallback<T>, otherwise property). The handler also toleratesComponent#membershorthand defensively. Response-size impact on a real Angular grid entry: full 4.6 KB →section=methods2.3 KB (−50%) →member=data113 B (−97%).Deterministic URL → MCP-ref rewriter — new
scripts/rewrite-api-links.tsruns betweeninjectanddiffin each platform pipeline. It rewriteshttps://www.infragistics.com/.../classes/<name>.html#<member>URLs tomcp:get_api_reference?platform=<p>&component=<C>&member=<m>. Pure regex match per platform — no LLM in the loop. Handles all four URL shapes (bare/docs/,/api/docs/with package prefixes, Blazor FQN form, Web Components dock-manager subpath), decodes Blazor docfx synthetic anchors (#IgniteUI_Blazor_Controls_IgbGrid_Sort→member=Sort), and recovers PascalCase canonical names from lowercased URL segments via the existingApiDocLoaderindex. Compression prompts updated to preservemcp:URIs verbatim.End-to-end smoke test against 270 Blazor doc files: 5,683 URLs rewritten across 241 files, 0 unknown-component skips, 0 mis-rewrites.
Related Issue
Closes #
Type of Change
Affected Packages
igniteui-cli(packages/cli)@igniteui/cli-core(packages/core)@igniteui/angular-templates(packages/igx-templates)@igniteui/angular-schematics(packages/ng-schematics)@igniteui/mcp-server(packages/igniteui-mcp)Checklist
npm run test) — 173/173 passingnpm run build)npm run lint) — root-level lint has pre-existing parser errors in submodule files underwebcomponents/igniteui-webcomponents/**that are unrelated to this PR; no new errors introduced by these changesEventCallbackclassificationAdditional Context
Sample rewrite (
dist/docs_prepeared/blazor/grid-advanced-filtering.md):Real-world
get_api_referenceprobe (scripts/test-get-api-reference.ts) — 27 scenarios across all four platforms, every code path passing. Response-size impact on a realIgbGridentry:section=propertiessection=methodssection=eventsmember=DataSection parameter was previously a no-op —
extractSectionwalked for## Properties/## Methods/## Eventsheadings, but no realllms-full.txtfile has those headings (they're flat bullet lists under### [Component]). The new bullet-inference fallback makes the parameter actually do what its description always claimed.Pipeline ordering:
clear → (build:xplat) → export → inject → rewrite-api-urls → diff → compress → update-baseline → build:db. Rewrite runs pre-compress so the LLM sees and preserves the finalmcp:URIs.