Azure / Azure/azure-functions-nodejs-library

McpToolResponse.isError is dropped before MCP tool result reaches the client

Open
#444 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
70
Forks
35
Avg merge
4d 18h
Merged PRs (30d)
6

Description

`McpToolResponse` accepts `isError: true`, but the Node.js worker conversion path appears to drop that field before the result is sent to the Azure Functions MCP extension. As a result, MCP clients receive a
successful `tools/call` result instead of a tool-error result.

## Environment

- `@azure/functions`: `4.16.0`
- Azure Functions MCP extension: observed with extension bundle preview using MCP extension `1.5.0`
- Runtime: Node.js Azure Functions app using `app.mcpTool(...)`

## Reproduction

Return an MCP tool response with `isError: true`:

```ts
return new McpToolResponse({
content: [
new McpTextContent("Invalid file")
],
isError: true,
});
```

The public type supports this:

```ts
export interface McpToolResponseInit {
content: McpContentBlock[];
structuredContent?: unknown;
isError?: boolean;
}
```

But toMcpToolResult() serializes only type, content, and optional structuredContent:

```ts
const out: McpToolResult = { type, content: contentStr };

if (response.structuredContent !== undefined && response.structuredContent !== null) {
out.structuredContent =
typeof response.structuredContent === "string"
? response.structuredContent
: JSON.stringify(response.structuredContent);
}

return out;
```

## Actual Behavior

A handler-level error response reaches the MCP client like this:

```json
{
"result": {
"content": [
{
"type": "text",
"text": "Invalid file"
}
]
},
"id": 5,
"jsonrpc": "2.0"
}
```

There is no isError field.

## Expected Behavior

The client-visible MCP result should include:

```json
{
"result": {
"content": [
{
"type": "text",
"text": "Invalid file"
}
],
"isError": true
},
"id": 5,
"jsonrpc": "2.0"
}
```

Per the MCP schema, missing isError defaults to false, so clients currently treat handler-level tool errors as successful tool results.

Spec reference: https://modelcontextprotocol.io/specification/2025-06-18/schema#tools-call

# Notes

I'm unsure if this would best be solved in the node library, or in the extension handler same way `_meta` is (in preview builds)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.