test_gateway
Test a gateway connection by providing its ID. Returns the gateway object with its connection status, such as active on success.
Instructions
Test gateway connection. GET /gateways/{gatewayId}/test. Returns the gateway object with connection status (e.g. status active on success).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gatewayId | Yes | Gateway ID (required) |
Implementation Reference
- src/tools/gateways/testGateway.ts:24-32 (handler)The handler function that executes the test_gateway tool logic. It validates args using a Zod schema (requiring gatewayId), then calls gatewayService.testGateway(client, gatewayId) which performs a GET /gateways/{gatewayId}/test request.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } return handleToolCall(() => gatewayService.testGateway(client, parsed.data.gatewayId) ); } - Zod schema for input validation (gatewayId required string) and the MCP ToolDefinition (name: test_gateway, description, inputSchema with a single required gatewayId string property).
const schema = z.object({ gatewayId: z.string().min(1, "gatewayId is required"), }); const definition = { name: "test_gateway", description: "Test gateway connection. GET /gateways/{gatewayId}/test. Returns the gateway object with connection status (e.g. status active on success).", inputSchema: { type: "object" as const, properties: { gatewayId: { type: "string", description: "Gateway ID (required)" }, }, required: ["gatewayId"], }, }; - src/tools/gateways/index.ts:13-29 (registration)testGatewayTool is imported from './testGateway.js' and included in the registerGatewayTools() array (line 27), which is called from src/tools/index.ts (line 35) via registerGatewayTools() to register all gateway tools.
import { testGatewayTool } from "./testGateway.js"; import { updateGatewayTool } from "./updateGateway.js"; /** All gateway tools. */ export function registerGatewayTools(): Tool[] { return [ listGlobalGatewaysTool, listGatewaysTool, getGatewayTool, getClientTokenTool, createSetupIntentTool, createGatewayTool, updateGatewayTool, deleteGatewayTool, testGatewayTool, ]; } - The underlying service function that performs the actual HTTP GET request to /gateways/{gatewayId}/test to test the gateway connection.
export async function testGateway( client: Client, gatewayId: string ): Promise<unknown> { return client.get<unknown>(`/gateways/${gatewayId}/test`); } - src/tools/gateways/helpers.ts:10-18 (helper)The handleToolCall helper (used by the handler) that wraps the service call in try/catch, returning successResult on success or errorResult on failure.
} export function successResult(data: unknown): ToolResult { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } export async function handleToolCall<T>(fn: () => Promise<T>): Promise<ToolResult> {