modelcontextprotocol / modelcontextprotocol/go-sdk
Proposal: add `ModifyRequest func(*http.Request)` to HTTP client transports
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.1k
- Forks
- 543
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 37
Description
Following up on #522, where we discussed making it easier to modify HTTP client transport requests, for example by adding headers, we propose the following two new options:
type StreamableClientTransport struct {
...
// If set, ModifyRequest is called before each outgoing HTTP request made by the client
// connection. It can be use to, for example, add headers to outgoing requests.
ModifyRequest func(*http.Request)
}
type SSEClientTransport struct {
...
// <ditto>
ModifyRequest func(*http.Request)
}
We believe these options will make it easier to do things like add auth headers. Currently, this can be achieved using the HTTPClient field, but only in the roundtripper, which requires cloning the request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the StreamableClientTransport and SSEClientTransport definitions, then trace how each creates outgoing HTTP requests. Check the existing HTTPClient and roundtripper behavior before deciding where the callbacks belong. Done means both transports expose ModifyRequest and invoke it before each outgoing request, with tests covering the callback behavior and header modification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100