Skip to content

Fix: Pass header parameter to StreamableHTTPClientTransport in MCPSessionManager#39

Merged
copybara-service[bot] merged 2 commits into
google:mainfrom
viniychuk:fix/mcp-streamable-http-headers
Dec 30, 2025
Merged

Fix: Pass header parameter to StreamableHTTPClientTransport in MCPSessionManager#39
copybara-service[bot] merged 2 commits into
google:mainfrom
viniychuk:fix/mcp-streamable-http-headers

Conversation

@viniychuk
Copy link
Copy Markdown
Contributor

Summary

This PR fixes a bug in MCPSessionManager where the header parameter from StreamableHTTPConnectionParams was not being passed to the StreamableHTTPClientTransport constructor. This prevented authentication headers (like Authorization) from being sent to MCP servers over HTTP.

Changes

  • Modified MCPSessionManager.createSession() to wrap the header parameter in a requestInit object
  • Pass the requestInit object as the second argument to StreamableHTTPClientTransport

Testing

  • Built the project successfully with npm run build
  • Verified that the TypeScript types are correct

Impact

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.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Dec 23, 2025

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.
@viniychuk
Copy link
Copy Markdown
Contributor Author

This addresses #33. Since header argument is unused anyways, could be an opportunity to rename it to headers, which feels more appropriate and matches RequestInit.

Copy link
Copy Markdown
Collaborator

@kalenkevich kalenkevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kalenkevich kalenkevich added the ready to pull Ready to pull for final review. label Dec 24, 2025
@JonasPardon
Copy link
Copy Markdown

This addresses #33. Since header argument is unused anyways, could be an opportunity to rename it to headers, which feels more appropriate and matches RequestInit.

+1 from me, the argument being named headers feels more appropriate to me as well, first thing I noticed when trying out this package.

@ScottMansfield
Copy link
Copy Markdown
Member

ScottMansfield commented Dec 26, 2025

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.

@copybara-service copybara-service Bot merged commit 9522758 into google:main Dec 30, 2025
7 of 8 checks passed
@JonasPardon
Copy link
Copy Markdown

@ScottMansfield any chance of you tagging a release for this? 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull Ready to pull for final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants