惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
L
LangChain Blog
博客园_首页
J
Java Code Geeks
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
WordPress大学
WordPress大学
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
C
Check Point Blog
IT之家
IT之家
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
D
Docker
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
I
InfoQ

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: support draft 2020 mcp tool schemas · openclaw/openc...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -1,8 +1,16 @@

11

import crypto from "node:crypto";

2+

import { createRequire } from "node:module";

23

import { Client } from "@modelcontextprotocol/sdk/client/index.js";

34

import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

45

import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";

56

import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";

7+

import { AjvJsonSchemaValidator } from "@modelcontextprotocol/sdk/validation/ajv-provider.js";

8+

import type {

9+

JsonSchemaType,

10+

JsonSchemaValidator,

11+

jsonSchemaValidator,

12+

} from "@modelcontextprotocol/sdk/validation/types.js";

13+

import type { ErrorObject, ValidateFunction } from "ajv";

614

import type { OpenClawConfig } from "../config/types.openclaw.js";

715

import { logWarn } from "../logger.js";

816

import { resolveGlobalSingleton } from "../shared/global-singleton.js";

@@ -34,7 +42,53 @@ type CreateSessionMcpRuntime = (

3442

params: Parameters<typeof createSessionMcpRuntime>[0] & { configFingerprint?: string },

3543

) => SessionMcpRuntime;

364445+

const require = createRequire(import.meta.url);

3746

const SESSION_MCP_RUNTIME_MANAGER_KEY = Symbol.for("openclaw.sessionMcpRuntimeManager");

47+

const DRAFT_2020_12_SCHEMA = "https://json-schema.org/draft/2020-12/schema";

48+49+

type Ajv2020Like = {

50+

compile: (schema: JsonSchemaType) => ValidateFunction;

51+

errorsText: (errors?: ErrorObject[] | null) => string;

52+

};

53+54+

function isDraft202012Schema(schema: JsonSchemaType): boolean {

55+

return (schema as { $schema?: unknown }).$schema === DRAFT_2020_12_SCHEMA;

56+

}

57+58+

export function createBundleMcpJsonSchemaValidator(): jsonSchemaValidator {

59+

const defaultValidator = new AjvJsonSchemaValidator();

60+

const Ajv2020Ctor = require("ajv/dist/2020") as new (opts?: object) => Ajv2020Like;

61+

const ajv2020 = new Ajv2020Ctor({

62+

strict: false,

63+

validateFormats: false,

64+

validateSchema: false,

65+

allErrors: true,

66+

});

67+68+

return {

69+

getValidator<T>(schema: JsonSchemaType): JsonSchemaValidator<T> {

70+

if (!isDraft202012Schema(schema)) {

71+

return defaultValidator.getValidator<T>(schema);

72+

}

73+

const ajvValidator = ajv2020.compile(schema);

74+

return (input: unknown) => {

75+

const valid = ajvValidator(input);

76+

if (valid) {

77+

return {

78+

valid: true,

79+

data: input as T,

80+

errorMessage: undefined,

81+

};

82+

}

83+

return {

84+

valid: false,

85+

data: undefined,

86+

errorMessage: ajv2020.errorsText(ajvValidator.errors),

87+

};

88+

};

89+

},

90+

};

91+

}

38923993

function connectWithTimeout(

4094

client: Client,

@@ -178,7 +232,9 @@ export function createSessionMcpRuntime(params: {

178232

name: "openclaw-bundle-mcp",

179233

version: "0.0.0",

180234

},

181-

{},

235+

{

236+

jsonSchemaValidator: createBundleMcpJsonSchemaValidator(),

237+

},

182238

);

183239

const session: BundleMcpSession = {

184240

serverName,