SearXNG MCP Server について
SearXNG MCP Server は、AI アシスタントが SearXNG メタ検索エンジンを使って Web 検索を実行できるようにする MCP サーバーです。SearX.space からランダムに選ばれる公開インスタンスを既定で使うため、追加のデプロイなしで利用でき、基本認証付きのプライベートインスタンスにも対応しています。
主な機能
- 01既定の公開インスタンスによる設定不要の利用
- 02基本認証付きプライベートインスタンスへの接続
- 03言語、期間、カテゴリ、検索エンジンの指定
- 04Markdown 形式での検索結果の返却
活用シーン
- 01AI アシスタントへのリアルタイム Web 検索の追加
- 02セルフホストした SearXNG での検索
- 03期間指定によるニュースや最新情報の検索
MCP 対応
MCP サーバーとして searxngsearch ツールを MCP クライアントに公開し、SearXNG による検索を実行できるようにします。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
SearXNG MCP サーバー
プライバシーに配慮したメタ検索エンジンである SearXNG を使用して、AI アシスタントがウェブ検索を行えるようにする Model Context Protocol(MCP)サーバーです。SearX.space からランダムなインスタンスを自動選択するため、追加のデプロイなしですぐに利用できます。また、基本認証を使用するプライベートインスタンスにも対応しています。
このプロジェクトは非推奨です。後継は https://github.com/DasDigitaleMomentum/searxNcrawl の searxNcrawl です。
非推奨
このリポジトリは searxNcrawl を後継とするため、非推奨になりました。後継には現在、ラウンドロビン方式のインスタンス選択機能は含まれていません(通常、信頼性に欠けるためです)。適切な不具合報告を提出していただければ、追加できます。
機能
- 設定不要ですぐに利用可能:SearX.space のランダムな公開インスタンスを使用して、すぐに動作します
- プライベートインスタンスに対応:任意で基本認証を使用して、独自の SearXNG インスタンスに接続できます
- パラメーターをカスタマイズしてウェブ検索を実行
- 複数の検索エンジンに対応
- プライバシーを重視した検索結果
- Markdown 形式の検索結果
- すべてのパラメーターに適切なデフォルト値を設定
注意:公開インスタンスはこの用途で利用できず、「Request failed with status code 429」を返す場合があります
インストール
前提条件
- Node.js(v16 以降)
- npm(v7 以降)
- SearXNG インスタンス(セルフホストまたは公開)へのアクセス
ソースからインストール
# Clone the repository
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# Install dependencies
npm install
# Build the project
npm run build
設定
SearXNG MCP サーバーは、以下の環境変数で設定できます。
SEARXNG_URL(任意):SearXNG インスタンスの URL(例:https://searx.example.com)。指定しない場合は、SearX.space からランダムな公開インスタンスが自動選択されるため、追加のデプロイなしでサーバーを利用できます。USE_RANDOM_INSTANCE(任意):URL が指定されていない場合のランダムなインスタンス選択を無効にするには、"false" に設定します。デフォルトは "true" です。SEARXNG_USERNAME(任意):プライベートインスタンスへの接続時に使用する基本認証のユーザー名SEARXNG_PASSWORD(任意):プライベートインスタンスへの接続時に使用する基本認証のパスワード
プロジェクトのルートディレクトリにある .env ファイルで、これらの環境変数を設定できます。
SEARXNG_URL=https://searx.example.com
SEARXNG_USERNAME=your_username
SEARXNG_PASSWORD=your_password
使用方法
サーバーの実行
# If installed globally
searxngmcp
# If installed from source
node build/index.js
Claude Desktop との連携
- Claude Desktop を開きます
- Settings > MCP Servers に移動します
- 以下の設定で新しい MCP サーバーを追加します
{ "mcpServers": { "searxngmcp": { "command": "searxngmcp", "env": { // Optional: If not provided, a random public instance will be used "SEARXNG_URL": "https://searx.example.com", // Optional: Only needed for private instances with authentication "SEARXNG_USERNAME": "your_username", "SEARXNG_PASSWORD": "your_password" }, "disabled": false, "autoApprove": [] } } }
VSCode の Claude との連携
- VSCode を開きます
- Settings > Extensions > Claude > MCP Settings に移動します
- 以下の設定で新しい MCP サーバーを追加します
{ "mcpServers": { "searxngmcp": { "command": "node", "args": ["/path/to/searxng-mcp/build/index.js"], "env": { // Optional: If not provided, a random public instance will be used "SEARXNG_URL": "https://searx.example.com", // Optional: Only needed for private instances with authentication "SEARXNG_USERNAME": "your_username", "SEARXNG_PASSWORD": "your_password" }, "disabled": false, "autoApprove": [] } } }
Smolagents での使用
SearXNG MCP は、AI エージェントを構築するための軽量フレームワークである Smolagents と簡単に連携できます。これにより、ウェブを検索して結果を処理する強力なリサーチエージェントを作成できます。
from smolagents import CodeAgent, LiteLLMModel, ToolCollection
from mcp import StdioServerParameters
# Configure the SearXNG MCP server
server_parameters = StdioServerParameters(
command="node",
args=["path/to/searxng-mcp/build/index.js"],
env={
"SEARXNG_URL": "https://your-searxng-instance.com",
"SEARXNG_USERNAME": "your_username", # Optional
"SEARXNG_PASSWORD": "your_password" # Optional
}
)
# Create a tool collection from the MCP server
with ToolCollection.from_mcp(server_parameters) as tool_collection:
# Initialize your LLM model
model = LiteLLMModel(
model_id="your-model-id",
api_key="your-api-key",
temperature=0.7
)
# Create an agent with the search tools
search_agent = CodeAgent(
name="search_agent",
tools=tool_collection.tools,
model=model
)
# Run the agent with a search prompt
result = search_agent.run(
"Perform a search about: 'climate change solutions' and summarize the top 5 results."
)
print(result)
利用可能なツール
searxngsearch
プライバシーに配慮したメタ検索エンジンである SearXNG を使用してウェブ検索を実行します。パラメーターをカスタマイズして、関連するウェブコンテンツを返します。
パラメーター
| パラメーター | 型 | 説明 | デフォルト | 必須 |
|---|---|---|---|---|
| query | string | 検索クエリ | - | はい |
| language | string | 検索結果の言語コード(例:'en'、'de'、'fr') | 'en' | いいえ |
| time_range | string | 検索結果の期間。選択肢:'day'、'week'、'month'、'year' | null | いいえ |
| categories | array of strings | 検索対象のカテゴリ(例:'general'、'images'、'news') | null | いいえ |
| engines | array of strings | 使用する特定の検索エンジン | null | いいえ |
| safesearch | number | セーフサーチのレベル:0(オフ)、1(中程度)、2(厳格) | 1 | いいえ |
| pageno | number | 検索結果のページ番号。最小値は1です | 1 | いいえ |
| max_results | number | 返す検索結果の最大数。範囲:1~50 | 10 | いいえ |
例
// Example request
const result = await client.callTool('searxngsearch', {
query: 'climate change solutions',
language: 'en',
time_range: 'year',
categories: ['general', 'news'],
safesearch: 1,
max_results: 5
});
開発
セットアップ
# Clone the repository
git clone https://github.com/tisDDM/searxng-mcp.git
cd searxng-mcp
# Install dependencies
npm install
ビルド
npm run build
ウォッチモード(開発用)
npm run watch
MCP Inspector でのテスト
npm run inspector
ライセンス
MIT
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。