fix(mcp): publish API reference docs and load latest version#1701
fix(mcp): publish API reference docs and load latest version#1701dkalinovInfra wants to merge 9 commits into
Conversation
…erver, and templates
…se latest versions
…erver, templates, and schematics
…, templates, and schematics
There was a problem hiding this comment.
Pull request overview
This PR fixes API reference availability for the published @igniteui/mcp-server package by ensuring the generated llms-full.txt API snapshots are packaged correctly and that the runtime loader consistently prefers the newest version when multiple version directories exist. It also updates CI to build these API docs during release publishing.
Changes:
- Added shared version ranking/picking logic and updated
ApiDocLoaderto load only the latest version per package. - Updated API-doc export scripts to emit only the latest version per package and introduced a patch step to pin overrides in the
api-docssubmodule before installing/building. - Updated release workflow to build MCP API docs at publish time and improved checkout/setup actions.
Reviewed changes
Copilot reviewed 18 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/igniteui-mcp/igniteui-doc-mcp/src/lib/version-picker.ts | Introduces shared version directory comparison and “latest” selection logic. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-loader.ts | Loads only the latest version per package to prevent older snapshots overwriting newer data. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/lib/version-picker.test.ts | Adds tests for version ranking and latest selection behavior. |
| packages/igniteui-mcp/igniteui-doc-mcp/src/tests/lib/api-doc-loader.test.ts | Adds regression coverage for multi-version package directories. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/patch-api-docs-overrides.ts | Patches api-docs submodule package.json overrides to work around upstream dependency breakage. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/export-angular-api.ts | Exports only the latest Angular API snapshot per package. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/export-react-api.ts | Exports only the latest React API snapshot per package. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/export-wc-api.ts | Exports only the latest Web Components API snapshot per package. |
| packages/igniteui-mcp/igniteui-doc-mcp/scripts/export-blazor-api.ts | Exports only the latest Blazor API snapshot per package. |
| packages/igniteui-mcp/igniteui-doc-mcp/package.json | Ensures API snapshot files are published and wires doc-build + patching into build:docs:all. |
| packages/igniteui-mcp/.gitignore | Ignores generated API snapshot directories under igniteui-doc-mcp/docs/*-api. |
| .github/workflows/npm-publish.yml | Builds MCP API docs during releases; updates actions; configures auth for private submodules. |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/webcomponents-api/igniteui-grid-lite/latest/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/webcomponents-api/igniteui-dockmanager/latest/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/react-api/igniteui-react-dockmanager/19.5.1/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/blazor-api/IgniteUI.Blazor.GridLite/25.1.x/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/blazor-api/IgniteUI.Blazor.Documents.Core/25.1.x/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/angular-api/igniteui-angular-layouts/latest/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
| packages/igniteui-mcp/igniteui-doc-mcp/docs/angular-api/igniteui-angular-gauges/latest/llms-full.txt | Removes checked-in generated API snapshot (now built during release). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - uses: actions/setup-node@v2 | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.CLASSIC_PAT_GITHUB }} |
There was a problem hiding this comment.
If you're adding a PAT token to this step as well, can we not just use submodules: true/recursive and have those clones correctly? I assume all of the submodules are needed at build time.
That'll also allow dropping or at least splitting the spread out submodule update calls from build scripts.
There was a problem hiding this comment.
That PAT token was already added, so I've decided to reuse it. About other submodules, for now we don't use them during the build, so this will slow down the release workflow without any real need to have all of the submodules.
| const PKG_PATH = join(ROOT, 'blazor', 'api-docs', 'package.json'); | ||
|
|
||
| const OVERRIDES = { | ||
| '@astrojs/sitemap': '^3.7.2', |
There was a problem hiding this comment.
Um any specific reason for the overrides? Kinda doesn't seem it should be needed, the submodules should be hitting stable refs, right?
Besides the fact this can affect the lock file, it will also go out of sync with the submodule repo - so fragile either way.
If there's an issue, is this something that should be addressed/fixed in the submodule repo itself?
There was a problem hiding this comment.
PS: Really odd the api-docs for all is cloned under blazor 😄
There was a problem hiding this comment.
I will probably deleted this script, as it may not be needed any more. Api repo was updated with same sitemap version as we need for the build (the issue was coming from zod versions sitemap needs v3 but we have dependency on v4 and this was breaking the build).
There was a problem hiding this comment.
And this one is a bit shaky too, though almost all of the scripts around collecting those API docs are prone to breakage if anything shifts slightly in the API docs build process.
Unless speed is critical here, as this is a requirement for the process, it should be possible to address this in the submodule repo again - either by producing artifacts that can be consumed by the MCP eventually, but even before that on the build commands level in api-docs we should really have a sub-set command to produce just the latest API Docs for a platform and even just the LLMs txt if possible and even preferably with parametrized path so this process can call something like:
npm run build:angular-latest-llm:en -- ../../docs/angular-api/llms-full.txtand be pretty much done with the whole process.
Description
Fixes two bugs preventing API reference data from working in the published
@igniteui/mcp-serverpackage, plus the CI changes needed to build those docs at release time.Bug 1 —
filesfield shipped the wrong glob. Thefilesarray inpackages/igniteui-mcp/igniteui-doc-mcp/package.jsonreferenceddocs/<framework>/api/...with.md/.jsonextensions, but the actual on-disk layout isdocs/<framework>-api/<pkg>/<ver>/llms-full.txt. The published tarball contained zero API entries, soget_api_reference/search_apireturned "API reference not available" for every platform. Updatedfilesto match the real paths and added the missingdocs/blazor-api/entry.Bug 2 —
ApiDocLoaderversion collision. Entries were keyed${platform}:${componentName}andreaddirSynclex-ordering meant older versions (9.0.x) silently overwrote newer ones (21.0.x) for any package with multiple version subdirs.IgxGridComponentwas returning the v9 entry, missing fields added later (e.g.groupingDone). Fix has two parts:scripts/export-{angular,react,wc,blazor}-api.tsnow copy only the highest-ranked version per package and delete any older versions from the on-disk output directory. The published tarball shrinks accordingly (Angular drops9.0.x~193 KB +15.1.x~500 KB).ApiDocLoader.parseLlmsFullTxtpicks the latest version when iterating, so older snapshots leaking onto disk locally cannot mask newer data.src/lib/version-picker.tsso they agree on what "latest" means. Ranking: literallatest> parsable<major>.<minor|x>.<patch|x>(numeric descending,xoutranks any concrete number) > lex fallback.CI changes (
.github/workflows/npm-publish.yml).actions/checkoutandactions/setup-nodeto@v4.Build MCP API docsstep that runsbuild:docs:allso the tarball contains freshllms-full.txtfiles at publish time.secrets.CLASSIC_PAT_GITHUBso the inlinegit submodule update --init blazor/api-docscan authenticate to the privateIgniteUI/api-docssubmodule.scripts/patch-api-docs-overrides.tsthat pins@astrojs/sitemap@^3.7.2andzod@^4.3.6in the submodule'spackage.jsonbefore itsnpm install— works around an upstream Astroz.function(...).optional is not a functionruntime error.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)npm run build)npm run lint)Additional Context
src/__tests__/lib/version-picker.test.ts(12 cases — semver ordering,latestprecedence,xin minor and patch slots, empty-input throw, input-not-mutated) and a regression test insrc/__tests__/lib/api-doc-loader.test.tsfor the multi-version scenario.npm pack --dry-runinpackages/igniteui-mcp/igniteui-doc-mcp/now listsdocs/*-api/**/llms-full.txtentries (was zero before thefilesfix).CLASSIC_PAT_GITHUBrepo secret withreposcope on theIgniteUIorg is required for the workflow to clone the privateIgniteUI/api-docssubmodule. Token expiration will cause future releases to fail until rotated — long term, consider migrating to a GitHub App so this isn't a recurring concern.