使用说明
搜索mcp
利用Brave MCP服务器
Brave Search MCP服务器
MCP服务器实现集成了Brave Search API,提供了全面的搜索功能,包括网络搜索、本地商业搜索、图像搜索、视频搜索、新闻搜索和人工智能摘要。此项目支持STDIO和HTTP传输,默认模式为STDIO。
迁移
1.x到2.x
现在默认传输STDIO
为了遵循既定的MCP惯例,服务器现在默认为STDIO。如果你想继续使用HTTP,你需要设置 BRAVE_MCP_TRANSPORT 环境变量 http,或提供运行时参数 --transport http 启动服务器时。
响应结构 brave_image_search
MCP服务器的1.x版本将返回base64编码的图像数据以及图像URL。这大大减慢了响应速度,并在会话中消耗了不必要的上下文。版本2.x删除base64编码的数据,并返回一个更接近反映原始Brave Search API响应的响应对象。更新的输出模式在中定义 src/tools/images/schemas/output.ts.
工具
网络搜索(brave_web_search)
使用丰富的结果类型和高级过滤选项执行全面的网络搜索。
参数:
query(字符串,必填):搜索词(最多400个字符,50个单词)country(字符串,可选):国家代码(默认值:“US”)search_lang(字符串,可选):搜索语言(默认:“en”)ui_lang(字符串,可选):用户界面语言(默认:“en-US”)count(数字,可选):每页结果(1-20,默认值:10)offset(数字,可选):分页偏移量(最大9,默认值:0)safesearch(字符串,可选):内容过滤(“关闭”、“中等”、“严格”,默认值:“中等”)freshness(字符串,可选):时间过滤器(“pd”、“pw”、“pm”、“py”或日期范围)text_decorations(布尔值,可选):包括突出显示标记(默认值:true)spellcheck(布尔值,可选):启用拼写检查(默认值:true)result_filter(数组,可选):筛选结果类型(默认值:[“web”,“query”])goggles(数组,可选):自定义重新排序定义units(字符串,可选):度量单位(“公制”或“英制”)extra_snippets(布尔值,可选):获取其他摘录(仅限专业版计划)summary(布尔值,可选):启用AI摘要的摘要密钥生成
本地搜索(brave_local_search)
搜索具有详细信息的本地企业和地点,包括评级、营业时间和人工智能生成的描述。
参数:
- 同
brave_web_search具有自动位置过滤功能 - 自动在result_filter中包含“web”和“位置”
注: 需要Pro计划才能获得完整的本地搜索功能。否则就回到网络搜索。
视频搜索(brave_video_search)
搜索具有全面元数据和缩略图信息的视频。
参数:
query(字符串,必填):搜索词(最多400个字符,50个单词)country(字符串,可选):国家代码(默认值:“US”)search_lang(字符串,可选):搜索语言(默认:“en”)ui_lang(字符串,可选):用户界面语言(默认:“en-US”)count(数字,可选):每页结果(1-50,默认值:20)offset(数字,可选):分页偏移量(最大9,默认值:0)spellcheck(布尔值,可选):启用拼写检查(默认值:true)safesearch(字符串,可选):内容过滤(“关闭”、“中等”、“严格”,默认值:“中等”)freshness(字符串,可选):时间过滤器(“pd”、“pw”、“pm”、“py”或日期范围)
图片搜索(brave_image_search)
搜索具有自动提取和base64编码的图像以直接显示。
参数:
query(字符串,必填):搜索词(最多400个字符,50个单词)country(字符串,可选):国家代码(默认值:“US”)search_lang(字符串,可选):搜索语言(默认:“en”)count(数字,可选):每页结果(1-200,默认值:50)safesearch(字符串,可选):内容过滤(“关闭”,“严格”,默认:“严格”)spellcheck(布尔值,可选):启用拼写检查(默认值:true)
新闻搜索(brave_news_search)
使用新鲜度控制和突发新闻指标搜索当前新闻文章。
参数:
query(字符串,必填):搜索词(最多400个字符,50个单词)country(字符串,可选):国家代码(默认值:“US”)search_lang(字符串,可选):搜索语言(默认:“en”)ui_lang(字符串,可选):用户界面语言(默认:“en-US”)count(数字,可选):每页结果(1-50,默认值:20)offset(数字,可选):分页偏移量(最大9,默认值:0)spellcheck(布尔值,可选):启用拼写检查(默认值:true)safesearch(字符串,可选):内容过滤(“关闭”、“中等”、“严格”,默认值:“中等”)freshness(字符串,可选):时间过滤器(默认值:“pd”表示过去24小时)extra_snippets(布尔值,可选):获取其他摘录(仅限专业版计划)goggles(数组,可选):自定义重新排序定义
摘要生成器搜索(brave_summarizer)
使用Brave的摘要API从web搜索结果生成AI摘要。
参数:
key(字符串,必填):网络搜索结果中的摘要键(使用summary: true在网络搜索中)entity_info(布尔值,可选):包含实体信息(默认值:false)inline_references(布尔值,可选):添加源URL引用(默认值:false)
用途: 首先使用执行网络搜索 summary: true,然后使用此工具返回的摘要键。
配置
获取API密钥
环境变量
服务器支持以下环境变量:
BRAVE_API_KEY:您的勇敢搜索API密钥(必需)BRAVE_MCP_TRANSPORT:传输模式(“http”或“stdio”,默认值:“stdio“)BRAVE_MCP_PORT:HTTP服务器端口(默认值:8080)BRAVE_MCP_HOST:HTTP服务器主机(默认值:“0.0.0.0”)BRAVE_MCP_LOG_LEVEL:所需的日志记录级别(“调试”、“信息”、“通知”、“警告”、“错误”、“严重”、“警报”或“紧急”,默认值:“信息”)BRAVE_MCP_ENABLED_TOOLS:使用时,为支持的工具指定白名单BRAVE_MCP_DISABLED_TOOLS:使用时,指定支持工具的黑名单
命令行选项
node dist/index.js [options]
Options:
--brave-api-key <string> Brave API key
--transport <stdio|http> Transport type (default: stdio)
--port <number> HTTP server port (default: 8080)
--host <string> HTTP server host (default: 0.0.0.0)
--logging-level <string> Desired logging level (one of _debug_, _info_, _notice_, _warning_, _error_, _critical_, _alert_, or _emergency_)
--enabled-tools Tools whitelist (only the specified tools will be enabled)
--disabled-tools Tools blacklist (included tools will be disabled)
安装
通过Smithery安装
通过以下方式自动安装Brave Search 史密瑟里:
npx -y @smithery/cli install brave
使用Claude Desktop
将此添加到您的 claude_desktop_config.json:
码头工人
{
"mcpServers": {
"brave-search": {
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "docker.io/mcp/brave-search"],
"env": {
"BRAVE_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}
NPX
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@brave/brave-search-mcp-server", "--transport", "http"],
"env": {
"BRAVE_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}
使用VS代码
为了快速安装,请使用下面的一键安装按钮:
对于手动安装,请将以下内容添加到您的用户设置(JSON)或 .vscode/mcp.json:
码头工人
{
"inputs": [
{
"password": true,
"id": "brave-api-key",
"type": "promptString",
"description": "Brave Search API Key",
}
],
"servers": {
"brave-search": {
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "mcp/brave-search"],
"env": {
"BRAVE_API_KEY": "${input:brave-api-key}"
}
}
}
}
NPX
{
"inputs": [
{
"password": true,
"id": "brave-api-key",
"type": "promptString",
"description": "Brave Search API Key",
}
],
"servers": {
"brave-search-mcp-server": {
"command": "npx",
"args": ["-y", "@brave/brave-search-mcp-server", "--transport", "stdio"],
"env": {
"BRAVE_API_KEY": "${input:brave-api-key}"
}
}
}
}
构建
码头工人
docker build -t mcp/brave-search:latest .
本地建设
npm install
npm run build
发展
先决条件
- Node.js 22.x或更高版本
- npm
- 勇敢搜索API密钥
设置
- 克隆存储库:
git clone https://github.com/brave/brave-search-mcp-server.git
cd brave-search-mcp-server
- 安装依赖项:
npm install
- 构建项目:
npm run build
通过Claude Desktop进行测试
添加对本地内置程序的引用 claude_desktop_config.json:
{
"mcpServers": {
"brave-search-dev": {
"command": "node",
"args": ["C:\\GitHub\\brave-search-mcp-server\\dist\\index.js"], // Verify your path
"env": {
"BRAVE_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}
通过MCP检查员进行测试
- 构建并启动服务器:
npm run build
node dist/index.js
- 在另一个终端中,启动MCP检查器:
npx @modelcontextprotocol/inspector node dist/index.js
STDIO是默认模式。对于HTTP模式测试,添加 --transport http 到检查器UI中的参数。
通过Smithery进行测试。人工智能
- 建立并获取smittery.ai帐户和API密钥
- 跑
npm run install,npm run smithery:build,最后npm run smithery:dev开始测试
可用脚本
-
npm run build:构建TypeScript项目 -
npm run watch:观察变化并重建 -
npm run format:使用Prettier格式化代码 -
npm run format:check:检查代码格式 -
npm run prepare:格式化和构建(在npm install上自动运行) -
npm run inspector:启动MCP Inspector的实例 -
npm run inspector:stdio:启动配置为STDIO的MCP Inspector实例 -
npm run smithery:build:为smithery.ai建立项目 -
npm run smithery:dev:启动smithery.ai的开发环境
Docker Compose
使用Docker进行本地开发:
docker-compose up --build
许可证
此MCP服务器根据MIT许可证获得许可。这意味着您可以根据MIT许可证的条款和条件自由使用、修改和分发软件。有关更多详细信息,请参阅项目存储库中的LICENSE文件。