/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/cli/src/commands/mcp/tools/devserver/devserver-stop.ts
79 строк
3 KB
Herdiyan Adam Putra
fix(@angular/cli): declare devserver_start and devserver_stop as isReadOnly:false
28 июл 2026, 11:01
28 июл 2026, 11:01
1f36380
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { z } from 'zod'; import { createDevServerNotFoundError, getDevserverKey } from '../../devserver'; import { workspaceAndProjectOptions } from '../../shared-options'; import { createStructuredContentOutput } from '../../utils'; import { resolveWorkspaceAndProject } from '../../workspace-utils'; import { type McpToolContext, type McpToolDeclaration, declareTool } from '../tool-registry'; const devserverStopToolInputSchema = z.object({ ...workspaceAndProjectOptions, }); export type DevserverStopToolInput = z.infer<typeof devserverStopToolInputSchema>; const devserverStopToolOutputSchema = z.object({ message: z.string().describe('A message indicating the result of the operation.'), logs: z.array(z.string()).optional().describe('The full logs from the dev server.'), }); export type DevserverStopToolOutput = z.infer<typeof devserverStopToolOutputSchema>; export async function stopDevserver(input: DevserverStopToolInput, context: McpToolContext) { const { workspacePath, projectName } = await resolveWorkspaceAndProject({ host: context.host, server: context.server, workspacePathInput: input.workspace, projectNameInput: input.project, mcpWorkspace: context.workspace, }); const key = getDevserverKey(workspacePath, projectName); const devserver = context.devservers.get(key); if (!devserver) { throw createDevServerNotFoundError(context.devservers); } devserver.stop(); context.devservers.delete(key); return createStructuredContentOutput({ message: `Development server for project '${projectName}' stopped.`, logs: devserver.getServerLogs(), }); } export const DEVSERVER_STOP_TOOL: McpToolDeclaration< typeof devserverStopToolInputSchema.shape, typeof devserverStopToolOutputSchema.shape > = declareTool({ name: 'devserver_stop', title: 'Stop Development Server', description: ` <Purpose> Stops a running Angular development server ("ng serve") that was started with the "devserver_start" tool. </Purpose> <Use Cases> * **Stopping the Server:** Use this tool to terminate a running development server and retrieve the logs. </Use Cases> <Operational Notes> * This should be called to gracefully shut down the server and access the full log output. * This just sends a SIGTERM to the server and returns immediately; so the server might still be functional for a short time after this is called. However note that this is not a blocker for starting a new devserver. </Operational Notes> `, isReadOnly: false, isLocalOnly: true, inputSchema: devserverStopToolInputSchema.shape, outputSchema: devserverStopToolOutputSchema.shape, factory: (context) => (input) => { return stopDevserver(input, context); }, });