Skip to content

[Request]: let an mcp tool handler return isError with a caller-facing message #716

Closed

Description

@jimhoyd

Problem or use case

An mcp tool handler can report a failure to the caller only by throwing, and the extension then returns a fixed The tool could not complete the request. with isError: true. A handler has no way to return isError: true together with its own caller-safe message, which the MCP spec intends for tool-execution errors the model should see and correct (for example "Unknown skill. Did you mean "urlcode-operations"?" or a YAML validator message).

urlcode-ai used to return those as isError: true results. With the extension it now returns them as successful results carrying an error object, which clients can't tell apart from success without parsing.

Proposed behavior and alternatives

  • Let a tool handler return an explicit tool error, for example a returned {isError: true, content} / {isError: true, structuredContent} marker, or a thrown McpToolError(message, data?) exported by the extension whose message is sent to the caller. Other thrown errors keep the generic message.
  • Report it to onToolCall as a third outcome ('tool_error'), separate from a thrown 'error'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions