Skip to content

Security logic result is unavailable to tools forcing a second header read #237

Description

@max-peroch

Hello, I run an MCP server that proxies an internal HTTP API: every tool forwards the caller's bearer token upstream, so the token is both the gate and an input to each tool.

prependSecurity handles the gate well. But per docs/server/transport.md#security:

The result of the security logic does not reach the tool logic. If a tool needs data from the caller, read the request headers with handleWithHeaders (or serverLogic with headers).

So each tool re-reads the Authorization header and re-handles the missing-token case the gate already rejected (unreachable branch in every tool), and header parsing lives in two places that can drift apart.

Tapir's serverSecurityLogic covers this by deriving a typed principal once and handing it to the main logic. Do you think it would make sense to add an equivalent for Chimp, or is there a recommended pattern I've missed?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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