Skip to content

Instantly share code, notes, and snippets.

@tripplyons
Last active September 26, 2025 14:32
Show Gist options
  • Save tripplyons/a2f9d8bd553802f9296a7ec3b46760de to your computer and use it in GitHub Desktop.
Save tripplyons/a2f9d8bd553802f9296a7ec3b46760de to your computer and use it in GitHub Desktop.
Free web search MCP using a local SearXNG instance
mkdir -p config data
cat > config/settings.yml << 'EOF'
server:
bind_address: "0.0.0.0"
secret_key: "secret"
search:
formats:
- html
- json
EOF
docker run --rm --name searxng \
-p 8080:8080 \
-v "./config/:/etc/searxng/" \
-v "./data/:/var/cache/searxng/" \
docker.io/searxng/searxng:latest
# dependencies for pip:
# pip install requests "mcp[cli]"
from mcp.server.fastmcp import FastMCP
import requests
mcp = FastMCP("searx")
@mcp.tool()
def search_web(query: str) -> str:
"""Search the web for information"""
response = requests.get(f"http://localhost:8080/search?format=json&q={query}")
data = response.json()
return "\n\n".join(
[
result["title"] + "\n" + result["url"] + "\n" + result["content"]
for result in data["results"]
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment