Skip to main content
Glama

SystemPrompt MCP Notion Server

tool-validation.test.ts2.76 kB
import { jest, describe, it, expect } from "@jest/globals"; import { validateToolRequest, getToolSchema } from "../tool-validation.js"; import { NOTION_TOOLS, TOOL_ERROR_MESSAGES } from "../../constants/tools.js"; import type { CallToolRequest } from "@modelcontextprotocol/sdk/types.js"; import type { NotionTool } from "../../types/tool-schemas.js"; // Mock validation module jest.mock("../validation.js", () => ({ validateWithErrors: jest.fn(), })); describe("Tool Validation", () => { beforeEach(() => { jest.clearAllMocks(); }); describe("validateToolRequest", () => { it("should throw error for missing tool name", () => { const request = { method: "tools/call", params: {}, } as CallToolRequest; expect(() => validateToolRequest(request)).toThrow( "Invalid tool request: missing tool name" ); }); it("should throw error for unknown tool", () => { const request = { method: "tools/call", params: { name: "unknown_tool", arguments: {}, }, } as CallToolRequest; expect(() => validateToolRequest(request)).toThrow( `${TOOL_ERROR_MESSAGES.UNKNOWN_TOOL} unknown_tool` ); }); it("should validate tool with schema", () => { const request = { method: "tools/call", params: { name: "systemprompt_get_notion_page", arguments: { pageId: "123", }, }, } as CallToolRequest; const tool = validateToolRequest(request); expect(tool).toBeDefined(); expect(tool.name).toBe("systemprompt_get_notion_page"); }); it("should handle tool without input validation", () => { // Create a mock tool with empty schema const mockTool: NotionTool = { name: "test_tool", description: "Test tool", inputSchema: { type: "object" as const, properties: {}, additionalProperties: false, }, }; jest.spyOn(NOTION_TOOLS, "find").mockReturnValueOnce(mockTool); const request = { method: "tools/call", params: { name: "test_tool", arguments: {}, }, } as CallToolRequest; const tool = validateToolRequest(request); expect(tool).toBeDefined(); expect(tool.name).toBe("test_tool"); }); }); describe("getToolSchema", () => { it("should return schema for valid tool", () => { const schema = getToolSchema("systemprompt_get_notion_page"); expect(schema).toBeDefined(); }); it("should return undefined for unknown tool", () => { const schema = getToolSchema("unknown_tool"); expect(schema).toBeUndefined(); }); }); });

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/Ejb503/systemprompt-mcp-notion'

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