Skip to content

refactor: Brand ToolResponse and narrow ToolEntry.call (P4 lock) #938

@jirispilka

Description

@jirispilka

Part of #935. Depends on #937 (all handlers must route through respond* first).

Goal

Make an unclassified error a compile error — closes P4. This is the structural guarantee that distinguishes Option F from a plain helper.

Scope

  • Brand the constructor output in src/utils/mcp.ts:

    declare const wireBrand: unique symbol;
    export type ToolResponse = MCPWireShape & { readonly [wireBrand]?: never };

    The respond* functions return ToolResponse; raw object literals don't carry the brand.

  • Narrow the handler signature in src/types.ts (currently call: (args) => Promise<object>):

    call: (args: InternalToolArgs) => Promise<ToolResponse>;
  • Fix whatever the compiler flags — those are the spots refactor: Adopt respond* response constructors across tools #937 missed (hand-rolled shapes or stray isError).

Acceptance

  • A hand-rolled { content: [...] } or bare isError: true in a handler does not compile.
  • pnpm run type-check, pnpm run lint, pnpm run test:unit clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-aiIssues owned by the AI team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions