Skip to content

Set headers on requests #133

Open
Open
@lucfranken

Description

@lucfranken

Is your feature request related to a problem? Please describe.
I have an MCP server with oAuth functional (a bearer / JWT token).

I don't see any point where to attach headers to all requests.

Is this a non-supported idea? I built it in the server for the official MCP Inspector but did not expect not to not find this option in the Swift SDK.

Describe the solution you'd like

A simple way to Auth my client after login.

I found how internally headers are set:

https://github.com/modelcontextprotocol/swift-sdk/blob/main/Sources/MCP/Base/Transports/HTTPClientTransport.swift#L205

But not how to do that in a supported way from outside the SDK.

Describe alternatives you've considered

Tried to keep track of this in the sessions on the server but that seems like the wrong way to go around this.

Additional context

Open to both alternatives when I don't understand the concept. We do use the session id's that all works fine but we don't see on the server (TypeScript SDK) and easy way to handle that. While we do see an oAuth example in the TypeScript SDK:

https://github.com/modelcontextprotocol/typescript-sdk/tree/590d4841373fc4eb86ecc9079834353a98cb84a3?tab=readme-ov-file#proxy-authorization-requests-upstream

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions