UNPKG

cursor-background-agent-mcp-server

Version:

MCP Server for Cursor Background Agents API - run autonomous coding agents from any MCP client

68 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MCP_ERROR_CODES = exports.MCPErrorImpl = void 0; exports.createMCPErrorResponse = createMCPErrorResponse; exports.getHttpStatusForMCPError = getHttpStatusForMCPError; class MCPErrorImpl extends Error { constructor(code, message, details) { super(message); this.code = code; this.details = details; this.name = 'MCPError'; } } exports.MCPErrorImpl = MCPErrorImpl; exports.MCP_ERROR_CODES = { TOOL_NOT_FOUND: 'TOOL_NOT_FOUND', RESOURCE_NOT_FOUND: 'RESOURCE_NOT_FOUND', INVALID_INPUT: 'INVALID_INPUT', INVALID_OUTPUT: 'INVALID_OUTPUT', SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE', AUTHENTICATION_FAILED: 'AUTHENTICATION_FAILED', RATE_LIMITED: 'RATE_LIMITED', INTERNAL_ERROR: 'INTERNAL_ERROR', TIMEOUT: 'TIMEOUT', }; function createMCPErrorResponse(error) { if (error instanceof MCPErrorImpl || error.code) { const mcpError = error; return { error: { code: mcpError.code, message: mcpError.message, ...(mcpError.details && { details: mcpError.details }) } }; } return { error: { code: exports.MCP_ERROR_CODES.INTERNAL_ERROR, message: error.message || 'An unexpected error occurred' } }; } function getHttpStatusForMCPError(error) { if (!(error instanceof MCPErrorImpl) && !error.code) { return 500; } const mcpError = error; switch (mcpError.code) { case exports.MCP_ERROR_CODES.TOOL_NOT_FOUND: case exports.MCP_ERROR_CODES.RESOURCE_NOT_FOUND: return 404; case exports.MCP_ERROR_CODES.INVALID_INPUT: case exports.MCP_ERROR_CODES.INVALID_OUTPUT: return 400; case exports.MCP_ERROR_CODES.AUTHENTICATION_FAILED: return 401; case exports.MCP_ERROR_CODES.RATE_LIMITED: return 429; case exports.MCP_ERROR_CODES.SERVICE_UNAVAILABLE: return 503; case exports.MCP_ERROR_CODES.TIMEOUT: return 408; default: return 500; } } //# sourceMappingURL=errors.js.map