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
11 changes: 11 additions & 0 deletions .changeset/task-error-masking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@modelcontextprotocol/server": patch
---

fix: prevent task-augmented tool errors from being masked

Re-throw McpErrors for task-augmented requests instead of wrapping them
in createToolError(). This prevents protocol errors from being masked
by "Invalid task creation result" errors during CreateTaskResultSchema validation.

Fixes #1385
7 changes: 6 additions & 1 deletion packages/server/src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,13 @@ export class McpServer {
await this.validateToolOutput(tool, result, request.params.name);
return result;
} catch (error) {
// For task-augmented requests, re-throw McpErrors to avoid masking
// them with "Invalid task creation result" errors in server.ts
if (request.params.task && error instanceof McpError) {
throw error;
}
if (error instanceof McpError && error.code === ErrorCode.UrlElicitationRequired) {
throw error; // Return the error to the caller without wrapping in CallToolResult
throw error;
}
return this.createToolError(error instanceof Error ? error.message : String(error));
}
Expand Down
Loading