Skip to main content
Glama
IBM

IBM i MCP Server

Official
by IBM
registration.ts2.41 kB
/** * @fileoverview Handles registration of the `fetch_image_test` tool. * This module acts as the "handler" layer, connecting the pure business logic to the * MCP server and ensuring all outcomes (success or failure) are handled gracefully. * @module src/mcp-server/tools/imageTest/registration **/ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { JsonRpcErrorCode } from "@/types-global/errors.js"; import { ErrorHandler, requestContextService } from "@/utils/index.js"; import { logOperationStart, logOperationSuccess, } from "@/utils/internal/logging-helpers.js"; import { createToolHandler, ResponseFormatter, } from "@/mcp-server/tools/utils/tool-utils.js"; import { FetchImageTestInputSchema, fetchImageTestLogic, FetchImageTestResponse, FetchImageTestResponseSchema, } from "./logic.js"; const TOOL_NAME = "fetch_image_test"; const TOOL_DESCRIPTION = "Fetches a random cat image from an external API (cataas.com) and returns it as a blob. Useful for testing image handling capabilities."; const responseFormatter: ResponseFormatter<FetchImageTestResponse> = ( result, ) => ({ structuredContent: result, content: [ { type: "image", data: result.data, mimeType: result.mimeType, }, ], }); export const registerFetchImageTestTool = async ( server: McpServer, ): Promise<void> => { const registrationContext = requestContextService.createRequestContext({ operation: "RegisterTool", toolName: TOOL_NAME, }); logOperationStart(registrationContext, `Registering tool: '${TOOL_NAME}'`); await ErrorHandler.tryCatch( async () => { server.registerTool( TOOL_NAME, { title: "Fetch Cat Image", description: TOOL_DESCRIPTION, inputSchema: FetchImageTestInputSchema.shape, outputSchema: FetchImageTestResponseSchema.shape, annotations: { readOnlyHint: true, openWorldHint: true, }, }, createToolHandler(TOOL_NAME, fetchImageTestLogic, responseFormatter), ); logOperationSuccess( registrationContext, `Tool '${TOOL_NAME}' registered successfully.`, ); }, { operation: `RegisteringTool_${TOOL_NAME}`, context: registrationContext, errorCode: JsonRpcErrorCode.InitializationFailed, critical: true, }, ); };

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/IBM/ibmi-mcp-server'

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