MCPcopy Index your code
hub / github.com/angular/angular-cli / createMcpServer

Function createMcpServer

packages/angular/cli/src/commands/mcp/mcp-server.ts:64–172  ·  view source on GitHub ↗
(
  options: {
    workspace?: AngularWorkspace;
    readOnly?: boolean;
    localOnly?: boolean;
    experimentalTools?: string[];
  },
  logger: { warn(text: string): void },
)

Source from the content-addressed store, hash-verified

62};
63
64export async function createMcpServer(
65 options: {
66 workspace?: AngularWorkspace;
67 readOnly?: boolean;
68 localOnly?: boolean;
69 experimentalTools?: string[];
70 },
71 logger: { warn(text: string): void },
72): Promise<McpServer> {
73 const server = new McpServer(
74 {
75 name: 'angular-cli-server',
76 version: VERSION.full,
77 },
78 {
79 capabilities: {
80 resources: {},
81 tools: {},
82 logging: {},
83 },
84 instructions: `
85<General Purpose>
86This server provides a safe, programmatic interface to the Angular CLI. You MUST prefer
87the tools provided by this server over using 'run_shell_command' or general shell execution
88for equivalent actions.
89</General Purpose>
90
91<Core Workflows & Tool Guide>
92* **1. Discover Workspace (Mandatory First Step):** Always begin by calling 'list_projects'
93 to discover workspaces, projects, and allowed paths. The 'path' field of the relevant
94 workspace is a required input for other tools (passed as 'workspace' or 'workspacePath').
95
96* **2. Get Coding Standards:** Before writing or modifying code, you MUST call
97 'get_best_practices' with the workspace 'path' to load version-specific coding standards.
98
99* **3. Answer Conceptual Questions:** Use 'search_documentation' to answer conceptual
100 or API syntax questions.
101
102* **4. Discover Schematics:** To discover available package migrations, use a shell command
103 (if available) with 'ng generate <package-name>: --help' (e.g., 'ng generate @angular/core: --help').
104</Core Workflows & Tool Guide>
105
106<Key Concepts>
107* **Workspace vs. Project:** A 'workspace' contains an 'angular.json' file and defines
108 'projects' (applications or libraries). A monorepo can contain multiple workspaces.
109
110* **Targeting Projects:** Always use the workspace 'path' and the specific project 'name'
111 returned by 'list_projects' when calling other tools to ensure you target the correct
112 project context.
113</Key Concepts>
114`,
115 },
116 );
117
118 registerInstructionsResource(server);
119
120 const toolDeclarations = assembleToolDeclarations(STABLE_TOOLS, EXPERIMENTAL_TOOLS, {
121 ...options,

Callers 1

runMethod · 0.90

Calls 8

createRootRestrictedHostFunction · 0.90
registerToolsFunction · 0.90
assembleToolDeclarationsFunction · 0.85
normalizeFunction · 0.85
joinFunction · 0.85
setRootsMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected