@@ -6,8 +6,72 @@ import { ServerList } from "./server.js";
66import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
77import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js" ;
88import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js" ;
9+ import type { Config } from "../config.js" ;
10+
11+ export async function startStdioTransport (
12+ serverList : ServerList ,
13+ config ?: Config ,
14+ ) {
15+ // Check if we're using the default model without an API key
16+ if ( config ) {
17+ const modelName = config . modelName || "google/gemini-2.0-flash" ;
18+ const hasModelApiKey = config . modelApiKey || process . env . GEMINI_API_KEY ;
19+
20+ if ( modelName . includes ( "google/gemini" ) && ! hasModelApiKey ) {
21+ console . error ( `
22+ ⚠️ IMPORTANT: MCP Server Configuration Update Required
23+
24+ We've made changes to the MCP server that now require model API keys for local STDIO usage.
25+
26+ You're using the default Gemini model (${ modelName } ) but no API key is configured.
27+
28+ To fix this, you have two options:
29+
30+ 1. Set the GEMINI_API_KEY environment variable:
31+ export GEMINI_API_KEY="your-gemini-api-key"
32+
33+ 2. Or add the --modelApiKey flag to your MCP config:
34+ {
35+ "mcpServers": {
36+ "browserbase": {
37+ "command": "npx",
38+ "args": ["@browserbasehq/mcp"],
39+ "env": {
40+ "BROWSERBASE_API_KEY": "your-browserbase-key",
41+ "BROWSERBASE_PROJECT_ID": "your-project-id"
42+ "GEMINI_API_KEY": "your-gemini-api-key"
43+ }
44+ }
45+ }
46+ }
47+
48+ You can get a Gemini API key from: https://aistudio.google.com/app/apikey
49+
50+ 3. Or choose another supported model:
51+ Available models: https://docs.stagehand.dev/examples/custom_llms#llm-customization
52+
53+ {
54+ "mcpServers": {
55+ "browserbase": {
56+ "command": "npx",
57+ "args": [
58+ "@browserbasehq/mcp",
59+ "--modelName", "available-model",
60+ "--modelApiKey", "your-api-key",
61+ ],
62+ "env": {
63+ "BROWSERBASE_API_KEY": "your-browserbase-key",
64+ "BROWSERBASE_PROJECT_ID": "your-project-id"
65+ }
66+ }
67+ }
68+ }
69+
70+ The server will now attempt to start, but will likely fail without the API key...
71+ ` ) ;
72+ }
73+ }
974
10- export async function startStdioTransport ( serverList : ServerList ) {
1175 const server = await serverList . create ( ) ;
1276 await server . connect ( new StdioServerTransport ( ) ) ;
1377}
0 commit comments