diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e2ef2e7848..749ce31e0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Added `outputSchema` support for local MCP tools. - Added `appcheck:providers:list`, `appcheck:providers:get` and `appcheck:providers:set` to configure App Check attestation providers for an app. - Added `appcheck:apps:list` to show every app with its configured App Check providers. - Added web app support for Crashlytics MCP tools and prompts. diff --git a/src/mcp/onemcp/onemcp_server.spec.ts b/src/mcp/onemcp/onemcp_server.spec.ts index 5f82b1d9145..19ce8e9b66f 100644 --- a/src/mcp/onemcp/onemcp_server.spec.ts +++ b/src/mcp/onemcp/onemcp_server.spec.ts @@ -33,6 +33,7 @@ describe("OneMcpServer", () => { name: "test_tool", description: "A test tool", inputSchema: { type: "object", properties: {} }, + outputSchema: { type: "object", properties: { status: { type: "string" } } }, }; clientRequestStub.resolves({ body: { @@ -47,6 +48,7 @@ describe("OneMcpServer", () => { expect(tools).to.have.length(1); expect(tools[0].mcp.name).to.equal("auth_test_tool"); expect(tools[0].mcp.description).to.equal(mockMcpTool.description); + expect(tools[0].mcp.outputSchema).to.deep.equal(mockMcpTool.outputSchema); expect(tools[0].mcp._meta).to.deep.equal({ requiresAuth: false, requiresProject: true, diff --git a/src/mcp/tool.spec.ts b/src/mcp/tool.spec.ts index 5e4457cf9d8..eb3f2cb8653 100644 --- a/src/mcp/tool.spec.ts +++ b/src/mcp/tool.spec.ts @@ -33,12 +33,15 @@ describe("tool", () => { name: "test_tool", description: "A test tool", inputSchema: z.object({}), + outputSchema: z.object({ result: z.string() }), }, testFn, ); expect(testTool.mcp.name).to.equal("test_tool"); expect(testTool.mcp.description).to.equal("A test tool"); + expect(testTool.mcp.outputSchema).to.not.be.undefined; + expect(testTool.mcp.outputSchema.properties.result.type).to.equal("string"); expect(testTool.fn).to.equal(testFn); }); diff --git a/src/mcp/tool.ts b/src/mcp/tool.ts index 99af0298d8e..1cef8f58cbb 100644 --- a/src/mcp/tool.ts +++ b/src/mcp/tool.ts @@ -24,6 +24,7 @@ export interface ServerTool { name: string; description?: string; inputSchema: any; + outputSchema?: any; annotations?: { title?: string; @@ -47,10 +48,11 @@ export interface ServerTool { isAvailable: (ctx: McpContext) => Promise; } -export function tool( +export function tool( feature: ServerFeature, - options: Omit["mcp"], "inputSchema"> & { + options: Omit["mcp"], "inputSchema" | "outputSchema"> & { inputSchema: InputSchema; + outputSchema?: OutputSchema; isAvailable?: (ctx: McpContext) => Promise; }, fn: ServerTool["fn"], @@ -63,6 +65,13 @@ export function tool( inputSchema: cleanSchema( z.toJSONSchema(options.inputSchema, { target: "draft-7", io: "input" }), ), + ...(options.outputSchema + ? { + outputSchema: cleanSchema( + z.toJSONSchema(options.outputSchema, { target: "draft-7", io: "output" }), + ), + } + : {}), }, fn, isAvailable: (ctx: McpContext) => {