Skip to content

Commit e96d5dc

Browse files
committed
update readme to have server url + keys && updated prompts for mcp
1 parent 9bab822 commit e96d5dc

File tree

2 files changed

+117
-10
lines changed

2 files changed

+117
-10
lines changed

README.md

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,44 @@ curl -fsSL https://get.pnpm.io/install.sh | sh
4141

4242
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.png)](cursor://anysphere.cursor-deeplink/mcp/install?name=browserbase&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAYnJvd3NlcmJhc2VocS9tY3AiXSwiZW52Ijp7IkJST1dTRVJCQVNFX0FQSV9LRVkiOiIiLCJCUk9XU0VSQkFTRV9QUk9KRUNUX0lEIjoiIn19)
4343

44+
We currently support 2 transports for our MCP server, STDIO and SHTTP. We recommend you use SHTTP with our remote hosted url to take advantage of the server at full capacity.
45+
46+
## SHTTP:
47+
48+
When using our remote hosted server, we eat the LLM costs of Gemini, the [best performing model](www.stagehand.dev/evals) in [Stagehand](www.stagehand.dev).
49+
50+
To use the Browserbase MCP Server through our remote hosted URL, add the following to your configuration.
51+
52+
If your client supports SHTTP outright:
53+
54+
```json
55+
{
56+
"mcpServers": {
57+
"browserbase": {
58+
"url": "mcp.browserbase.com/mcp?browserbaseApiKey=""&browserbaseProjectId=""",
59+
}
60+
}
61+
}
62+
```
63+
64+
If your client doesn't support SHTTP outright:
65+
66+
```json
67+
{
68+
"mcpServers": {
69+
"browserbase": {
70+
"command": "npx",
71+
"args": [
72+
"mcp-remote",
73+
"mcp.browserbase.com/mcp?browserbaseApiKey=""&browserbaseProjectId="""
74+
],
75+
}
76+
}
77+
}
78+
```
79+
80+
## STDIO:
81+
4482
You can either use our Server hosted on NPM or run it completely locally by cloning this repo.
4583

4684
### To run on NPM (Recommended)
@@ -55,7 +93,8 @@ Go into your MCP Config JSON and add the Browserbase Server:
5593
"args": ["@browserbasehq/mcp"],
5694
"env": {
5795
"BROWSERBASE_API_KEY": "",
58-
"BROWSERBASE_PROJECT_ID": ""
96+
"BROWSERBASE_PROJECT_ID": "",
97+
"GEMINI_API_KEY": ""
5998
}
6099
}
61100
}
@@ -89,7 +128,8 @@ To your MCP Config JSON file add the following:
89128
"args": ["/path/to/mcp-server-browserbase/cli.js"],
90129
"env": {
91130
"BROWSERBASE_API_KEY": "",
92-
"BROWSERBASE_PROJECT_ID": ""
131+
"BROWSERBASE_PROJECT_ID": "",
132+
"GEMINI_API_KEY": ""
93133
}
94134
}
95135
}
@@ -113,7 +153,8 @@ Then in your MCP Config JSON file put the following:
113153
"url": "http://localhost:8931/mcp",
114154
"env": {
115155
"BROWSERBASE_API_KEY": "",
116-
"BROWSERBASE_PROJECT_ID": ""
156+
"BROWSERBASE_PROJECT_ID": "",
157+
"GEMINI_API_KEY": ""
117158
}
118159
}
119160
}
@@ -212,7 +253,8 @@ To use proxies, set the --proxies flag in your MCP Config:
212253
"args": ["@browserbasehq/mcp", "--proxies"],
213254
"env": {
214255
"BROWSERBASE_API_KEY": "",
215-
"BROWSERBASE_PROJECT_ID": ""
256+
"BROWSERBASE_PROJECT_ID": "",
257+
"GEMINI_API_KEY": ""
216258
}
217259
}
218260
}
@@ -233,7 +275,8 @@ To use advanced stealth, set the --advancedStealth flag in your MCP Config:
233275
"args": ["@browserbasehq/mcp", "--advancedStealth"],
234276
"env": {
235277
"BROWSERBASE_API_KEY": "",
236-
"BROWSERBASE_PROJECT_ID": ""
278+
"BROWSERBASE_PROJECT_ID": "",
279+
"GEMINI_API_KEY": ""
237280
}
238281
}
239282
}
@@ -254,7 +297,8 @@ To use contexts, set the --contextId flag in your MCP Config:
254297
"args": ["@browserbasehq/mcp", "--contextId", "<YOUR_CONTEXT_ID>"],
255298
"env": {
256299
"BROWSERBASE_API_KEY": "",
257-
"BROWSERBASE_PROJECT_ID": ""
300+
"BROWSERBASE_PROJECT_ID": "",
301+
"GEMINI_API_KEY": ""
258302
}
259303
}
260304
}
@@ -279,7 +323,8 @@ You can inject cookies into the MCP by adding them to your MCP Config. Your cook
279323
],
280324
"env": {
281325
"BROWSERBASE_API_KEY": "",
282-
"BROWSERBASE_PROJECT_ID": ""
326+
"BROWSERBASE_PROJECT_ID": "",
327+
"GEMINI_API_KEY": ""
283328
}
284329
}
285330
}
@@ -304,7 +349,8 @@ Here's how to use it for custom browser sizing. We recommend to stick with 16:9
304349
],
305350
"env": {
306351
"BROWSERBASE_API_KEY": "",
307-
"BROWSERBASE_PROJECT_ID": ""
352+
"BROWSERBASE_PROJECT_ID": "",
353+
"GEMINI_API_KEY": ""
308354
}
309355
}
310356
}
@@ -333,7 +379,8 @@ Here's how to configure different models:
333379
],
334380
"env": {
335381
"BROWSERBASE_API_KEY": "",
336-
"BROWSERBASE_PROJECT_ID": ""
382+
"BROWSERBASE_PROJECT_ID": "",
383+
"GEMINI_API_KEY": ""
337384
}
338385
}
339386
}
@@ -356,7 +403,8 @@ For Claude models:
356403
],
357404
"env": {
358405
"BROWSERBASE_API_KEY": "",
359-
"BROWSERBASE_PROJECT_ID": ""
406+
"BROWSERBASE_PROJECT_ID": "",
407+
"GEMINI_API_KEY": ""
360408
}
361409
}
362410
}

