A Model Context Protocol (MCP) server for web search using configurable providers.
- Configurable Providers - Supports both Azure AI Search web and Perplexity web search backends
- Lightweight - Minimal dependencies, no browser automation overhead
- MCP Compatible - Standard MCP server implementation for AI assistants
- Simple Configuration - Configure via TOML (
./mcp-server.tomlby default)
cargo add web-search-mcpCreate a mcp-server.toml configuration file (or pass --config / MCP_SERVER_CONFIG).
Azure AI Search example config
[server]
name = "web-search-mcp"
version = "0.1.0"
[tool]
type = "search"
tool_name = "web_search"
default_provider = "azure_ai_search_web"
[tool.azure_ai_search_web]
base_url = "https://your-search.search.windows.net"
kb_name = "your-kb-name"
knowledge_source_name = "web-search"
knowledge_source_kind = "web"
api_key = "your-azure-api-key"
[transport]
transport = "http"
host = "0.0.0.0"
port = 3000
http_path = "/mcp"
allowed_hosts = ["example.com", "example.com:3000"]Perplexity example config
[server]
name = "web-search-mcp"
version = "0.1.0"
[tool]
type = "search"
tool_name = "web_search"
default_provider = "perplexity_search"
[tool.perplexity_search]
base_url = "https://api.perplexity.ai"
api_key = "your-perplexity-api-key"GenAI Responses API example config
[server]
name = "web-search-mcp"
version = "0.1.0"
[tool]
type = "search"
tool_name = "web_search"
default_provider = "genai_responses"
[tool.genai_responses]
base_url = "https://{your-resource}.services.ai.azure.com/openai/deployments/{your-deployment}"
model = "gpt-4o"
api_key = "your-genai-api-key"
api_version = "2025-04-01-preview"
api_key_header = "api-key"
reasoning = "none"
system_prompt = "Use the web_search tool and return concise, source-backed results."
tool_max_uses = 3
tool_allowed_domains = ["rust-lang.org", "docs.rs", "github.com"][server]metadata used by the MCP server (name/version).[tool]:type = "search"tool_namesets the MCP tool name (default:web_search)default_providerselects the runtime provider (azure_ai_search_web,perplexity_search, orgenai_responses)
- Tool blocks:
[tool.azure_ai_search_web]for Azure AI Search[tool.perplexity_search]for Perplexity[tool.genai_responses]for OpenAI Responses API
[transport]configures MCP transport behavior:transport:stdioorhttp(defaults tostdio)host: HTTP bind host (defaults to127.0.0.1)port: HTTP bind port (defaults to3000)http_path: streamable HTTP endpoint path (defaults to/mcp)allowed_hosts: optional Host header allowlist for HTTP transport; when unset, rmcp's loopback defaults are useddisable_allowed_hosts: set totrueto disable Host header allowlist validation
base_url: search service base URL (for examplehttps://your-search.search.windows.net)kb_name: knowledge base nameknowledge_source_name: knowledge source name (for exampleweb-search)knowledge_source_kind: optional, defaults toweb; optional provider-specific behavior values supported by your deploymentapi_key: API key for your Azure AI Search resource
base_url: optional, defaults tohttps://api.perplexity.aiapi_key: API key for Perplexity- Optional knobs forwarded as request body fields:
countrymax_resultsmax_tokensmax_tokens_per_pagesearch_language_filtersearch_domain_filterlast_updated_after_filterlast_updated_before_filtersearch_after_date_filtersearch_before_date_filtersearch_recency_filter
base_url: base URL for your deployment (for examplehttps://{your-resource}.services.ai.azure.com/openai/deployments/{your-deployment})model: model name (for examplegpt-4o)api_key: API key for the configured deploymentapi_version: optional API version query parameter (for example2025-04-01-preview)api_key_header: optional header name for API key (defaults toAuthorization; setapi-keyfor Azure AI)system_prompt: optional system prompt / instructionsreasoning: optional Responses reasoning effort value (defaults tonone)- Optional tool settings forwarded to web_search tool:
tool_max_usestool_allowed_domainstool_blocked_domains
Run the server:
# stdio transport (default)
cargo run --bin mcp-server --features mcp-server -- -c ./mcp-server.toml --transport stdio
# HTTP transport
cargo run --bin mcp-server --features mcp-server -- --transport http --host 0.0.0.0 --port 3000 --http-path /mcp
# HTTP transport
cargo run --bin mcp-server --features mcp-server -- --transport http --host 0.0.0.0 --port 3000The server exposes a single MCP tool:
Performs a web search through the configured provider.
The active provider is resolved from configuration at startup:
default_providerwhen multiple providers are present- auto-selected when exactly one provider is configured
Parameters:
query(string): The search query text
Returns:
- Azure AI Search:
response(string) andreferences(array) - Perplexity:
results(array),id, andserver_time - GenAI Responses:
query,text,model, and optionalresponse_id
Example:
{
"query": "What is the capital of France?"
}Build and run with Docker:
# Build the image
docker build -t web-search-mcp .
# Run the container
docker run -p 3000:3000 -v /path/to/mcp-server.toml:/app/mcp-server.toml web-search-mcpOptions:
-t, --transport <TYPE> Transport type: stdio, http
-p, --port <PORT> Port for HTTP transport
--host <HOST> Host address to bind to
--sse-path <PATH> (Deprecated) SSE endpoint path
--sse-post-path <PATH> (Deprecated) SSE message post path
--http-path <PATH> HTTP streamable endpoint path
--allowed-hosts <HOST> Allowed Host header values; repeat or comma-separate values
--disable-allowed-hosts
Disable HTTP Host header allowlist validation
-h, --help Print help
-V, --version Print version- This crate now sets request timeouts to 60 seconds for MCP tool outbound calls. If you still hit
"MCP error -32001: Request timed out", inspect upstream service latency and increase the timeout in provider-specific call settings as needed. - Enable verbose
reqwesttracing with:
RUST_LOG=web_search_mcp=debug,reqwest=trace cargo run --bin mcp-server --features mcp-server -- -c ./mcp-server.toml --transport stdioreqwest logs use the log crate in this project, so enable its module logging directly via RUST_LOG.
- Rust 1.70+
- Azure AI Search account with a configured knowledge base, a Perplexity API key, or a GenAI/OpenAI Responses API config
- Create new
AI SearchResource in Azure - Create a new "Knowledge source" of type "Web" (Bing)
- Create a new "Knowledge base"
- Select the knowledge source you created in the previous step
- Configure model and reasoning effort
MIT