Skip to content

Comments

Contrib/1690#1735

Merged
monadoid merged 6 commits intomainfrom
contrib/1690
Feb 24, 2026
Merged

Contrib/1690#1735
monadoid merged 6 commits intomainfrom
contrib/1690

Conversation

@monadoid
Copy link
Contributor

@monadoid monadoid commented Feb 23, 2026

why

From 1690 shoutout @huuyafwww !

This enables agent to connect to MCP servers that require Authorization headers.

what changed

connectToMCPServer was modified to accept options for StreamableHTTPClientTransport as arguments.

test plan

A public api test was added


Note

Low Risk
Small additive API change that only affects MCP HTTP connection setup; minimal behavior change unless callers opt into requestOptions.

Overview
connectToMCPServer now accepts requestOptions and forwards them to StreamableHTTPClientTransport, enabling HTTP connections to MCP servers that require request-header auth (e.g., Authorization).

Updates the public API type test to include requestOptions, adds docs showing a header-authenticated connection example, and publishes patch changesets for @browserbasehq/stagehand and @browserbasehq/stagehand-docs.

Written by Cursor Bugbot for commit 657b7d5. This will update automatically on new commits. Configure here.


Summary by cubic

Enable header-based auth for MCP HTTP connections. connectToMCPServer now accepts requestOptions and forwards them to StreamableHTTPClientTransport.

  • New Features
    • Added requestOptions to connectToMCPServer for HTTP transports to pass headers like Authorization.
    • Updated docs with an authenticated MCP server example, expanded the public API type test, and limited the changeset bump to @browserbasehq/stagehand (docs package bump removed).

Written for commit 6cee1df. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 6cee1df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Extends connectToMCPServer to accept requestOptions, enabling HTTP-based MCP connections with custom request headers like Authorization.

  • Added optional requestOptions: StreamableHTTPClientTransportOptions parameter to ConnectToMCPServerOptions interface
  • Extracts and forwards requestOptions to StreamableHTTPClientTransport constructor
  • Updated public API type test to validate the new optional field
  • Documentation includes working example with Authorization header for Deep Wiki MCP server
  • Backward compatible - existing code continues to work without changes

Confidence Score: 5/5

  • Safe to merge - clean additive change with proper typing and documentation
  • The PR makes a simple, backward-compatible API extension that adds an optional parameter. The implementation correctly extracts and passes the requestOptions to the underlying SDK transport, the type definitions are updated, tests validate the public API surface, and documentation provides a clear usage example. No breaking changes or logical issues.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/mcp/connection.ts Added optional requestOptions parameter to support custom HTTP headers like Authorization
packages/core/tests/unit/public-api/v3-core.test.ts Updated type test to include new requestOptions field
packages/docs/v3/best-practices/mcp-integrations.mdx Added documentation example showing header-based authentication with requestOptions
.changeset/tender-experts-obey.md Changeset documenting the new request header authentication support

Last reviewed commit: 657b7d5

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Confidence score: 4/5

  • Minor documentation inconsistency in packages/docs/v3/best-practices/mcp-integrations.mdx: systemPrompt doesn’t mention DeepWiki even though deepWikiClient was added, which could confuse readers following the example.
  • Overall impact is limited to docs/example accuracy, so this looks safe to merge with minimal risk.
  • Pay close attention to packages/docs/v3/best-practices/mcp-integrations.mdx - update the example prompt to include DeepWiki for consistency.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/v3/best-practices/mcp-integrations.mdx">

