Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp): honor the default JSON Schema dialect
Alfredo Lopez81e494224938
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex eae0e8444..b2d109755 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.321",+ "version": "0.1.322","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.321",+ "version": "0.1.322","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 0d423966a..a4da7d06f 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.321",+ "version": "0.1.322","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/core/adapters/toolRegistryAdapter.ts b/mcp-host/src/core/adapters/toolRegistryAdapter.tsindex 8a27e397d..812acd661 100644--- a/mcp-host/src/core/adapters/toolRegistryAdapter.ts+++ b/mcp-host/src/core/adapters/toolRegistryAdapter.ts@@ -24,8 +24,9 @@ function selectedSchemaValidator(schema: Record<string, unknown>): ValidateFunct// An empty fragment denotes the same JSON Schema meta-schema URI.const dialect =typeof schema.$schema === 'string' ? schema.$schema.replace(/#$/, '') : undefined+ // MCP defines an omitted $schema as JSON Schema 2020-12.const Constructor =- dialect === 'https://json-schema.org/draft/2020-12/schema'+ dialect === undefined || dialect === 'https://json-schema.org/draft/2020-12/schema'? Ajv2020: dialect === 'https://json-schema.org/draft/2019-09/schema'? Ajv2019diff --git a/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts b/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.tsindex eb4ffa9ee..248015392 100644--- a/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts+++ b/mcp-host/src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts@@ -1,5 +1,5 @@import { afterEach, describe, expect, it, vi } from 'vitest'-import Ajv from 'ajv'+import Ajv2020 from 'ajv/dist/2020'import { TaskExecutor, type TaskExecutorDeps } from '../../../agent/taskExecutor'import { config as appConfig } from '../../../config'import { TaskLifecycle } from '../../../lifecycle/taskLifecycle'@@ -289,7 +289,7 @@ describe('approved catalog across presentation and lifecycle', () => {it.each([83, 250])('compiles only the selected schema out of %i and reuses validation without mutating arguments',async count => {- const compile = vi.spyOn(Ajv.prototype, 'compile')+ const compile = vi.spyOn(Ajv2020.prototype, 'compile')try {const { manager, registry, config } = await setup(count)const target = 'alpha__record__read_000'@@ -373,6 +373,48 @@ describe('approved catalog across presentation and lifecycle', () => {expect(remote.calls).toHaveBeenCalledTimes(1)})+ for (const mode of ['direct', 'discovery'] as const) {+ it.each(['default', '2020-12', 'draft-07'] as const)(+ `${mode}: validates tuple arguments using the declared or MCP-default dialect: %s`,+ async dialect => {+ const { manager, registry, config } = await setup()+ const target = 'alpha__record__read_000'+ const tuple =+ dialect === 'draft-07'+ ? { items: [{ type: 'string' }], additionalItems: false }+ : { prefixItems: [{ type: 'string' }], items: false }+ remote.catalogs.get('alpha')![0].inputSchema = {+ ...(dialect === 'default'+ ? {}+ : {+ $schema:+ dialect === 'draft-07'+ ? 'http://json-schema.org/draft-07/schema#'+ : 'https://json-schema.org/draft/2020-12/schema',+ }),+ type: 'object',+ properties: { tuple: { type: 'array', ...tuple, minItems: 1 } },+ required: ['tuple'],+ additionalProperties: false,+ }+ await manager.replaceServer(serverInfo('alpha'))+ registry.listDefinitions()+ const call = (id: string, args: Record<string, unknown>): ToolCall =>+ mode === 'direct' ? { id, name: target, arguments: args } : bridgeCall(target, id, args)+ const valid = { tuple: ['example'] }+ const accepted = await executeToolCalls([call('valid-tuple', valid)], config, 0)+ expect(accepted.toolResults[0].is_error).toBe(false)+ expect(valid).toEqual({ tuple: ['example'] })+ expect(remote.calls).toHaveBeenCalledTimes(1)+ for (const args of [{ tuple: [] }, { tuple: [1] }, { tuple: ['a', 'b'] }]) {+ const rejected = await executeToolCalls([call('invalid-tuple', args)], config, 1)+ expect(rejected.toolResults[0].is_error).toBe(true)+ expect(remote.calls).toHaveBeenCalledTimes(1)+ }+ }+ )+ }+it('a captured adapter rechecks an in-place changed schema immediately before execution', async () => {const { manager, registry } = await setup()const target = 'alpha__record__read_000'