Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/igniteui-mcp/igniteui-doc-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Every tool is scoped to a single framework — `angular`, `react`, `blazor`, or
| Tool | Parameters | Description |
|------|-----------|-------------|
| `list_components` | `framework` (required), `filter`, `group`, `detail` | Browse the component doc index, grouped by the published documentation table of contents. By default returns a compact index — one heading per group with a short summary and its doc names. `group` (a heading exactly as printed, e.g. `Grids & Lists > Data Grid`) returns that group's docs with summaries; in grouped mode, `filter` is a case-insensitive substring match against filename, component name, keywords, summary, and group name; `detail: "docs"` returns the flat per-doc list with every summary (much larger), where `filter` does not match group names. No pagination. |
| `get_doc` | `framework` (required), `name` (required) | Return the full markdown content of one component doc by name, kebab-case without `.md` (e.g. `grid-editing`, `accordion`). Bare grid feature names resolve automatically (`sorting` → `grid-sorting`), and common aliases are handled (`virtual-scroll` → `grid-virtualization`). The frontmatter has a `package` line with the package and version of the doc's components in the bundled API reference (e.g. `igniteui-react-grids@19.9`); local mode only. |
| `get_doc` | `framework` (required), `name` (required) | Return the full markdown content of one component doc by name, kebab-case without `.md` (e.g. `grid-editing`, `accordion`). Bare grid feature names resolve automatically (`sorting` → `grid-sorting`), and common aliases are handled (`virtualization` → `grid-virtualization`). The frontmatter has a `package` line with the package and version of the doc's components in the bundled API reference (e.g. `igniteui-react-grids@19.9`); local mode only. |
| `search_docs` | `framework` (required), `query` (required) | Full-text search across the docs for one framework. Returns up to 20 title- and keyword-weighted results with highlighted excerpts. Multi-word queries are implicit AND; trailing `*` does prefix matching (`grid*`); hyphenated terms match as phrases. |
| `search_api` | `query` (required), `platform` | Discover API entries by keyword, feature name, or partial component name. Returns up to 10 ranked results with framework tag, API type, package and version it describes (e.g. `igniteui-react-grids@19.9`), and excerpt. Omit `platform` to search all four frameworks at once. |
| `get_api_reference` | `platform` (required), `component` (required), `section`, `member` | Return the full API reference for an exact component or class name (case-insensitive). Narrow the response with `section` (`properties`, `methods`, `events`, `all` — default `all`) or `member` to fetch a single property/method/event. `member` takes precedence over `section`. Every response starts with a `Package: <name>@<version>` line naming the release the entry was read from, plus an `Also in:` line when other packages ship the same name. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import initSqlJs from 'sql.js';
import { describe, expect, it } from 'vitest';
import {
DOC_ALIASES,
addPackageVersions,
applyCompactGridPrefix,
applyDocAlias,
Expand Down Expand Up @@ -193,12 +197,12 @@ describe('applyDocAlias', () => {
expect(applyDocAlias('angular', 'accordion')).toBe('accordion');
});

it('resolves react combo to overview', () => {
expect(applyDocAlias('react', 'combo')).toBe('overview');
it('resolves react combo to combo-overview', () => {
expect(applyDocAlias('react', 'combo')).toBe('combo-overview');
});

it('resolves react combo-box to overview', () => {
expect(applyDocAlias('react', 'combo-box')).toBe('overview');
it('resolves react combo-box to combo-overview', () => {
expect(applyDocAlias('react', 'combo-box')).toBe('combo-overview');
});

it('resolves react grid to data-grid', () => {
Expand All @@ -209,8 +213,8 @@ describe('applyDocAlias', () => {
expect(applyDocAlias('react', 'hierarchical-grid')).toBe('hierarchical-grid-overview');
});

it('resolves angular combo-box to combo', () => {
expect(applyDocAlias('angular', 'combo-box')).toBe('combo');
it('resolves angular combo-box to combo-overview', () => {
expect(applyDocAlias('angular', 'combo-box')).toBe('combo-overview');
});

it('resolves angular hierarchical-grid correctly', () => {
Expand All @@ -221,8 +225,8 @@ describe('applyDocAlias', () => {
expect(applyDocAlias('angular', 'grid')).toBe('grid-grid');
});

it('resolves webcomponents combo to overview', () => {
expect(applyDocAlias('webcomponents', 'combo')).toBe('overview');
it('resolves webcomponents combo to combo-overview', () => {
expect(applyDocAlias('webcomponents', 'combo')).toBe('combo-overview');
});

it('resolves webcomponents grid to data-grid', () => {
Expand Down Expand Up @@ -251,7 +255,48 @@ describe('applyDocAlias', () => {

it('IgrCombo normalizes then aliases correctly for react', () => {
const normalized = normalizeDocName('IgrCombo');
expect(applyDocAlias('react', normalized)).toBe('overview');
expect(applyDocAlias('react', normalized)).toBe('combo-overview');
});
});

describe('DOC_ALIASES against the bundled database', async () => {
const dbPath = fileURLToPath(new URL('../../../db/igniteui-docs.db', import.meta.url));
const SQL = await initSqlJs();
const db = new SQL.Database(readFileSync(dbPath));
const docNames = (framework: string) =>
new Set(
(db.exec('SELECT filename FROM docs WHERE framework = ?', [framework])[0]?.values ?? []).map((row) =>
String(row[0]).replace(/.md$/, ''),
),
);

for (const [framework, aliases] of Object.entries(DOC_ALIASES)) {
const names = docNames(framework);

it(`${framework}: every alias points to an existing doc`, () => {
const missing = Object.entries(aliases)
.filter(([, target]) => !names.has(target))
.map(([alias, target]) => `${alias} -> ${target}`);
expect(missing).toEqual([]);
});

it(`${framework}: no alias renames an existing doc`, () => {
const shadowing = Object.entries(aliases)
.filter(([alias, target]) => alias !== target && names.has(alias))
.map(([alias, target]) => `${alias} -> ${target}`);
expect(shadowing).toEqual([]);
});
}

it.each(['react', 'webcomponents', 'blazor', 'angular'])('%s: combo names resolve to the Combo doc', (framework) => {
for (const name of ['combo', 'combo-box', 'combobox']) {
expect(applyDocAlias(framework, name)).toBe('combo-overview');
}
const [[tocName]] = db.exec('SELECT toc_name FROM docs WHERE framework = ? AND filename = ?', [
framework,
'combo-overview.md',
])[0].values;
expect(tocName).toBe('Combo');
});
});

Expand All @@ -278,6 +323,20 @@ describe('resolveDoc', () => {
};
}

it('serves a doc with the exact requested name even when an alias exists for it', async () => {
const p = makeProvider({ grid: 'EXACT', 'data-grid': 'ALIASED' });
const r = await resolveDoc(p, 'react', 'grid');
expect(r).toMatchObject({ found: true, servedName: 'grid', text: 'EXACT', fuzzy: false });
});

it('falls back to the alias when no doc has the requested name', async () => {
const p = makeProvider({ overview: 'THEMES', 'combo-overview': 'COMBO' });
for (const name of ['combo', 'IgrCombo', 'combo-box']) {
const r = await resolveDoc(p, 'react', name);
expect(r).toMatchObject({ found: true, servedName: 'combo-overview', text: 'COMBO', fuzzy: false });
}
});

it('resolves a direct name', async () => {
const p = makeProvider({ accordion: 'ACC' });
const r = await resolveDoc(p, 'angular', 'accordion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ No pagination — the full result set is returned in one call.

get_doc: `Retrieve the full markdown content of one specific Ignite UI component doc by its exact name. The name is kebab-case without the .md extension (e.g. "grid-editing", "combo-overview", "accordion").

For grid feature docs, the bare feature name works without the "grid-" prefix — e.g. "sorting" resolves to "grid-sorting", "remote-data-operations" resolves to "grid-remote-data-operations". Common aliases are also handled: "virtualization" → "grid-virtualization", "virtual-scroll" → "grid-virtualization". For completely unknown names, use list_components or search_docs to discover the exact name first.
For grid feature docs, the bare feature name works without the "grid-" prefix — e.g. "sorting" resolves to "grid-sorting", "remote-data-operations" resolves to "grid-remote-data-operations". Common aliases are also handled: "virtualization" → "grid-virtualization", "combo-box" → "combo-overview". For completely unknown names, use list_components or search_docs to discover the exact name first.

Returns YAML frontmatter (component, package, keywords, summary) followed by the complete markdown body with code samples, tables, and links. The \`package\` line (e.g. "igniteui-react-grids@19.9") names the package and release of the doc's components in the bundled API reference; compare it with the version in the project's package.json or .csproj, because an older release may lack what the doc describes. It is omitted when the doc lists no component from the API reference.

Expand Down
67 changes: 36 additions & 31 deletions packages/igniteui-mcp/igniteui-doc-mcp/src/tools/doc-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,22 @@ export function normalizeDocName(name: string): string {
* Per-framework alias maps: normalized kebab-case name → actual doc key.
*
* Covers cases where the doc key cannot be derived mechanically:
* - Combo Box overview is keyed as "overview" not "combo" / "combo-box"
* - Combo Box overview is keyed as "combo-overview" not "combo" / "combo-box"
* - Combo sub-docs use bare generic names: "features", "templates", "single-selection"
* - Grid overview is "grid-grid" or "data-grid", not "grid"
* - Several components append "-overview" or "-chart" suffix
* - "radio" covers both Radio and Radio Group
* - "slider" covers both Slider and Range Slider
*
* An alias applies only when no doc has the requested name (see resolveDoc), and
* every target must name a doc in the bundled database; doc-tools.test.ts checks both.
*/
const DOC_ALIASES: Record<string, Record<string, string>> = {
export const DOC_ALIASES: Record<string, Record<string, string>> = {
react: {
// Combo Box
combo: 'overview',
'combo-box': 'overview',
combobox: 'overview',
'combo-overview': 'overview',
combo: 'combo-overview',
'combo-box': 'combo-overview',
combobox: 'combo-overview',
'combo-features': 'features',
'combobox-features': 'features',
'combo-templates': 'templates',
Expand All @@ -119,27 +121,26 @@ const DOC_ALIASES: Record<string, Record<string, string>> = {
zoomslider: 'zoomslider-overview',
// Virtualization
virtualization: 'grid-virtualization',
'virtual-scroll': 'grid-virtualization',
'virtual-scrolling': 'grid-virtualization',
'virtual-scrolling': 'virtual-scroll',
'grid-performance': 'grid-virtualization',
// Non-obvious renames
treemap: 'treemap-chart',
'radio-group': 'radio',
'radio-and-radio-group': 'radio',
'range-slider': 'slider',
dashboard: 'dashboard-tile',
themes: 'themes-overview',
theme: 'themes-overview',
themes: 'overview',
theme: 'overview',
'geographic-map': 'geo-map',
'geo-map-overview': 'geo-map',
'geographic-map-features': 'geo-map',
// grids/theming-grid moved under grids/grid/ in igniteui-documentation
'theming-grid': 'grid-theming-grid',
'theming-grid': 'grid-theming',
},
angular: {
// Combo Box
'combo-box': 'combo',
combobox: 'combo',
combo: 'combo-overview',
'combo-box': 'combo-overview',
combobox: 'combo-overview',
// Grid types
grid: 'grid-grid',
'hierarchical-grid': 'hierarchicalgrid-hierarchical-grid',
Expand All @@ -150,8 +151,7 @@ const DOC_ALIASES: Record<string, Record<string, string>> = {
zoomslider: 'zoomslider-overview',
// Virtualization — Angular uses different naming convention (hierarchicalgrid-, treegrid-)
virtualization: 'grid-virtualization',
'virtual-scroll': 'grid-virtualization',
'virtual-scrolling': 'grid-virtualization',
'virtual-scrolling': 'virtual-scroll',
'grid-performance': 'grid-virtualization',
'hierarchical-grid-virtualization': 'hierarchicalgrid-virtualization',
'tree-grid-virtualization': 'treegrid-virtualization',
Expand All @@ -164,16 +164,16 @@ const DOC_ALIASES: Record<string, Record<string, string>> = {
'igx-for-of': 'for-of',
// Non-obvious renames
treemap: 'types-treemap-chart',
'radio-group': 'radio-button',
'range-slider': 'slider',
'radio-group': 'radio',
'range-slider': 'slider-slider',
'geographic-map': 'geo-map',
'geo-map-overview': 'geo-map',
},
webcomponents: {
// Combo Box
combo: 'overview',
'combo-box': 'overview',
combobox: 'overview',
combo: 'combo-overview',
'combo-box': 'combo-overview',
combobox: 'combo-overview',
// Grid types
grid: 'data-grid',
'hierarchical-grid': 'hierarchical-grid-overview',
Expand All @@ -185,22 +185,21 @@ const DOC_ALIASES: Record<string, Record<string, string>> = {
zoomslider: 'zoomslider-overview',
// Virtualization
virtualization: 'grid-virtualization',
'virtual-scroll': 'grid-virtualization',
'virtual-scrolling': 'grid-virtualization',
'virtual-scrolling': 'virtual-scroll',
'grid-performance': 'grid-virtualization',
// Non-obvious renames
treemap: 'treemap-chart',
'radio-group': 'radio',
'range-slider': 'slider',
'geographic-map': 'geo-map',
'geo-map-overview': 'geo-map',
'theming-grid': 'grid-theming-grid',
'theming-grid': 'grid-theming',
},
blazor: {
// Combo Box
combo: 'overview',
'combo-box': 'overview',
combobox: 'overview',
combo: 'combo-overview',
'combo-box': 'combo-overview',
combobox: 'combo-overview',
// Grid types
grid: 'data-grid',
'hierarchical-grid': 'hierarchical-grid-overview',
Expand All @@ -219,7 +218,7 @@ const DOC_ALIASES: Record<string, Record<string, string>> = {
'range-slider': 'slider',
'geographic-map': 'geo-map',
'geo-map-overview': 'geo-map',
'theming-grid': 'grid-theming-grid',
'theming-grid': 'grid-theming',
},
};

Expand Down Expand Up @@ -322,7 +321,7 @@ export interface ResolvedDoc {

/**
* Resolve a caller-supplied doc name to actual doc content for get_doc.
* Applies normalizeDocName + applyDocAlias, then the Angular compact grid
* Tries the normalized name as given, then its alias, then the Angular compact grid
* prefix rewrite (tree-grid-x → treegrid-x), then a generic grid- prefix
* fallback for bare feature names (e.g. "sorting" → "grid-sorting").
* As a last resort, runs a full-text search and serves the top hit — this
Expand All @@ -335,8 +334,14 @@ export async function resolveDoc(
framework: string,
name: string,
): Promise<ResolvedDoc> {
const resolvedName = applyDocAlias(framework, normalizeDocName(name.trim()));
let { text, found } = await docsProvider.getDoc(framework, resolvedName);
const normalizedName = normalizeDocName(name.trim());
const aliasedName = applyDocAlias(framework, normalizedName);
let resolvedName = normalizedName;
let { text, found } = await docsProvider.getDoc(framework, normalizedName);
Comment thread
dkalinovInfra marked this conversation as resolved.
Resolved
if (!found && aliasedName !== normalizedName) {
resolvedName = aliasedName;
({ text, found } = await docsProvider.getDoc(framework, aliasedName));
}
let servedName = resolvedName;

if (!found) {
Expand Down