Skip to main content
Glama
IBM

IBM i MCP Server

Official
by IBM
logic.test.ts1.99 kB
import { describe, expect, it } from "vitest"; import { EchoToolInputSchema, echoToolLogic, EchoToolResponseSchema, } from "../../../../src/mcp-server/tools/echoTool/logic"; describe("echoToolLogic", () => { it("should return a valid response for valid input", async () => { const mockInput = { message: "hello world", mode: "uppercase" as const, repeat: 2, includeTimestamp: true, }; const result = await echoToolLogic(mockInput); // Validate that the output matches the response schema const validation = EchoToolResponseSchema.safeParse(result); expect(validation.success).toBe(true); if (validation.success) { expect(result.originalMessage).toBe(mockInput.message); expect(result.formattedMessage).toBe("HELLO WORLD"); expect(result.repeatedMessage).toBe("HELLO WORLD HELLO WORLD"); expect(typeof result.timestamp).toBe("string"); } }); it("should handle lowercase mode correctly", async () => { const mockInput = { message: "HELLO WORLD", mode: "lowercase" as const, repeat: 1, includeTimestamp: false, }; const result = await echoToolLogic(mockInput); const validation = EchoToolResponseSchema.safeParse(result); expect(validation.success).toBe(true); if (validation.success) { expect(result.formattedMessage).toBe("hello world"); expect(result.repeatedMessage).toBe("hello world"); expect(result.timestamp).toBeUndefined(); } }); it("should handle empty message correctly based on Zod schema", async () => { // Zod schema min(1) should prevent this from ever reaching the logic function // but we test the principle. The handler would catch this validation error. const input = { message: "", mode: "standard" as const, repeat: 1, includeTimestamp: true, }; const parseResult = EchoToolInputSchema.safeParse(input); expect(parseResult.success).toBe(false); }); });

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