feat: Supports request header authentication with connectToMCPServer
why
Hello, thank you for developing the wonderful product Stagehand.
I am currently using Stagehand for my project.
It is very comfortable and convenient.
While developing, I was using connectToMCPServer to establish the client connection for agent integration settings,
and I discovered it does not support authentication via request headers (Authorization header).
In my project, I attempted to use DeepWiki's MCP server, which can connect to private repositories.
However, since it doesn't allow setting the API key via URL parameters like Supabase's MCP does,
I couldn't establish a connection using connectToMCPServer.
https://mcp.devin.ai/
Because the API key must be included in the Authorization request header,
I need to make modifications to handle such MCP servers in a more generic way.
what changed
We have modified connectToMCPServer to accept options for StreamableHTTPClientTransport as arguments.
test plan
-
pnpm installandpnpm build,pnpm lintsucceed - Passed the tests in
packages/core/tests/public-api/v3-core.test.ts
Summary by cubic
Adds request header authentication to connectToMCPServer by exposing requestOptions to the HTTP transport. This enables connecting to MCP servers that require Authorization headers (e.g., DeepWiki).
- New Features
- connectToMCPServer now accepts requestOptions (StreamableHTTPClientTransportOptions) passed to StreamableHTTPClientTransport, allowing custom headers via requestInit.headers.
- Updated docs with an Authorization header example; adjusted public API tests to include the new option; added a changeset to publish patch releases for core and docs.