<violation number="1" location="packages/docs/v3/best-practices/mcp-integrations.mdx:86">
P2: The `systemPrompt` was not updated to mention DeepWiki after adding `deepWikiClient` to the `integrations` array. This makes the documentation example inconsistent — readers following this example would configure an integration the agent isn't instructed to use. The docs' own best practices section emphasizes providing clear instructions about all available tools.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Dev as Developer / Client
    participant Conn as connectToMCPServer()
    participant Transport as StreamableHTTPClientTransport
    participant MCPClient as MCP Client (SDK)
    participant Server as Remote MCP Server

    Note over Dev,Server: MCP HTTP Connection Flow with Authentication

    Dev->>Conn: connectToMCPServer(config)
    Note right of Dev: NEW: config includes requestOptions<br/>(e.g., Authorization headers)

    alt HTTP Transport Path
        Conn->>Transport: NEW: constructor(url, requestOptions)
        Note over Transport: Stores custom headers/requestInit
        
        Conn->>MCPClient: new Client({ transport, clientOptions })
        Conn->>MCPClient: connect()
        
        MCPClient->>Transport: start()
        Transport->>Server: CHANGED: HTTP Request (includes custom headers)
        
        alt Success
            Server-->>Transport: 200 OK / Stream
            Transport-->>MCPClient: Connection established
            MCPClient-->>Conn: client instance
            Conn-->>Dev: Return MCP Client
        else Unauthorized / Error
            Server-->>Transport: 401 Unauthorized
            Transport-->>MCPClient: Connection failed
            MCPClient-->>Conn: throw Error
            Conn-->>Dev: throw MCPConnectionError
        end
    else Stdio Transport Path (Unchanged)
        Conn->>Conn: Use StdioClientTransport(command, args)
    end
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Collaborator

@miguelg719 miguelg719 left a comment

Choose a reason for hiding this comment

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

good stuff @huuyafwww !

@monadoid monadoid merged commit c465e87 into main Feb 24, 2026
161 checks passed
@github-actions github-actions bot mentioned this pull request Feb 24, 2026
miguelg719 pushed a commit that referenced this pull request Feb 24, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @browserbasehq/stagehand@3.1.0

### Minor Changes