src/mcp/prompts.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export const PROMPTS = [
1818
"Guidance on when and how to use multi-session browser automation",
1919
arguments: [],
2020
},
21+
{
22+
name: "stagehand_usage",
23+
description:
24+
"Guidelines on how to use Stagehand's act, observe, and extract utilities effectively",
25+
arguments: [],
26+
},
2127
];
2228

2329
/**
@@ -120,5 +126,58 @@ SINGLE VS MULTI-SESSION:
120126
};
121127
}
122128

129+
if (name === "stagehand_usage") {
130+
return {
131+
description:
132+
"Guidelines on how to use Stagehand's act, observe, and extract utilities effectively",
133+
messages: [
134+
{
135+
role: "system",
136+
content: {
137+
type: "text",
138+
text: `Stagehand Usage Guidelines
139+
140+
OVERVIEW:
141+
Stagehand extends Playwright with natural-language helpers (act, observe, extract) available via stagehand.page.
142+
143+
INITIALISE:
144+
import { Stagehand } from "@browserbasehq/stagehand";
145+
const stagehand = new Stagehand(StagehandConfig);
146+
await stagehand.init();
147+
const { page, context } = stagehand;
148+
149+
ACT:
150+
- Invoke atomic, single-step actions in plain language: page.act("Click the sign in button");
151+
- Avoid multi-step instructions such as "Type in the search bar and hit enter".
152+
- Cache observe results and pass them to act whenever possible to avoid DOM drift.
153+
154+
OBSERVE:
155+
- Plan before acting: const [action] = await page.observe("Click the sign in button");
156+
- The returned ObserveResult array can be fed directly into page.act(action).
157+
158+
EXTRACT:
159+
- Always call page.extract({ instruction, schema }) with a strict Zod schema.
160+
- For URLs use z.string().url(); for arrays wrap them in an object property.
161+
Example:
162+
const data = await page.extract({
163+
instruction: "extract the text inside all buttons",
164+
schema: z.object({ text: z.array(z.string()) }),
165+
});
166+
167+
AGENT:
168+
Use stagehand.agent for autonomous multi-step tasks.
169+
170+
BEST PRACTICES:
171+
- Keep actions atomic and specific.
172+
- Cache observe results to stabilise interactions.
173+
- Prefer explicit schemas to guarantee correct extraction.
174+
- Use observe to verify actions before invoking act.
175+
- Treat Stagehand as controlling real browsers – navigate, click, type, and extract exactly as a user would, but with automation scale.`,
176+
},
177+
},
178+
],
179+
};
180+
}
181+
123182
throw new Error(`Invalid prompt name: ${name}`);
124183
}

0 commit comments

Comments
 (0)