Skip to content

feat: agent-agnostic MCP config — add Cursor support, remove hardcoded template files#1674

Draft
Copilot wants to merge 3 commits intocopilot/update-ai-config-agent-agnosticfrom
copilot/extend-mcp-config-support
Draft

feat: agent-agnostic MCP config — add Cursor support, remove hardcoded template files#1674
Copilot wants to merge 3 commits intocopilot/update-ai-config-agent-agnosticfrom
copilot/extend-mcp-config-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

mcp-config.ts only handled VS Code's .vscode/mcp.json. This PR makes MCP configuration agent-aware (matching the skills/instructions approach from #1664) and removes the static mcp.json files from project templates.

Core changes

mcp-config.ts

  • addMcpServers() gains an optional serversKey param (default "servers") to handle differing root keys per tool
  • New AI_AGENT_MCP_CONFIGS map — associates agent targets with their project-level MCP config path and root key:
    export const AI_AGENT_MCP_CONFIGS = {
      cursor: { path: ".cursor/mcp.json", serversKey: "mcpServers" }
    };
  • New configureMcpForAgents(agents, additionalServers?) — always writes .vscode/mcp.json as the VS Code baseline, additionally writes .cursor/mcp.json (with mcpServers key) when cursor is in the agents list
  • Exports CURSOR_MCP_PATH alongside the existing VS_CODE_MCP_PATH

Call-site updates

  • ai-config.ts: removes configureMCP(), configure() now calls configureMcpForAgents(agents)
  • ng-schematics/cli-config/index.ts: aiConfig() uses configureMcpForAgents(agents, angularCliServer) — writes cursor config when cursor is selected
  • PromptSession.ts: configureAI() uses configureMcpForAgents([])

Template cleanup

Deleted hardcoded __dot__vscode/mcp.json from all three project templates (angular/react/webcomponents) — these are now generated dynamically by the configure() flow. Empty __dot__vscode dirs in react and webcomponents templates removed too.

Tests

  • ai-config-spec.ts: migrated from configureMCP to configureMcpForAgents; added cursor-specific assertions (two writes, correct paths, mcpServers root key)
  • PromptSession-spec.ts: spy updated to mcpConfigModule.configureMcpForAgents via leaf-module require
  • ng-schematics/index_spec.ts: new test verifies .cursor/mcp.json is created with mcpServers key when cursor agent is selected

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.google-analytics.com
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js new --help de_modules/.bin/tsx (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js config --help (dns block)
    • Triggering command: /usr/local/bin/node node packages/cli/bin/execute.js generate --help ui/m�� (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Context

PR #1664 (copilot/update-ai-config-agent-agnostic branch) made ig ai-config agent-agnostic for skills and instruction files. However, the MCP server configuration in packages/core/util/mcp-config.ts still only handles VS Code's .vscode/mcp.json. The hardcoded __dot__vscode/mcp.json files also still exist in project templates.

This PR should extend the MCP configuration logic to support multiple AI tools and remove the static template files.

Requirements

1. Extend mcp-config.ts to support agent-specific MCP config paths and formats

Based on the mcp-setup.md reference file (at packages/igx-templates/igx-ts/projects/ai-config/skills/igniteui-angular-theming/references/mcp-setup.md), different tools use different MCP config files and JSON structures:

Agent MCP config path Root key for servers
VS Code (default, always written) .vscode/mcp.json servers
Cursor .cursor/mcp.json mcpServers

Claude Desktop and WebStorm/JetBrains use global config files (not project-level), so they should NOT be auto-configured by the CLI.

Add to mcp-config.ts:

  • An AI_AGENT_MCP_CONFIGS mapping from AIAgentTarget to { path: string; serversKey: string } (only for agents that use project-level MCP config files: currently vscode-equivalent targets and cursor).
  • A new configureMcpForAgents(agents: AIAgentTarget[], additionalServers?: Record<string, McpServerEntry>): void function that:
    • Always writes .vscode/mcp.json (with servers key) since VS Code is the baseline
    • Also writes .cursor/mcp.json (with mcpServers key) if cursor is in the agents list
    • Uses the existing addMcpServers logic internally, but adapted to handle the different root keys (servers vs mcpServers)
  • Update addMcpServers to accept an optional serversKey parameter (default "servers") so it can handle both servers and mcpServers root keys.

2. Remove hardcoded __dot__vscode/mcp.json from ALL project templates

Delete these files (they will now be generated dynamically by the configure() flow):

  • packages/igx-templates/igx-ts/projects/_base/files/__dot__vscode/mcp.json
  • packages/cli/templates/react/igr-ts/projects/_base/files/__dot__vscode/mcp.json
  • packages/cli/templates/webcomponents/igc-ts/projects/_base/files/__dot__vscode/mcp.json

If the __dot__vscode directories become empty after removing mcp.json, remove the directories too.

3. Update configure() in packages/cli/lib/commands/ai-config.ts

Replace the configureMCP() call (which only does VS Code) with the new configureMcpForAgents(agents, ...) call. The angular-cli additional server should be passed when the project framework is angular.

4. Update schematics in packages/ng-schematics/src/cli-config/index.ts

The aiConfig() function currently calls addMcpServers(VS_CODE_MCP_PATH, angularCliServer) directly. Update it to use the new configureMcpForAgents(agents, angularCliServer) function instead, so the MCP config is also written to .cursor/mcp.json when cursor is selected.

5. Update the configure() call in packages/cli/lib/PromptSession.ts

The configureAI() method currently calls configureMCP(). It should use the new agent-aware MCP configuration. The PromptSession already collects the agents list in start() - pass it through or use the new function.

Also in start(), after process.chdir(projectName), the configure(agents) call should handle MCP config for the selected agents.

6. Adjust/add tests

  • In spec/unit/ai-config-spec.ts: Update tests to verify MCP is configured for selected agents (not just VS Code)
  • In spec/unit/ai-skills-spec.ts or a new spec/unit/mcp-config-spec.ts: Add tests for:
    • configureMcpForAgents writes .vscode/mcp.json always
    • configureMcpForAgents writes .cursor/mcp.json when cursor is in agents
    • .cursor/mcp.json uses mcpServers as root key (not servers)
    • addMcpServers with custom serversKey parameter
  • Update existing tests that reference configureMCP() to use the new pattern

Key implementation notes

  • The addMcpServers function signature should become: addMcpServers(mcpFilePath: string, additionalServers?: Record<string, McpServerEntry>, serversKey?: string): boolean where serversKey defaults to "servers".
  • When creating a new file in addMcpServers, use { [serversKey]: servers } instead of { servers }.
  • When parsing existing files, use parsed[serversKey] ?? {} instead of parsed.servers ?? {}.
  • When modifying with jsonc, use [serversKey, key] path instead of ["servers", key].
  • Export configureMcpForAgents from @igniteui/cli-core barrel.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: The ai-config command, shared logic and schematic now add both skills and agent instructions for the selected AI tool. There's al...

This pull request was created from Copilot chat.

Copilot AI and others added 2 commits April 30, 2026 12:02
…remove hardcoded template files

Agent-Logs-Url: https://github.com/IgniteUI/igniteui-cli/sessions/7a391e28-8cf3-4d80-ab1a-66f2e40b9c66

Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend MCP configuration for multiple AI tools feat: agent-agnostic MCP config — add Cursor support, remove hardcoded template files Apr 30, 2026
Copilot AI requested a review from damyanpetev April 30, 2026 12:07
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.

2 participants