Skip to content

Commit bf4f042

Browse files
committed
refactor(@angular/cli): add structured workflows to MCP server instructions
This commit refactors the top-level `instructions` for the MCP server to provide clearer, more structured, and actionable guidance for an AI assistant. Following the best practices for LLM-centric documentation, the new instructions: - Use a structured tag-based format (`<General Purpose>`, `<Core Workflows>`, etc.) to improve parsability. - Establish a mandatory "first step" workflow, instructing the AI to always use the `list_projects` tool to gather context before taking other actions. - Provide a high-level guide to the available tools, mapping them to common user intents (e.g., answering questions, writing code). - Define key domain concepts like "Workspace" vs. "Project" to improve the AI's operational model in a monorepo. This change helps the AI behave more reliably and effectively by providing a strategic framework for how to use the server's tools as a cohesive system.
1 parent b983ea8 commit bf4f042

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

packages/angular/cli/src/commands/mcp/mcp-server.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,34 @@ export async function createMcpServer(
5555
tools: {},
5656
logging: {},
5757
},
58-
instructions:
59-
'For Angular development, this server provides tools to adhere to best practices, search documentation, and find code examples. ' +
60-
'When writing or modifying Angular code, use the MCP server and its tools instead of direct shell commands where possible.',
58+
instructions: `
59+
<General Purpose>
60+
This server provides a safe, programmatic interface to the Angular CLI for an AI assistant.
61+
Your primary goal is to use these tools to understand, analyze, refactor, and run Angular
62+
projects. You MUST prefer the tools provided by this server over using \`run_shell_command\` for
63+
equivalent actions.
64+
</General Purpose>
65+
66+
<Core Workflows & Tool Guide>
67+
* **1. Discover Project Structure (Mandatory First Step):** Always begin by calling
68+
\`list_projects\` to understand the workspace. The outputs from this tool are often
69+
required inputs for other tools.
70+
71+
* **2. Write & Modify Code:** Before writing or changing code, you MUST consult the
72+
\`get_best_practices\` tool to learn the current, non-negotiable coding standards.
73+
74+
* **3. Answer User Questions:**
75+
- For conceptual questions ("what is..."), use \`search_documentation\`.
76+
- For code examples ("show me how to..."), use \`find_examples\`.
77+
</Core Workflows & Tool Guide>
78+
79+
<Key Concepts>
80+
* **Workspace vs. Project:** A 'workspace' contains an \`angular.json\` file and defines 'projects'
81+
(applications or libraries). A monorepo can have multiple workspaces.
82+
* **Targeting Projects:** Always use the \`workspaceConfigPath\` from \`list_projects\` when
83+
available to ensure you are targeting the correct project in a monorepo.
84+
</Key Concepts>
85+
`,
6186
},
6287
);
6388

0 commit comments

Comments
 (0)