CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
mcp-errors.ts66 linesDownload Raw Back to tools
1/**2 * @license3 * Copyright 2025 Google LLC4 * SPDX-License-Identifier: Apache-2.05 */6 7/**8 * T2.8: thrown by `McpClientManager.addRuntimeMcpServer` when adding the9 * server would exceed the workspace MCP budget in `enforce` mode.10 */11export class McpBudgetWouldExceedError extends Error {12  readonly code = 'mcp_budget_would_exceed' as const;13  readonly serverName: string;14  constructor(serverName: string) {15    super(`Adding '${serverName}' would exceed workspace MCP budget`);16    this.name = 'McpBudgetWouldExceedError';17    this.serverName = serverName;18  }19}20 21/**22 * T2.8: thrown by `McpClientManager.addRuntimeMcpServer` when the23 * transport spawn (pool acquire / McpClient connect) fails.24 */25export class McpServerSpawnFailedError extends Error {26  readonly code = 'mcp_server_spawn_failed' as const;27  readonly serverName: string;28  readonly details: {29    exitCode?: number;30    stderr?: string;31    timeout?: boolean;32  };33  constructor(34    serverName: string,35    details: {36      exitCode?: number;37      stderr?: string;38      timeout?: boolean;39    },40  ) {41    super(42      `Failed to spawn MCP server '${serverName}': ${JSON.stringify(details)}`,43    );44    this.name = 'McpServerSpawnFailedError';45    this.serverName = serverName;46    this.details = details;47  }48}49 50/**51 * T2.8: thrown by `McpClientManager.addRuntimeMcpServer` when the52 * provided server config is structurally invalid (e.g. missing both53 * `command` and `url`/`httpUrl`).54 */55export class InvalidMcpConfigError extends Error {56  readonly code = 'invalid_config' as const;57  readonly serverName: string;58  readonly reason: string;59  constructor(serverName: string, reason: string) {60    super(`Invalid MCP server config for '${serverName}': ${reason}`);61    this.name = 'InvalidMcpConfigError';62    this.serverName = serverName;63    this.reason = reason;64  }65}66 
basant307/AI_Governance_Project · CoolFace