From 457a714114315e15cc8018c0642206b98a53e649 Mon Sep 17 00:00:00 2001 From: King Star Date: Sat, 27 Jun 2026 15:13:06 +0800 Subject: [PATCH] fix: add default schemas for mcpb tools --- src/commands/__tests__/deploy.test.ts | 8 +++++- src/lib/__tests__/mcpb/mcpb.test.ts | 37 +++++++++++++++++++++++++++ src/lib/mcpb.ts | 14 +++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/commands/__tests__/deploy.test.ts b/src/commands/__tests__/deploy.test.ts index ffeefb50..5f1b72a0 100644 --- a/src/commands/__tests__/deploy.test.ts +++ b/src/commands/__tests__/deploy.test.ts @@ -523,7 +523,13 @@ describe("deploy command", () => { name: "test-bundle", version: "1.2.3", }, - tools: [{ name: "ping", description: "Ping" }], + tools: [ + { + name: "ping", + description: "Ping", + inputSchema: { type: "object" }, + }, + ], prompts: [{ name: "draft", text: "Hello" }], resources: [{ name: "docs", uri: "file:///docs" }], }, diff --git a/src/lib/__tests__/mcpb/mcpb.test.ts b/src/lib/__tests__/mcpb/mcpb.test.ts index 05161986..f8fcefeb 100644 --- a/src/lib/__tests__/mcpb/mcpb.test.ts +++ b/src/lib/__tests__/mcpb/mcpb.test.ts @@ -2,13 +2,22 @@ import { mkdtempSync } from "node:fs" import { rm, writeFile } from "node:fs/promises" import { tmpdir } from "node:os" import { join } from "node:path" +import { strToU8, zipSync } from "fflate" import { afterEach, beforeEach, describe, expect, it } from "vitest" import { getBundleCommand, + getBundleDeployPayload, getHydratedBundleCommand, hydrateBundleCommand, } from "../../mcpb.js" +function createBundleBuffer(manifest: unknown): Buffer { + const zip = zipSync({ + "manifest.json": strToU8(JSON.stringify(manifest)), + }) + return Buffer.from(zip.buffer, zip.byteOffset, zip.byteLength) +} + describe("Bundle Manager End-to-End", () => { let tempDir: string @@ -116,4 +125,32 @@ describe("Bundle Manager End-to-End", () => { LOG_FILE: `${tempDir}/logs/app.log`, }) }) + + it("should add default input schemas to MCPB tools for deploy payloads", async () => { + const bundlePath = join(tempDir, "server.mcpb") + await writeFile( + bundlePath, + createBundleBuffer({ + name: "tool-bundle", + version: "1.0.0", + server: { + type: "node", + mcp_config: { + command: "node", + }, + }, + tools: [{ name: "ping", description: "Ping" }], + }), + ) + + const payload = getBundleDeployPayload(bundlePath) + + expect(payload.serverCard!.tools).toEqual([ + { + name: "ping", + description: "Ping", + inputSchema: { type: "object" }, + }, + ]) + }) }) diff --git a/src/lib/mcpb.ts b/src/lib/mcpb.ts index b323581d..6f79da45 100644 --- a/src/lib/mcpb.ts +++ b/src/lib/mcpb.ts @@ -659,6 +659,18 @@ interface BundleManifest { user_config?: Record> } +function getBundleDeployTools( + tools: NonNullable, +): ServerCard["tools"] { + return tools.map((tool) => ({ + name: tool.name as string, + ...(typeof tool.description === "string" + ? { description: tool.description } + : {}), + inputSchema: { type: "object" }, + })) +} + function readBundleArchive(bundlePath: string) { const { size } = fs.statSync(bundlePath) if (size > MAX_BUNDLE_SIZE_BYTES) { @@ -757,7 +769,7 @@ export function getBundleDeployPayload(bundlePath: string): StdioDeployPayload { version: manifest.version, }, ...(manifest.tools - ? { tools: manifest.tools as unknown as ServerCard["tools"] } + ? { tools: getBundleDeployTools(manifest.tools) } : {}), ...(manifest.prompts ? { prompts: manifest.prompts } : {}), ...(manifest.resources ? { resources: manifest.resources } : {}),