Skip to main content
Glama

actors-mcp-server

Official
by apify
tool-status.ts1.22 kB
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js'; import { TOOL_STATUS } from '../const.js'; import type { ToolStatus } from '../types.js'; import { getHttpStatusCode } from './logging.js'; /** * Central helper to classify an error into a ToolStatus value. * * - TOOL_STATUS.ABORTED → Request was explicitly aborted by the client. * - TOOL_STATUS.SOFT_FAIL → User/client errors (HTTP 4xx, InvalidParams, validation issues). * - TOOL_STATUS.FAILED → Server errors (HTTP 5xx, unknown, or unexpected exceptions). */ export function getToolStatusFromError(error: unknown, isAborted: boolean): ToolStatus { if (isAborted) { return TOOL_STATUS.ABORTED; } const statusCode = getHttpStatusCode(error); // HTTP client errors (4xx) are treated as user errors if (statusCode !== undefined && statusCode >= 400 && statusCode < 500) { return TOOL_STATUS.SOFT_FAIL; } // MCP InvalidParams errors are also user errors if (error instanceof McpError && error.code === ErrorCode.InvalidParams) { return TOOL_STATUS.SOFT_FAIL; } // Everything else is considered a server / unexpected failure return TOOL_STATUS.FAILED; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/apify/actors-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server