From 69ca5b1898902279f99b08afe05f98bb0b244034 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:12:16 +0000 Subject: [PATCH 1/4] Initial plan From fb833d49221ea9ce55fdb389613773d9abba8b55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:16:47 +0000 Subject: [PATCH 2/4] Fix application-create schema validation error with outputSchema support Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com> --- src/http-server.ts | 4 +-- .../tools/application/applicationCreate.ts | 25 +++++++++++++++---- src/mcp/tools/toolFactory.ts | 16 +++++++++--- src/server.ts | 11 +++++++- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/http-server.ts b/src/http-server.ts index d386742..725bfc3 100644 --- a/src/http-server.ts +++ b/src/http-server.ts @@ -62,9 +62,7 @@ export async function main() { // Create and connect server first const server = createServer(); // The transport will have sessionId after initialization - await server.connect( - transport as StreamableHTTPServerTransport & { sessionId: string } - ); + await server.connect(transport as any); // Log after successful connection logger.info("New MCP session server connected", { diff --git a/src/mcp/tools/application/applicationCreate.ts b/src/mcp/tools/application/applicationCreate.ts index 02f262e..aca1b8d 100644 --- a/src/mcp/tools/application/applicationCreate.ts +++ b/src/mcp/tools/application/applicationCreate.ts @@ -1,7 +1,6 @@ import { z } from "zod"; import apiClient from "../../../utils/apiClient.js"; import { createTool } from "../toolFactory.js"; -import { ResponseFormatter } from "../../../utils/responseFormatter.js"; export const applicationCreate = createTool({ name: "application-create", @@ -29,6 +28,11 @@ export const applicationCreate = createTool({ .optional() .describe("The ID of the server where the application will be deployed."), }), + outputSchema: z.object({ + success: z.boolean().describe("Whether the operation was successful"), + message: z.string().describe("A message describing the result"), + data: z.record(z.any()).optional().describe("The application data returned from the API"), + }), annotations: { title: "Create Application", destructiveHint: false, @@ -38,9 +42,20 @@ export const applicationCreate = createTool({ handler: async (input) => { const response = await apiClient.post("/application.create", input); - return ResponseFormatter.success( - `Application "${input.name}" created successfully in environment "${input.environmentId}"`, - response.data - ); + const structuredData = { + success: true, + message: `Application "${input.name}" created successfully in environment "${input.environmentId}"`, + data: response.data, + }; + + return { + content: [ + { + type: "text", + text: JSON.stringify(structuredData, null, 2), + }, + ], + structuredContent: structuredData, + }; }, }); diff --git a/src/mcp/tools/toolFactory.ts b/src/mcp/tools/toolFactory.ts index ceec7f0..780085b 100644 --- a/src/mcp/tools/toolFactory.ts +++ b/src/mcp/tools/toolFactory.ts @@ -11,10 +11,15 @@ export type ToolHandler = (input: T) => Promise<{ // Defines the structure for a tool. // TShape is the ZodRawShape (the object passed to z.object()). -export interface ToolDefinition { +// TOutputShape is the optional output schema ZodRawShape +export interface ToolDefinition< + TShape extends ZodRawShape, + TOutputShape extends ZodRawShape = ZodRawShape +> { name: string; description: string; schema: ZodObject; // The schema must be a ZodObject + outputSchema?: ZodObject; // Optional output schema for validation handler: ToolHandler>>; // Handler input is inferred from the ZodObject annotations?: { title?: string; @@ -39,9 +44,12 @@ export function createToolContext(): ToolContext { }; } -export function createTool( - definition: ToolDefinition -): ToolDefinition { +export function createTool< + TShape extends import("zod").ZodRawShape, + TOutputShape extends import("zod").ZodRawShape = import("zod").ZodRawShape +>( + definition: ToolDefinition +): ToolDefinition { return { ...definition, handler: async (input) => { diff --git a/src/server.ts b/src/server.ts index 1aa357b..cefa7a2 100644 --- a/src/server.ts +++ b/src/server.ts @@ -8,7 +8,16 @@ export function createServer() { }); for (const tool of allTools) { - server.tool(tool.name, tool.description, tool.schema.shape, tool.handler); + server.registerTool( + tool.name, + { + description: tool.description, + inputSchema: tool.schema.shape, + ...(tool.outputSchema && { outputSchema: tool.outputSchema.shape }), + ...(tool.annotations && { annotations: tool.annotations }), + }, + tool.handler + ); } return server; From 99b9b140f0f229c5608b27983bfab390598c4901 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:17:31 +0000 Subject: [PATCH 3/4] Apply prettier formatting to modified files Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com> --- src/mcp/tools/application/applicationCreate.ts | 5 ++++- src/mcp/tools/toolFactory.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mcp/tools/application/applicationCreate.ts b/src/mcp/tools/application/applicationCreate.ts index aca1b8d..963816f 100644 --- a/src/mcp/tools/application/applicationCreate.ts +++ b/src/mcp/tools/application/applicationCreate.ts @@ -31,7 +31,10 @@ export const applicationCreate = createTool({ outputSchema: z.object({ success: z.boolean().describe("Whether the operation was successful"), message: z.string().describe("A message describing the result"), - data: z.record(z.any()).optional().describe("The application data returned from the API"), + data: z + .record(z.any()) + .optional() + .describe("The application data returned from the API"), }), annotations: { title: "Create Application", diff --git a/src/mcp/tools/toolFactory.ts b/src/mcp/tools/toolFactory.ts index 780085b..d63db53 100644 --- a/src/mcp/tools/toolFactory.ts +++ b/src/mcp/tools/toolFactory.ts @@ -14,7 +14,7 @@ export type ToolHandler = (input: T) => Promise<{ // TOutputShape is the optional output schema ZodRawShape export interface ToolDefinition< TShape extends ZodRawShape, - TOutputShape extends ZodRawShape = ZodRawShape + TOutputShape extends ZodRawShape = ZodRawShape, > { name: string; description: string; @@ -46,7 +46,7 @@ export function createToolContext(): ToolContext { export function createTool< TShape extends import("zod").ZodRawShape, - TOutputShape extends import("zod").ZodRawShape = import("zod").ZodRawShape + TOutputShape extends import("zod").ZodRawShape = import("zod").ZodRawShape, >( definition: ToolDefinition ): ToolDefinition { From efa252e512e676fb5c803dbde08fad97f51e3b85 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:18:32 +0000 Subject: [PATCH 4/4] Improve type safety in http-server transport connection Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com> --- src/http-server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/http-server.ts b/src/http-server.ts index 725bfc3..c626d16 100644 --- a/src/http-server.ts +++ b/src/http-server.ts @@ -2,6 +2,7 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; +import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js"; import express from "express"; import { randomUUID } from "node:crypto"; @@ -62,7 +63,7 @@ export async function main() { // Create and connect server first const server = createServer(); // The transport will have sessionId after initialization - await server.connect(transport as any); + await server.connect(transport as Transport); // Log after successful connection logger.info("New MCP session server connected", {