The best way to control Claude Code, Codex and more from any computer or phone
fix(pi): declare properties on MCP tool schemas that omit them (#21822)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Taissa committed
Oct 21, 2026 at 23:08 UTC
9892aca206279640b17a5453578f9f2b3178800d
3 files changed
+35
-2
packages/provider-pi/src/server/mcpBridge.testkit.ts
+2
-1
@@ -47,6 +47,7 @@ export async function loadMcpBridge(
47
readonly toolSearchDisabled?: boolean;
48
readonly allowsTool?: (name: string) => boolean;
49
readonly runtimeMode?: string;
50
+ readonly inputSchema?: Record<string, unknown>;
51
} = {},
52
) {
53
const handlers = new Map<string, AgentStartHook>();
@@ -75,7 +76,7 @@ export async function loadMcpBridge(
76
{ name: "preview_snapshot", description: "Inspect the collaborative browser." },
77
].map((tool) => ({
78
...tool,
78
- inputSchema: { type: "object", properties: {} },
79
+ inputSchema: options.inputSchema ?? { type: "object", properties: {} },
80
outputSchema: { type: "object", properties: { count: { type: "number" } } },
81
}));
82
const source = NodeModule.stripTypeScriptTypes(
packages/provider-pi/src/server/mcpExtensionSource.test.ts
+26
@@ -238,6 +238,32 @@ describe("Pi MCP tool exposure", () => {
238
);
239
});
240
241
+describe("Pi MCP tool schemas", () => {
242
+ it.each([{ type: "object" }, {}])(
243
+ "declares empty properties on object schemas that omit them: %j",
244
+ async (inputSchema) => {
245
+ const bridge = await loadMcpBridge({ inputSchema });
246
+ assert.isAbove(bridge.tools.length, 0);
247
+ for (const tool of bridge.tools) {
248
+ assert.deepEqual(tool.parameters, { type: "object", properties: {} });
249
+ }
250
+ },
251
+ );
252
+
253
+ it("keeps declared properties and other schema keywords", async () => {
254
+ const inputSchema = {
255
+ type: "object",
256
+ properties: { depth: { type: "number" } },
257
+ required: ["depth"],
258
+ additionalProperties: false,
259
+ };
260
+ const bridge = await loadMcpBridge({ inputSchema });
261
+ for (const tool of bridge.tools) {
262
+ assert.deepEqual(tool.parameters, inputSchema);
263
+ }
264
+ });
265
+});
266
+
267
describe("Pi tool discovery permissions", () => {
268
it.each(["approval-required", "auto-accept-edits", "auto"])(
269
"allows annotated T3 reads in %s while gating mutations and replacements",
packages/provider-pi/src/server/mcpExtensionSource.ts
+7
-1
@@ -91,7 +91,13 @@ function parseSseOrJson(body: string, contentType: string): JsonRpcResponse {
91
function jsonSchemaToTypebox(schema: Record<string, unknown> | undefined) {
92
const unsafe = (Type as { Unsafe?: (value: unknown) => unknown }).Unsafe;
93
if (typeof unsafe === "function" && schema !== undefined) {
94
- return unsafe(schema);
94
+ // Zero-argument MCP tools may omit "properties", which some OpenAI-compatible
95
+ // servers reject. Declare it, as Pi does for its own MCP tools.
96
+ return unsafe({
97
+ ...schema,
98
+ type: schema.type ?? "object",
99
+ ...(schema.properties === undefined ? { properties: {} } : {}),
100
+ });
101
}
102
return Type.Object({}, { additionalProperties: true });
103
}