UNPKG

@chinchillaenterprises/mcp-upwork

Version:

Modular Upwork MCP server for job search and proposal management via Upwork API

26 lines 1.39 kB
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; import axios from "axios"; export function handleUpworkError(error) { if (axios.isAxiosError(error)) { const axiosError = error; if (axiosError.response) { const status = axiosError.response.status; const data = axiosError.response.data; switch (status) { case 401: return new McpError(ErrorCode.InvalidRequest, "Authentication failed. Please check your API credentials."); case 403: return new McpError(ErrorCode.InvalidRequest, "Access forbidden. Please check your API permissions."); case 404: return new McpError(ErrorCode.InvalidRequest, "Resource not found."); case 429: return new McpError(ErrorCode.InvalidRequest, "Rate limit exceeded. Please try again later."); default: return new McpError(ErrorCode.InternalError, `Upwork API error: ${data?.message || axiosError.message}`); } } return new McpError(ErrorCode.InternalError, `Network error: ${axiosError.message}`); } return new McpError(ErrorCode.InternalError, `Unexpected error: ${error instanceof Error ? error.message : String(error)}`); } //# sourceMappingURL=error-handler.js.map