Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(mcp): refuse an IPv6 zone id in schemars' `ip` format
Fabio Nunes Cerqueirac78f8017db8e
diff --git a/server/mcp-schema-validator.test.ts b/server/mcp-schema-validator.test.tsindex 748233b13f..9d887f7f45 100644--- a/server/mcp-schema-validator.test.ts+++ b/server/mcp-schema-validator.test.ts@@ -33,6 +33,11 @@ describe("compileToolSchema", () => {expect(["256.1.1.1", "example.com", "192.168.0.1/24", ""].map((host) => validate({ host }))).toEqual([false, false, false, false]);});+ it("refuses an IPv6 zone id in `ip`, which Rust's IpAddr does not parse", () => {+ const validate = compileToolSchema({ type: "object", properties: { host: { type: "string", format: "ip" } } });+ expect(["fe80::1%eth0", "fe80::1%1"].map((host) => validate({ host }))).toEqual([false, false]);+ });+it("still refuses a format it does not know", () => {expect(() => compileToolSchema({ type: "object", properties: { x: { type: "string", format: "made-up" } } })).toThrow("could not be validated");});diff --git a/server/mcp-schema-validator.ts b/server/mcp-schema-validator.tsindex 013165e1b8..c9a73bf144 100644--- a/server/mcp-schema-validator.ts+++ b/server/mcp-schema-validator.ts@@ -47,8 +47,9 @@ export function compileToolSchema(schema: Record<string, unknown>, options: { al// Google's remote MCP servers (Maps, Gmail, Drive) annotate enums with per-value descriptions; it adds no constraint to check.compiler.addKeyword({ keyword: "x-google-enum-descriptions", schemaType: "array" });for (const [format, min, max] of INTEGER_FORMATS) compiler.addFormat(format, { type: "number", validate: value => Number.isInteger(value) && value >= min && value <= max });- // schemars writes `ip` for Rust's IpAddr (Ipv4Addr/Ipv6Addr get ajv-formats' ipv4/ipv6): either family.- compiler.addFormat("ip", { type: "string", validate: value => isIP(value) !== 0 });+ // schemars writes `ip` for Rust's IpAddr (Ipv4Addr/Ipv6Addr get ajv-formats' ipv4/ipv6): either family. IpAddr has+ // no zone id (`fe80::1%eth0`), which node's isIP accepts.+ compiler.addFormat("ip", { type: "string", validate: value => isIP(value) !== 0 && !value.includes("%") });try { return compiler.compile(schema); }catch { throw new Error("MCP tool schema could not be validated; check its constraints, formats, and references"); }}