Skip to main content
Glama

hypertool-mcp

base.test.tsโ€ข5.14 kB
/** * Tests for the configuration transformers */ import { describe, it, expect } from "vitest"; import { StandardTransformer } from "./base.js"; describe("StandardTransformer", () => { const transformer = new StandardTransformer(); describe("validation", () => { it("should validate stdio transport with command", () => { const config = { mcpServers: { "test-server": { type: "stdio", command: "test-command", args: ["arg1", "arg2"], }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(true); expect(result.errors).toBeUndefined(); }); it("should validate sse transport with url", () => { const config = { mcpServers: { context7: { type: "sse", url: "https://mcp.context7.com/sse", }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(true); expect(result.errors).toBeUndefined(); }); it("should validate http transport with url", () => { const config = { mcpServers: { "http-server": { type: "http", url: "https://example.com/mcp", }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(true); expect(result.errors).toBeUndefined(); }); it("should reject stdio transport without command", () => { const config = { mcpServers: { "test-server": { type: "stdio", url: "https://example.com", // Wrong field }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(false); expect(result.errors).toContain( "Server \"test-server\" with type 'stdio' missing required field: command" ); }); it("should reject sse transport without url", () => { const config = { mcpServers: { "sse-server": { type: "sse", command: "some-command", // Wrong field }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(false); expect(result.errors).toContain( "Server \"sse-server\" with type 'sse' missing required field: url" ); }); it("should warn about command field in http/sse transport", () => { const config = { mcpServers: { "mixed-server": { type: "sse", url: "https://example.com/sse", command: "unnecessary-command", // This should generate a warning }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(true); // Still valid, just warning expect(result.warnings).toContain( "Server \"mixed-server\" with type 'sse' should use 'url' instead of 'command'" ); }); it("should reject invalid transport type", () => { const config = { mcpServers: { "bad-server": { type: "invalid-type", command: "test", }, }, }; const result = transformer.validate(config); expect(result.valid).toBe(false); expect(result.errors).toContain( 'Server "bad-server" has invalid type: invalid-type' ); }); }); describe("toStandard", () => { it("should pass through standard format", () => { const config = { mcpServers: { test: { type: "stdio", command: "test", }, }, }; const result = transformer.toStandard(config); expect(result).toEqual(config); }); it("should wrap bare server objects", () => { const bareConfig = { server1: { type: "stdio", command: "cmd1", }, server2: { type: "sse", url: "https://example.com", }, }; const result = transformer.toStandard(bareConfig); expect(result.mcpServers).toEqual(bareConfig); }); }); describe("fromStandard", () => { it("should pass through standard format without existingConfig", () => { const config = { mcpServers: { test: { type: "stdio" as const, command: "test", }, }, }; const result = transformer.fromStandard(config); expect(result).toEqual(config); }); it("should pass through standard format with existingConfig (ignored)", () => { const config = { mcpServers: { test: { type: "stdio" as const, command: "test", }, }, }; const existingConfig = { someField: "should-be-ignored", mcpServers: { old: { type: "stdio", command: "old", }, }, }; const result = transformer.fromStandard(config, existingConfig); // StandardTransformer ignores existingConfig expect(result).toEqual(config); }); }); });

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/toolprint/hypertool-mcp'

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