ping
Check server health and verify Storyblok API connectivity.
Instructions
Checks server health and Storyblok API connectivity.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/ping.ts:9-47 (handler)The ping tool handler function. Registers a tool named 'ping' on the MCP server. When invoked, it performs a health check by calling the Storyblok Management API endpoint (mapi.storyblok.com) with the management token. Returns success if the API is reachable, or an error response with details if not.
export function registerPing(server: McpServer): void { server.tool( 'ping', 'Checks server health and Storyblok API connectivity.', {}, async () => { try { const url = `https://mapi.storyblok.com/?token=${cfg.managementToken}`; const response = await fetch(url); if (response.ok) { return { content: [ { type: 'text' as const, text: 'Server is running and Storyblok API is reachable.', }, ], }; } else { const errorBody = await response.text(); return { isError: true, errorCode: 'STORYBLOK_API_ERROR', errorMessage: `Storyblok API returned an error. Details: Status: ${response.status} ${response.statusText}, Body: ${errorBody}`, content: [ { type: 'text' as const, text: `Error: STORYBLOK_API_ERROR - Storyblok API returned an error. Details: Status: ${response.status} ${response.statusText}, Body: ${errorBody}`, }, ], }; } } catch (error) { return createErrorResponse(error); } } ); } - src/tools/ping.ts:13-13 (schema)The ping tool has no input parameters (empty schema object {}) since it's a simple health check.
{}, - src/tools/index.ts:44-44 (registration)Registration call: registerPing(server) is called within registerAllTools() to register the ping tool with the MCP server.
registerPing(server); - src/tools/ping.ts:7-7 (helper)Imports createErrorResponse from '../utils/response.js' as a helper for formatting error responses in the ping handler.
import { createErrorResponse } from '../utils/response.js';