diff --git a/packages/igniteui-mcp/igniteui-doc-mcp/src/index.ts b/packages/igniteui-mcp/igniteui-doc-mcp/src/index.ts index 689e2e28d..9e54a84e6 100644 --- a/packages/igniteui-mcp/igniteui-doc-mcp/src/index.ts +++ b/packages/igniteui-mcp/igniteui-doc-mcp/src/index.ts @@ -70,7 +70,10 @@ const server = new McpServer( "React → Igr prefix (IgrGrid), package 'igniteui-react', .tsx files. " + "Blazor → Igb prefix (IgbGrid), package 'IgniteUI.Blazor', .razor files. " + "Web Components → Igc prefix + Component suffix (IgcGridComponent), package 'igniteui-webcomponents', .ts+.html with custom elements. " + - "If the framework is unclear from context, ask the user.", + "If the framework is unclear from context, ask the user. " + + "LIBRARY BOUNDARY RULE: Once the target framework is identified, always pass it as the 'framework' or 'platform' parameter to every tool call. " + + "Never apply component APIs, event names, binding syntax, prop names, or state patterns from one framework to code in another framework. " + + "Angular (Igx), React (Igr), Blazor (Igb), and Web Components (Igc) each have distinct APIs — they are not interchangeable.", } ); diff --git a/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/constants.ts b/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/constants.ts index 9318afcda..67d1fb4d4 100644 --- a/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/constants.ts +++ b/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/constants.ts @@ -63,7 +63,7 @@ Use this as the discovery step when the exact component name is unknown — e.g. Each result includes: exact component name, framework tag, API type (class/interface/directive/enum), match count, keyword list, and a content excerpt. Pass the component name and framework from a result to get_api_reference for full details. To reduce response size, use section="properties", "methods", or "events" instead of the default "all". -Omit framework to search all frameworks at once. Maximum query length is 256 characters. +Always specify \`platform\` when your target framework is known — this prevents cross-framework API contamination. Omit only when you explicitly need to compare or search across all frameworks at once. Maximum query length is 256 characters. ` }; @@ -132,6 +132,15 @@ Most tools require a \`framework\` parameter. Determine the framework from the u 4. **User's explicit statement** — "I'm using Angular", "Blazor project", etc. 5. **Ask the user** if none of the above apply +## Library Boundary Rules + +> **These rules are mandatory. Violating them produces code that looks valid but fails at runtime.** + +- **Always pass \`framework\` / \`platform\` to every tool call once the target framework is known.** Do not omit it. +- **Never mix APIs across frameworks.** Angular (\`Igx\`), React (\`Igr\`), Blazor (\`Igb\`), and Web Components (\`Igc\`) each have distinct component names, event shapes, prop names, binding syntax, and state models. They are not interchangeable. +- **Do not apply Angular patterns to React code** (or any other cross-framework combination). For example: Angular template bindings (\`(cellEditDone)\`), directive imports (\`IGX_GRID_DIRECTIVES\`), and signal-based \`viewChild\` are Angular-only. React uses callback props, hook-based state, and \`useRef\`. +- **When \`search_api\` returns results from multiple frameworks, only use entries that match your target framework.** + ## Documentation Tools - **\`search_docs\`** — full-text search when user asks "how do I..." or describes a feature need diff --git a/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/handlers.ts b/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/handlers.ts index f78244389..0ea1ef0a7 100644 --- a/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/handlers.ts +++ b/packages/igniteui-mcp/igniteui-doc-mcp/src/tools/handlers.ts @@ -85,6 +85,11 @@ export function createSearchApiHandler(docLoader: ApiDocLoader) { return `**${h.entry.component}** ${platformTag} ${typeTag} (${h.matches} matches)${kwTag}\n${h.excerpt}`; }); - return { content: [{ type: "text", text: lines.join("\n\n") }] }; + const frameworks = new Set(hits.map(h => h.entry.platform)); + const crossPlatformWarning = !platform && frameworks.size > 1 + ? `⚠ Results span multiple frameworks (${[...frameworks].join(', ')}). Only use entries that match your target framework — never apply APIs, events, or binding syntax from one framework to another.\n\n` + : ''; + + return { content: [{ type: "text", text: crossPlatformWarning + lines.join("\n\n") }] }; }; } \ No newline at end of file