@brave/brave-search-mcp-server 2.0.68 → 2.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/config.js +13 -3
- package/dist/protocols/http.js +16 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,11 +114,12 @@ The server supports the following environment variables:
|
|
|
114
114
|
|
|
115
115
|
- `BRAVE_API_KEY`: Your Brave Search API key (required)
|
|
116
116
|
- `BRAVE_MCP_TRANSPORT`: Transport mode ("http" or "stdio", default: "stdio")
|
|
117
|
-
- `BRAVE_MCP_PORT`: HTTP server port (default:
|
|
117
|
+
- `BRAVE_MCP_PORT`: HTTP server port (default: 8000)
|
|
118
118
|
- `BRAVE_MCP_HOST`: HTTP server host (default: "0.0.0.0")
|
|
119
119
|
- `BRAVE_MCP_LOG_LEVEL`: Desired logging level("debug", "info", "notice", "warning", "error", "critical", "alert", or "emergency", default: "info")
|
|
120
120
|
- `BRAVE_MCP_ENABLED_TOOLS`: When used, specifies a whitelist for supported tools
|
|
121
121
|
- `BRAVE_MCP_DISABLED_TOOLS`: When used, specifies a blacklist for supported tools
|
|
122
|
+
- `BRAVE_MCP_STATELESS`: HTTP stateless mode (default: "true"). When running on Amazon Bedrock Agentcore, set to "true".
|
|
122
123
|
|
|
123
124
|
### Command Line Options
|
|
124
125
|
|
|
@@ -133,6 +134,7 @@ Options:
|
|
|
133
134
|
--logging-level <string> Desired logging level (one of _debug_, _info_, _notice_, _warning_, _error_, _critical_, _alert_, or _emergency_)
|
|
134
135
|
--enabled-tools Tools whitelist (only the specified tools will be enabled)
|
|
135
136
|
--disabled-tools Tools blacklist (included tools will be disabled)
|
|
137
|
+
--stateless <boolean> HTTP Stateless flag
|
|
136
138
|
```
|
|
137
139
|
|
|
138
140
|
## Installation
|
package/dist/config.js
CHANGED
|
@@ -32,6 +32,11 @@ export const configSchema = z.object({
|
|
|
32
32
|
.default('info')
|
|
33
33
|
.describe('Desired logging level')
|
|
34
34
|
.optional(),
|
|
35
|
+
stateless: z
|
|
36
|
+
.boolean()
|
|
37
|
+
.default(false)
|
|
38
|
+
.describe('Whether the server should be stateless')
|
|
39
|
+
.optional(),
|
|
35
40
|
});
|
|
36
41
|
const state = {
|
|
37
42
|
transport: 'stdio',
|
|
@@ -42,6 +47,7 @@ const state = {
|
|
|
42
47
|
ready: false,
|
|
43
48
|
enabledTools: [],
|
|
44
49
|
disabledTools: [],
|
|
50
|
+
stateless: false,
|
|
45
51
|
};
|
|
46
52
|
export function isToolPermittedByUser(toolName) {
|
|
47
53
|
return state.enabledTools.length > 0
|
|
@@ -53,10 +59,11 @@ export function getOptions() {
|
|
|
53
59
|
.option('--brave-api-key <string>', 'Brave API key', process.env.BRAVE_API_KEY ?? '')
|
|
54
60
|
.option('--logging-level <string>', 'Logging level', process.env.BRAVE_MCP_LOG_LEVEL ?? 'info')
|
|
55
61
|
.option('--transport <stdio|http>', 'transport type', process.env.BRAVE_MCP_TRANSPORT ?? 'stdio')
|
|
56
|
-
.option('--enabled-tools <names...>', 'tools to enable', process.env.BRAVE_MCP_ENABLED_TOOLS?.split(' ') ?? [])
|
|
57
|
-
.option('--disabled-tools <names...>', 'tools to disable', process.env.BRAVE_MCP_DISABLED_TOOLS?.split(' ') ?? [])
|
|
62
|
+
.option('--enabled-tools <names...>', 'tools to enable', process.env.BRAVE_MCP_ENABLED_TOOLS?.trim().split(' ') ?? [])
|
|
63
|
+
.option('--disabled-tools <names...>', 'tools to disable', process.env.BRAVE_MCP_DISABLED_TOOLS?.trim().split(' ') ?? [])
|
|
58
64
|
.option('--port <number>', 'desired port for HTTP transport', process.env.BRAVE_MCP_PORT ?? '8080')
|
|
59
65
|
.option('--host <string>', 'desired host for HTTP transport', process.env.BRAVE_MCP_HOST ?? '0.0.0.0')
|
|
66
|
+
.option('--stateless <boolean>', 'whether the server should be stateless', process.env.BRAVE_MCP_STATELESS === 'true' ? true : false)
|
|
60
67
|
.allowUnknownOption()
|
|
61
68
|
.parse(process.argv);
|
|
62
69
|
const options = program.opts();
|
|
@@ -67,7 +74,7 @@ export function getOptions() {
|
|
|
67
74
|
console.error('Error: --enabled-tools and --disabled-tools cannot be used together');
|
|
68
75
|
return false;
|
|
69
76
|
}
|
|
70
|
-
if ([...enabledTools, ...disabledTools].some((t) => !toolNames.includes(t))) {
|
|
77
|
+
if ([...enabledTools, ...disabledTools].some((t) => t.trim().length > 0 && !toolNames.includes(t.trim()))) {
|
|
71
78
|
console.error(`Invalid tool name used. Must be one of: ${toolNames.join(', ')}`);
|
|
72
79
|
return false;
|
|
73
80
|
}
|
|
@@ -94,6 +101,8 @@ export function getOptions() {
|
|
|
94
101
|
return false;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
104
|
+
// Normalize stateless to boolean (CLI passes it as string)
|
|
105
|
+
options.stateless = options.stateless === true || options.stateless === 'true';
|
|
97
106
|
// Update state
|
|
98
107
|
state.braveApiKey = options.braveApiKey;
|
|
99
108
|
state.transport = options.transport;
|
|
@@ -102,6 +111,7 @@ export function getOptions() {
|
|
|
102
111
|
state.loggingLevel = options.loggingLevel;
|
|
103
112
|
state.enabledTools = options.enabledTools;
|
|
104
113
|
state.disabledTools = options.disabledTools;
|
|
114
|
+
state.stateless = options.stateless;
|
|
105
115
|
state.ready = true;
|
|
106
116
|
return options;
|
|
107
117
|
}
|
package/dist/protocols/http.js
CHANGED
|
@@ -28,13 +28,22 @@ const getTransport = async (request) => {
|
|
|
28
28
|
await mcpServer.connect(transport);
|
|
29
29
|
return transport;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
31
|
+
let transport;
|
|
32
|
+
if (config.stateless) {
|
|
33
|
+
// Some contexts (e.g. AgentCore) may prefer or require a stateless transport
|
|
34
|
+
transport = new StreamableHTTPServerTransport({
|
|
35
|
+
sessionIdGenerator: undefined,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Otherwise, start a new transport/session
|
|
40
|
+
transport = new StreamableHTTPServerTransport({
|
|
41
|
+
sessionIdGenerator: () => randomUUID(),
|
|
42
|
+
onsessioninitialized: (sessionId) => {
|
|
43
|
+
transports.set(sessionId, transport);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
38
47
|
const mcpServer = createMcpServer();
|
|
39
48
|
await mcpServer.connect(transport);
|
|
40
49
|
return transport;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brave/brave-search-mcp-server",
|
|
3
3
|
"mcpName": "io.github.brave/brave-search-mcp-server",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.69",
|
|
5
5
|
"description": "Brave Search MCP Server: web results, images, videos, rich results, AI summaries, and more.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"api",
|