- [#1681](#1681)
[`e3db9aa`](e3db9aa)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add cookie management
APIs: `context.addCookies()`, `context.clearCookies()`, &
`context.cookies()`

- [#1672](#1672)
[`b65756e`](b65756e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add boolean
keepAlive parameter to allow for configuring whether the browser should
be closed when stagehand.close() is called.

- [#1708](#1708)
[`176d420`](176d420)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add
context.setExtraHTTPHeaders()

- [#1611](#1611)
[`8a3c066`](8a3c066)
Thanks [@monadoid](https://github.com/monadoid)! - Using `mode` enum
instead of old `cua` boolean in openapi spec

### Patch Changes

- [#1683](#1683)
[`7584f3e`](7584f3e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix:
include shadow DOM in .count() & .nth() & support xpath predicates

- [#1644](#1644)
[`1e1c9c1`](1e1c9c1)
Thanks [@monadoid](https://github.com/monadoid)! - Fix unhandled CDP
detaches by returning the original sendCDP promise

- [#1729](#1729)
[`6bef890`](6bef890)
Thanks [@shrey150](https://github.com/shrey150)! - fix: support Claude
4.6 (Opus and Sonnet) in CUA mode by using the correct
`computer_20251124` tool version and `computer-use-2025-11-24` beta
header

- [#1647](#1647)
[`ffd4b33`](ffd4b33)
Thanks [@tkattkat](https://github.com/tkattkat)! - Fix [Agent] - Address
bug causing issues with continuing a conversation from past messages in
dom mode

- [#1614](#1614)
[`677bff5`](677bff5)
Thanks [@miguelg719](https://github.com/miguelg719)! - Enforce
<number>-<number> regex validation on act/observe for elementId

- [#1580](#1580)
[`65ff464`](65ff464)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add unified variables
support across act and agent with a single VariableValue type

- [#1666](#1666)
[`101bcf2`](101bcf2)
Thanks [@Kylejeong2](https://github.com/Kylejeong2)! - add support for
codex models

- [#1728](#1728)
[`0a94301`](0a94301)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - handle
potential race condition on `.close()` when using the Stagehand API

- [#1664](#1664)
[`b27c04d`](b27c04d)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fixes issue
with context.addInitScript() where scripts were not being applied to out
of process iframes (OOPIFs), and popup pages with same process iframes
(SPIFs)

- [#1632](#1632)
[`afbd08b`](afbd08b)
Thanks [@pirate](https://github.com/pirate)! - Remove automatic `.env`
loading via `dotenv`.

If your app relies on `.env` files, install `dotenv` and load it
explicitly in your code:

    ```ts
    import dotenv from "dotenv";
    dotenv.config({ path: ".env" });
    ```

- [#1624](#1624)
[`0e8d569`](0e8d569)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where screenshot masks were not being applied to dialog elements

- [#1596](#1596)
[`ff0f979`](ff0f979)
Thanks [@tkattkat](https://github.com/tkattkat)! - Update usage/metrics
handling in agent

- [#1631](#1631)
[`2d89d2b`](2d89d2b)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add right and
middle click support to act and observe

- [#1697](#1697)
[`aac9a19`](aac9a19)
Thanks [@shrey150](https://github.com/shrey150)! - fix: support
`<frame>` elements in XPath frame boundary detection so `act()` works on
legacy `<frameset>` pages

- [#1692](#1692)
[`06de50f`](06de50f)
Thanks [@shrey150](https://github.com/shrey150)! - fix: skip piercer
injection for chrome-extension:// and other non-HTML targets

- [#1613](#1613)
[`aa4d981`](aa4d981)
Thanks [@miguelg719](https://github.com/miguelg719)! -
SupportedUnderstudyAction Enum validation for 'method' on act/observe
inference

- [#1652](#1652)
[`18b1e3b`](18b1e3b)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add support for
gemini 3 flash and pro in hybrid/cua agent

- [#1706](#1706)
[`957d82b`](957d82b)
Thanks [@chrisreadsf](https://github.com/chrisreadsf)! - Add GLM to
prompt-based JSON fallback for models without native structured output
support

- [#1633](#1633)
[`22e371a`](22e371a)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add warning when
incorrect models are used with agents hybrid mode

- [#1673](#1673)
[`d29b91f`](d29b91f)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add multi-region
support for Stagehand API with region-specific endpoints

- [#1695](#1695)
[`7b4f817`](7b4f817)
Thanks [@tkattkat](https://github.com/tkattkat)! - Fix: zod bug when
pinning zod to v3 and using structured output in agent

- [#1609](#1609)
[`3f9ca4d`](3f9ca4d)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add
SupportedUnderstudyActions to observe system prompt

- [#1581](#1581)
[`49ead1e`](49ead1e)
Thanks [@sameelarif](https://github.com/sameelarif)! - **Server-side
caching is now available.**

When running `env: "BROWSERBASE"`, Stagehand automatically caches
`act()`, `extract()`, and `observe()` results server-side — repeated
calls with the same inputs return instantly without consuming LLM
tokens.

Caching is enabled by default and can be disabled via `serverCache:
false` on the Stagehand instance or per individual call. Check out the
[browserbase blog](https://www.browserbase.com/blog/stagehand-caching)
for more details.

- [#1642](#1642)
[`3673369`](3673369)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where scripts added via context.addInitScripts() were not being injected
into new pages that were opened via popups (eg, clicking a link that
opens a new page) and/or calling context.newPage(url)

- [#1735](#1735)
[`c465e87`](c465e87)
Thanks [@monadoid](https://github.com/monadoid)! - Supports request
header authentication with connectToMCPServer

- [#1705](#1705)
[`ae533e4`](ae533e4)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - include
error cause in UnderstudyCommandException

- [#1636](#1636)
[`ea33052`](ea33052)
Thanks [@miguelg719](https://github.com/miguelg719)! - Include
executionModel on the AgentConfigSchema

- [#1679](#1679)
[`5764ede`](5764ede)
Thanks [@shrey150](https://github.com/shrey150)! - fix issue where
locator.count() was not working with xpaths that have attribute
predicates

- [#1646](#1646)
[`f09b184`](f09b184)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add user-agent to
CDP connections

- [#1637](#1637)
[`a7d29de`](a7d29de)
Thanks [@miguelg719](https://github.com/miguelg719)! - Improve error and
warning message for legacy model format

- [#1685](#1685)
[`d334399`](d334399)
Thanks [@tkattkat](https://github.com/tkattkat)! - Bump ai sdk & google
provider version

- [#1662](#1662)
[`44416da`](44416da)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where locator.fill() was not working on elements that require direct
value setting

- [#1612](#1612)
[`bdd8b4e`](bdd8b4e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue
where screenshot mask was only being applied to the first element that
the locator resolved to. masks now apply to all matching elements.

## @browserbasehq/stagehand-server@3.6.0

### Minor Changes

- [#1611](#1611)
[`8a3c066`](8a3c066)
Thanks [@monadoid](https://github.com/monadoid)! - Using `mode` enum
instead of old `cua` boolean in openapi spec

### Patch Changes

- [#1604](#1604)
[`4753078`](4753078)
Thanks [@miguelg719](https://github.com/miguelg719)! - Enable bedrock

- [#1636](#1636)
[`ea33052`](ea33052)
Thanks [@miguelg719](https://github.com/miguelg719)! - Include
executionModel on the AgentConfigSchema

- [#1602](#1602)
[`22a0502`](22a0502)
Thanks [@miguelg719](https://github.com/miguelg719)! - Include vertex as
a supported provider

- Updated dependencies
\[[`7584f3e`](7584f3e),
[`1e1c9c1`](1e1c9c1),
[`6bef890`](6bef890),
[`ffd4b33`](ffd4b33),
[`677bff5`](677bff5),
[`65ff464`](65ff464),
[`101bcf2`](101bcf2),
[`0a94301`](0a94301),
[`b27c04d`](b27c04d),
[`afbd08b`](afbd08b),
[`e3db9aa`](e3db9aa),
[`0e8d569`](0e8d569),
[`ff0f979`](ff0f979),
[`2d89d2b`](2d89d2b),
[`aac9a19`](aac9a19),
[`06de50f`](06de50f),
[`aa4d981`](aa4d981),
[`18b1e3b`](18b1e3b),
[`957d82b`](957d82b),
[`b65756e`](b65756e),
[`22e371a`](22e371a),
[`d29b91f`](d29b91f),
[`7b4f817`](7b4f817),
[`176d420`](176d420),
[`3f9ca4d`](3f9ca4d),
[`8a3c066`](8a3c066),
[`49ead1e`](49ead1e),
[`3673369`](3673369),
[`c465e87`](c465e87),
[`ae533e4`](ae533e4),
[`ea33052`](ea33052),
[`5764ede`](5764ede),
[`f09b184`](f09b184),
[`a7d29de`](a7d29de),
[`d334399`](d334399),
[`44416da`](44416da),
[`bdd8b4e`](bdd8b4e)]:
    -   @browserbasehq/stagehand@3.1.0

## @browserbasehq/stagehand-evals@1.1.8

### Patch Changes

- Updated dependencies
\[[`7584f3e`](7584f3e),
[`1e1c9c1`](1e1c9c1),
[`6bef890`](6bef890),
[`ffd4b33`](ffd4b33),
[`677bff5`](677bff5),
[`65ff464`](65ff464),
[`101bcf2`](101bcf2),
[`0a94301`](0a94301),
[`b27c04d`](b27c04d),
[`afbd08b`](afbd08b),
[`e3db9aa`](e3db9aa),
[`0e8d569`](0e8d569),
[`ff0f979`](ff0f979),
[`2d89d2b`](2d89d2b),
[`aac9a19`](aac9a19),
[`06de50f`](06de50f),
[`aa4d981`](aa4d981),
[`18b1e3b`](18b1e3b),
[`957d82b`](957d82b),
[`b65756e`](b65756e),
[`22e371a`](22e371a),
[`d29b91f`](d29b91f),
[`7b4f817`](7b4f817),
[`176d420`](176d420),
[`3f9ca4d`](3f9ca4d),
[`8a3c066`](8a3c066),
[`49ead1e`](49ead1e),
[`3673369`](3673369),
[`c465e87`](c465e87),
[`ae533e4`](ae533e4),
[`ea33052`](ea33052),
[`5764ede`](5764ede),
[`f09b184`](f09b184),
[`a7d29de`](a7d29de),
[`d334399`](d334399),
[`44416da`](44416da),
[`bdd8b4e`](bdd8b4e)]:
    -   @browserbasehq/stagehand@3.1.0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants