diff --git a/tools/server/webui/src/lib/clients/mcp.client.ts b/tools/server/webui/src/lib/clients/mcp.client.ts index e2e50d57ee..7144d73cc2 100644 --- a/tools/server/webui/src/lib/clients/mcp.client.ts +++ b/tools/server/webui/src/lib/clients/mcp.client.ts @@ -48,7 +48,6 @@ import type { import type { ListChangedHandlers } from '@modelcontextprotocol/sdk/types.js'; import { MCPConnectionPhase, MCPLogLevel, HealthCheckStatus } from '$lib/enums'; import type { McpServerOverride } from '$lib/types/database'; -import { MCPError } from '$lib/errors'; import { detectMcpTransportFromUrl } from '$lib/utils'; import { config } from '$lib/stores/settings.svelte'; import { DEFAULT_MCP_CONFIG, MCP_SERVER_ID_PREFIX } from '$lib/constants/mcp'; @@ -754,12 +753,12 @@ export class MCPClient { const serverName = this.toolsIndex.get(toolName); if (!serverName) { - throw new MCPError(`Unknown tool: ${toolName}`, -32601); + throw new Error(`Unknown tool: ${toolName}`); } const connection = this.connections.get(serverName); if (!connection) { - throw new MCPError(`Server "${serverName}" is not connected`, -32000); + throw new Error(`Server "${serverName}" is not connected`); } const args = this.parseToolArguments(toolCall.function.arguments); @@ -781,12 +780,12 @@ export class MCPClient { ): Promise { const serverName = this.toolsIndex.get(toolName); if (!serverName) { - throw new MCPError(`Unknown tool: ${toolName}`, -32601); + throw new Error(`Unknown tool: ${toolName}`); } const connection = this.connections.get(serverName); if (!connection) { - throw new MCPError(`Server "${serverName}" is not connected`, -32000); + throw new Error(`Server "${serverName}" is not connected`); } return MCPService.callTool(connection, { name: toolName, arguments: args }, signal); @@ -802,20 +801,13 @@ export class MCPClient { try { const parsed = JSON.parse(trimmed); if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) { - throw new MCPError( - `Tool arguments must be an object, got ${Array.isArray(parsed) ? 'array' : typeof parsed}`, - -32602 + throw new Error( + `Tool arguments must be an object, got ${Array.isArray(parsed) ? 'array' : typeof parsed}` ); } return parsed as Record; } catch (error) { - if (error instanceof MCPError) { - throw error; - } - throw new MCPError( - `Failed to parse tool arguments as JSON: ${(error as Error).message}`, - -32700 - ); + throw new Error(`Failed to parse tool arguments as JSON: ${(error as Error).message}`); } } @@ -823,7 +815,7 @@ export class MCPClient { return args; } - throw new MCPError(`Invalid tool arguments type: ${typeof args}`, -32602); + throw new Error(`Invalid tool arguments type: ${typeof args}`); } /** diff --git a/tools/server/webui/src/lib/errors/index.ts b/tools/server/webui/src/lib/errors/index.ts deleted file mode 100644 index d19f14cced..0000000000 --- a/tools/server/webui/src/lib/errors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { MCPError } from './mcp'; diff --git a/tools/server/webui/src/lib/errors/mcp.ts b/tools/server/webui/src/lib/errors/mcp.ts deleted file mode 100644 index 0de8b640d5..0000000000 --- a/tools/server/webui/src/lib/errors/mcp.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * MCP-specific error class with error code and optional data. - */ -export class MCPError extends Error { - code: number; - data?: unknown; - - constructor(message: string, code: number, data?: unknown) { - super(message); - this.name = 'MCPError'; - this.code = code; - this.data = data; - } -} diff --git a/tools/server/webui/src/lib/services/mcp.service.ts b/tools/server/webui/src/lib/services/mcp.service.ts index 51226f5f9d..0be4c98787 100644 --- a/tools/server/webui/src/lib/services/mcp.service.ts +++ b/tools/server/webui/src/lib/services/mcp.service.ts @@ -36,7 +36,6 @@ import type { MCPServerInfo } from '$lib/types'; import { MCPConnectionPhase, MCPLogLevel, MCPTransportType } from '$lib/enums'; -import { MCPError } from '$lib/errors'; import { DEFAULT_MCP_CONFIG } from '$lib/constants/mcp'; interface ToolResultContentItem { @@ -365,7 +364,7 @@ export class MCPService { const message = error instanceof Error ? error.message : String(error); - throw new MCPError(`Tool execution failed: ${message}`, -32603); + throw new Error(`Tool execution failed: ${message}`); } }