Agent / foldkit-agent-mcp

Protocol errors vs application refusals

MCP distinguishes a malformed/invalid protocol call from a valid call the application refuses. This adapter preserves that distinction:

SituationMCP result
unknown tool nameJSON-RPC error -32602
arguments fail the advertised input schemaJSON-RPC error -32602
capability is currently unavailabletool result with isError: true
principal is unauthorizedtool result with isError: true
invocation is cancelledtool result with isError: true
declared completion failstool result with isError: true

That matters because a client may treat JSON-RPC errors as malformed requests or transport/protocol faults. An authorization refusal is an application decision, not a broken MCP call.

A capability can also disappear between tools/list and tools/call. That call remains syntactically valid, so it returns a tool error rather than -32602.

Availability follows the Model

tools/list is dynamic. If a capability's available(model) changes, the tool appears or disappears with the live application state.

The adapter emits notifications/tools/list_changed only when that advertised set actually changes, not on every Model transition. Use debounceMs when the capability set itself can flap rapidly.

Availability is also enforced at invocation time. Knowing a previously advertised tool name does not bypass the current Model boundary.