MCP SearXNG Go
高性能的 模型上下文协议(MCP) 用Go语言实现的服务器,为AI助手提供注重隐私的网页搜索功能,通过 SearXNG。
构建于 官方 MCP Go SDK 与谷歌合作维护。
](https://go.dev/)  ](https://www.docker.com/) 
特点/特性
- 🔍 看起来像一个放大镜的符号,常用于表示搜索或查看细节。 网页搜索由支持70多个搜索引擎的SearXNG元搜索引擎提供动力
- 🌐(这个符号本身在中文中没有直接对应的翻译,它通常代表“网络”或“互联网”的概念,可以简单理解为“网络”或“互联网”的标志。) URL内容提取获取网页并将其转换为Markdown格式
- 🔒(锁形符号,常用于表示安全、保密或锁定状态) 注重隐私所有搜索都通过您自己的SearXNG实例进行
- ⚡(闪电符号,常用于表示速度、活力、能量或电等概念,在中文中无直接对应词汇,通常保留原样或根据上下文意译) 高性能用Go语言构建,带有内存缓存(TTL为60秒)
- 🐳 这个表情符号通常代表“海豚”,在中文里可以简单翻译为“海豚”。不过,具体含义可能根据上下文有所不同,有时也可能被用作一种网络用语或特定社群内的梗。 Docker 已就绪使用docker-compose一键部署
- 🛡️ 译为中文是“盾牌”。 安全的非root容器执行,大小限制,请求超时
快速入门
先决条件
- 并且
- Go 1.25+(用于本地开发)
使用 Docker(推荐)
- 克隆仓库:
git clone https://github.com/Tomlord1122/mcp-searxng-claude-go.git
cd mcp-searxng-claude-go- 创建环境文件:
cp .env.example .env
echo "SEARXNG_SECRET=$(openssl rand -hex 16)" >> .env- 启动服务:
# Build and start both SearXNG and MCP server
docker compose up -d
# Or use convenience script
./start-mcp.sh- 验证它是否正在运行:
docker compose logs -f mcp-searxng-go- 设置您的环境以在Claude Code中使用
创建一个名为该名称的文件 ~/.mcp.json
{
"mcpServers": {
"searxng": {
"command": "docker",
"args": ["exec", "-i", "mcp-searxng-go", "/app/mcp-searxng-go"],
"env": {
"SEARXNG_URL": "http://searxng:8080"
}
}
}
}加上这个到 ~/.claude/settings.json
{
"permissions": {
"allow": [
"mcp__searxng__searxng_web_search",
"mcp__searxng__web_url_read"
]
},
"enabledMcpjsonServers": [
"searxng"
]
}
本地开发
- 安装依赖项:
make deps- 构建二进制文件:
make build- 本地运行:
# Requires a running SearXNG instance
SEARXNG_URL=http://localhost:8080 ./mcp-searxng-goMCP 工具
1. searxng_web_search
使用SearXNG进行网页搜索。
参数:
query(必填):搜索查询字符串pageno(可选):页码(默认:1)time_range(可选):按时间过滤 - “天”、“月”或“年”language(可选):语言代码(例如,“en”、“fr”、“de”,默认:“all”)safesearch(可选):安全搜索级别 - “0”,“1”,或“2”(默认:“0”)
示例:
{
"query": "Go programming best practices",
"pageno": 1,
"language": "en"
}2. web_url_read
读取网页内容并将其转换为Markdown格式。
参数:
url(必需):要获取的URLstartChar(可选):起始字符位置maxLength(可选):返回的最大字符数section(可选):提取特定标题部分paragraphRange(可选):段落范围(例如,“1-5”,“10-”)readHeadings(可选):仅返回标题(布尔值)
示例:
{
"url": "https://example.com/article",
"maxLength": 5000
}与Claude桌面版的集成
添加到您的Claude桌面配置中(~/Library/Application Support/Claude/claude_desktop_config.json (在 macOS 上):
{
"mcpServers": {
"searxng": {
"command": "docker",
"args": ["exec", "-i", "mcp-searxng-go", "/app/mcp-searxng-go"],
"env": {
"SEARXNG_URL": "http://searxng:8080"
}
}
}
}或者如果本地安装:
{
"mcpServers": {
"searxng": {
"command": "/usr/local/bin/mcp-searxng-go",
"env": {
"SEARXNG_URL": "http://localhost:8080"
}
}
}
}配置
环境变量
| 变量 | 必填 | 默认值 | 描述 |
|---|---|---|---|
SEARXNG_URL | ✅ 是 | - | SearXNG 实例的URL(例如。, http://localhost:8080) |
SEARXNG_SECRET | 推荐 | - | SearXNG 实例的密钥 |
AUTH_USERNAME | 编号 | - | SearXNG的基本认证用户名 |
AUTH_PASSWORD | 编号 | - | SearXNG的基本认证密码 |
HTTP_PROXY | 序号 | - | HTTP 代理 URL |
HTTPS_PROXY | 编号 | - | HTTPS 代理 URL |
CACHE_TTL | 编号 | 60 | 缓存生存时间(以秒为单位) |
SearXNG 配置
SearXNG 实例已自动配置为输出 JSON 格式。可以配置自定义搜索引擎以 searxng/config/settings.yml.
可用的Make命令
make help # Show all available commands
make deps # Download Go dependencies
make build # Build the binary
make run # Run locally (requires SEARXNG_URL)
make test # Run tests
make docker-up # Start Docker containers
make docker-down # Stop Docker containers
make docker-logs # View Docker logs
make install # Install to /usr/local/bin
make build-all # Build for multiple platforms建筑学
┌─────────────────────────┐
│ AI Assistant (Claude) │
└───────────┬─────────────┘
│ MCP Protocol (stdio)
│
┌───────────▼─────────────┐
│ MCP Server (Go) │
│ ┌──────────────────┐ │
│ │ Search Client │───┼──► SearXNG (Docker)
│ │ URL Reader │───┼──► Internet
│ │ Cache (60s TTL) │ │
│ └──────────────────┘ │
└─────────────────────────┘项目结构
mcp-searxng-claude-go/
├── main.go # Application entry point
├── searxng.go # SearXNG API client
├── urlreader.go # URL fetching and HTML-to-Markdown conversion
├── cache.go # In-memory caching with TTL
├── proxy.go # HTTP proxy configuration
├── resources.go # MCP resources (config, help)
├── Dockerfile # Multi-stage Docker build
├── docker-compose.yml # Service orchestration
├── Makefile # Build automation
└── .env.example # Environment template