Skip to content

Use custom headers for both the /sse and /message endpoints #118

Closed
@jirispilka

Description

@jirispilka

@chrisdickinson thank you for this PR

Apologies, but I'm not very strong in JS.
I need to include an API token to access my MCP server, for both the /sse and /message endpoints.

I believe the headers are not being used during client.connect()?

Here’s the code snippet I’m working with:

const customHeaders = { Authorization: `Bearer ${token}` };

const transport = new SSEClientTransport(new URL(SERVER_URL), { requestInit: { headers: customHeaders } });
const client = new Client({ name: 'example-client', version: '1.0.0' }, { capabilities: {} });

await client.connect(transport);

I'm still getting 401.
As far as I can tell, the requestInit is only being used when a message is sent. Is that correct?

I’d appreciate your help. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions