go-sdk icon indicating copy to clipboard operation
go-sdk copied to clipboard

No Way to Pass Custom Headers (e.g., Authorization) When Using go-sdk to Connect to MCP Server

Open NiharDoshi99 opened this issue 2 months ago • 3 comments

When using the go-sdk to communicate with an MCP server that requires authentication, there is currently no documented or supported way to pass custom HTTP headers (e.g., Authorization, x-api-key, etc.) during the connection or request initialization.

NiharDoshi99 avatar Nov 07 '25 05:11 NiharDoshi99

Right now, this is done with a custom HTTP client. #595 is an in-progress PR with an example, but per @jba's comment, we updated the experimental client-side oauth support to make this example more ergonomic.

Leaving this open to track documentation.

findleyr avatar Nov 07 '25 21:11 findleyr

@findleyr Could you please share me example on how to do pass custom headers with custom HTTP client ?

NiharDoshi99 avatar Nov 10 '25 12:11 NiharDoshi99

@NiharDoshi99 I also was wondering the same, I saw an example somewhere but I'm unable to find it again for now.

But you might find my implementation here helpful. It is not the best though.

Bajahaw avatar Nov 11 '25 22:11 Bajahaw