使用说明
mcp网络搜索
使用的Web搜索MCP服务器 勇敢搜索API 建于 FastMCP.
特性
- 5搜索工具 -网络、新闻、图片、视频和建议
- 丰富的过滤功能 -国家、语言、新鲜度、安全搜索
- 流式HTTP传输 -部署为远程MCP服务器
- 免费套餐可用 -2000次查询/月
工具
web_search
在网上搜索信息。
web_search(query="Python asyncio tutorial")
web_search(query="climate change", freshness="pw", country="us")
news_search
搜索最近的新闻文章。
news_search(query="AI regulations")
news_search(query="tech layoffs", freshness="pd")
image_search
搜索图像。
image_search(query="sunset over mountains")
image_search(query="modern architecture", safe_search="strict")
video_search
搜索视频。
video_search(query="Python tutorial for beginners")
video_search(query="cooking pasta", freshness="pm")
suggest
获取搜索查询建议/自动完成。
suggest(query="how to")
suggest(query="python", count=10)
参数
公共参数
| 参数 | 类型 | 说明 |
|---|---|---|
query |
str | 搜索查询(必填) |
count |
int | 结果数(1-20,默认值:10) |
country |
str | 国家代码(例如“us”、“gb”、“de”) |
search_lang |
str | 语言代码(例如“en”、“de”、“fr”) |
safe_search |
str | 内容过滤器:“关闭”、“中等”、“严格” |
新鲜度过滤器
按时间筛选结果:
| 价值 | 含义 |
|---|---|
pd |
过去一天 |
pw |
上周 |
pm |
上个月 |
py |
过去一年 |
安装
# Clone the repository
git clone https://github.com/agentic-forge/mcp-web-search.git
cd mcp-web-search
# Install dependencies
uv sync
配置
从获取API密钥 勇敢搜索API.
设置环境变量:
export BRAVE_API_KEY="your-api-key-here"
或者创建一个 .envrc.local 文件:
export BRAVE_API_KEY="your-api-key-here"
运行服务器
HTTP传输(建议用于远程访问)
# Default: HTTP on port 8001
uv run python -m forge_mcp_web_search
# Custom port
uv run python -m forge_mcp_web_search --port 3000
服务器将在 http://localhost:8001/mcp
STDIO传输(适用于本地MCP客户端)
uv run python -m forge_mcp_web_search --stdio
MCP客户端配置
克劳德桌面版
添加到 claude_desktop_config.json:
{
"mcpServers": {
"web-search": {
"command": "uv",
"args": ["run", "python", "-m", "forge_mcp_web_search", "--stdio"],
"cwd": "/path/to/mcp-web-search",
"env": {
"BRAVE_API_KEY": "your-api-key"
}
}
}
}
远程HTTP服务器
{
"mcpServers": {
"web-search": {
"url": "http://localhost:8001/mcp"
}
}
}
使用Anvil进行测试
使用 锻造铁砧 要测试服务器,请执行以下操作:
# Start the server
export BRAVE_API_KEY="your-api-key"
uv run python -m forge_mcp_web_search
# In another terminal
cd /path/to/forge-anvil
export ANVIL_SERVER=http://localhost:8001/mcp
# List tools
anvil list-tools
# Search the web
anvil call web_search --json-args '{"query": "Python tutorial"}'
# Search for news
anvil call news_search --json-args '{"query": "AI news", "freshness": "pd"}'
# Get suggestions
anvil call suggest --arg query="how to"
发展
# Install dev dependencies
uv sync --group dev
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov
# Type checking
uv run basedpyright
# Linting
uv run ruff check .
# Install pre-commit hooks
uv run pre-commit install
API费率限制
| 层级 | 费率 | 每月限额 | 成本 |
|---|---|---|---|
| 免费人工智能 | 1个请求/秒 | 2000个查询 | 0美元 |
| 基础人工智能 | 20个请求/秒 | 2000万次查询 | 5/1k美元 |
| Pro AI | 50个要求/秒 | 无限制 | 9/1k美元 |
许可证
麻省理工学院