pi-mono/packages/mcp/test/input-schema.test.ts
Armin Ronacher 76c040a2ad feat(mcp): shared tool naming, schema, output limit and config helpers
createMcpToolName, mcpNamespace, normalizeMcpInputSchema,
limitMcpContent (with a caller-provided saver) and validation of the
standard mcpServers shape move from coding-agent into pi-mcp, so other
applications name and limit MCP tools exactly like pi. Applications
validate their own fields on the tagged result; coding-agent keeps
exposure, auth.provider and its Client ID Metadata Document rule.
2026-11-03 14:17:21 +01:00

24 lines
826 B
TypeScript

import { describe, expect, it } from "vitest";
import { normalizeMcpInputSchema } from "../src/index.ts";
describe("normalizeMcpInputSchema", () => {
it("adds type object and empty properties when missing", () => {
expect(normalizeMcpInputSchema({})).toEqual({ type: "object", properties: {} });
expect(normalizeMcpInputSchema({ type: "object" })).toEqual({ type: "object", properties: {} });
});
it("keeps the schema's own keywords", () => {
const schema = {
type: "object",
properties: { query: { type: "string" } },
required: ["query"],
additionalProperties: false,
};
expect(normalizeMcpInputSchema(schema)).toEqual(schema);
expect(normalizeMcpInputSchema({ properties: { a: {} }, $defs: { x: {} } })).toEqual({
type: "object",
properties: { a: {} },
$defs: { x: {} },
});
});
});