Skip to content

All 10 tools return internal error (-32603) instead of isError for missing API token #21

Description

@blackwell-systems

When BANKLESS_API_TOKEN is not set, all 10 tools return a JSON-RPC internal error (-32603) instead of a proper tool error (isError: true). This means agents receive a protocol-level crash instead of a recoverable error message.

FAIL read_contract    internal error: Authentication Failed: BANKLESS_API_TOKEN environment variable is not set
FAIL get_proxy        internal error: Authentication Failed: BANKLESS_API_TOKEN environment variable is not set
... (all 10 tools)

Why it matters: MCP distinguishes between:

  • isError: true: the tool ran but something went wrong. The error message is user-facing and the agent can recover (e.g. prompt the user for the token).
  • -32603: something broke inside the server. The agent treats this as a fatal error and can't help the user.

The error message itself is excellent ("Authentication Failed: BANKLESS_API_TOKEN environment variable is not set"). It just needs to be returned as a tool error instead of an internal error.

Suggested fix:

Instead of throwing/rejecting, return the error through the MCP tool result:

if (!process.env.BANKLESS_API_TOKEN) {
  return { content: [{ type: "text", text: "Authentication Failed: BANKLESS_API_TOKEN environment variable is not set" }], isError: true };
}

Additionally: the network parameter appears in 7 tools but has no enum listing valid values. Agents must guess whether it's "ethereum", "eth", "1", or "mainnet". Adding enum: ["ethereum", "polygon", "arbitrum", ...] to the schema would reduce agent errors.

Found via: mcp-assert audit --server "npx -y @bankless/onchain-mcp" and mcp-assert lint. If you want to add CI regression testing for your server: github.com/blackwell-systems/mcp-assert.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions