Fix: Pass header parameter to StreamableHTTPClientTransport in MCPSessionManager#39
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The MCPSessionManager was not passing the header parameter from StreamableHTTPConnectionParams to the StreamableHTTPClientTransport constructor. This prevented authentication headers (like Authorization) from being sent to MCP servers over HTTP. This fix wraps the header parameter in a requestInit object and passes it as the second argument to StreamableHTTPClientTransport, which properly includes the headers in all HTTP requests to the MCP server.
16d78b6 to
81bffbc
Compare
|
This addresses #33. Since |
+1 from me, the argument being named |
|
I'm ok changing the name but let's keep the PRs small and focused. You can open another if you want or just create the issue. Thank you for finding that, it looks like an inconsistency with the other ADKs, too. Edit: It looks like you merged main into your branch, but we want to do single commit PRs. If you fast forward your branch it should pass the check again. |
|
@ScottMansfield any chance of you tagging a release for this? 🙏🏻 |
Summary
This PR fixes a bug in
MCPSessionManagerwhere theheaderparameter fromStreamableHTTPConnectionParamswas not being passed to theStreamableHTTPClientTransportconstructor. This prevented authentication headers (likeAuthorization) from being sent to MCP servers over HTTP.Changes
MCPSessionManager.createSession()to wrap theheaderparameter in arequestInitobjectrequestInitobject as the second argument toStreamableHTTPClientTransportTesting
npm run buildImpact
This enables users to authenticate with MCP servers that require authentication headers, such as Bearer tokens.
Example Usage
After this fix, users can pass authentication headers like this:
```typescript
const mcpToolset = new MCPToolset({
type: 'StreamableHTTPConnectionParams',
url: 'http://localhost:3001/mcp',
header: { 'Authorization': 'Bearer ' }
}, ['tool_name']);
```
Fixes authentication issues with StreamableHTTP MCP servers that require API keys or Bearer tokens.