Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/commands/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }],
},
Expand Down
37 changes: 37 additions & 0 deletions src/lib/__tests__/mcpb/mcpb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" },
},
])
})
})
14 changes: 13 additions & 1 deletion src/lib/mcpb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,18 @@ interface BundleManifest {
user_config?: Record<string, Partial<McpbUserConfigurationOption>>
}

function getBundleDeployTools(
tools: NonNullable<BundleManifest["tools"]>,
): 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) {
Expand Down Expand Up @@ -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 } : {}),
Expand Down