torproxy
Provides tools for managing Tor circuits and executing HTTP/HTTPS or .onion requests through the Tor network, including checking status and exit IP, rotating identities, selecting exit countries, and running health or circuit diagnostics.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
🧅 torproxy
Quick Start · Transparent Gateway · Model Context Protocol (MCP) · Use Cases · Architecture · REST API · Configuration · Examples · Contributing
A production-grade, leak-proof Tor HTTP and SOCKS5 proxy packaged for Docker. Route entire container stacks without touching application code, equip AI coding assistants (Claude Desktop, Cursor) with native Tor tools via MCP, and rotate circuits dynamically with a single REST call.
🛡️ Zero Clearnet Leaks: Fail-closed netfilter kill-switch & Privoxy fail-safe — never leaks your real IP on connection drops.
🚀 Transparent Tor Gateway: Tunnel any container's TCP & DNS via
network_mode: "service:torproxy"— zero app config changes.🤖 Native AI Agent MCP Server: Built-in Model Context Protocol server (SSE & Stdio) for Claude Desktop, Cursor, and Antigravity.
🔄 Dynamic Circuit & Country Control: Switch identities (
SIGNAL NEWNYM) and select exit node countries on the fly via REST.🔒 Defense in Depth: Runs strictly as an unprivileged user (
torproxy), with ephemeral cookie authentication for Tor control.
Quick Start
Get up and running with a verified Tor circuit in seconds:
1. Launch torproxy
Clone and run via Docker Compose:
docker compose up -dOr launch directly via Docker Run without cloning:
docker run -d --name torproxy --restart unless-stopped \
-p 127.0.0.1:8118:8118 -p 127.0.0.1:9050:9050 -p 127.0.0.1:8080:8080 \
hapheus/torproxy:latest2. Verify Tor connectivity
# Verify HTTP proxy (returns {"IsTor": true, "IP": "..."})
curl -x http://127.0.0.1:8118 https://check.torproject.org/api/ip
# Verify SOCKS5 proxy with remote DNS resolution
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip
# Check live connection status via REST API
curl -s http://127.0.0.1:8080/status | jq .Leak-Proof Guarantee (Fail-Closed): If Tor disconnects or crashes, Privoxy immediately returns 503 Service Unavailable and the Netfilter kill switch drops outgoing packets. Your real IP will never silently leak to clearnet under network failures.
Security Note: In
docker-compose.yml, all ports bind strictly to127.0.0.1by default. Neither the proxy listeners nor the management API require authentication; do not expose them to untrusted networks.
# Request a fresh Tor identity without restarting the container:
curl -X POST http://127.0.0.1:8080/reconnect
# Switch exit country dynamically on reconnect:
curl -X POST "http://127.0.0.1:8080/reconnect?country=DE"
# Switch with strict exit country enforcement via JSON payload:
curl -X POST http://127.0.0.1:8080/reconnect \
-H "Content-Type: application/json" \
-d '{"country": "AT", "strict_nodes": true}'
# Or launch with a default country at startup:
TORPROXY_COUNTRY=DE docker compose up -dRelated MCP server: tor-mcp
🎯 When to Use torproxy
Understanding where torproxy excels helps you pick the right tool for the job:
✅ Ideal For:
Automated Web Scraping & Data Extraction: Distribute requests and bypass IP rate limits with dynamic circuit rotation.
AI Agent Automation (MCP): Allow Claude Desktop, Cursor, and agent frameworks to fetch web and
.onionpages safely.Zero-Friction Container Privacy: Tunnel third-party containers (crawlers, search engines, microservices) with zero code modifications.
Geolocation Verification: Test localized web experiences and CDN geo-routing across different exit countries (
TORPROXY_COUNTRY=DE,AT,US).Self-Hosted Privacy Stacks: Route upstream search queries (e.g. SearXNG) privately.
⚠️ Not Designed For:
High-Bandwidth / Latency-Critical Traffic: Tor is not designed for 4K video streaming, voice calls, or real-time gaming.
Bypassing Dedicated Anti-Bot Protection: Major CDNs (e.g., Cloudflare, Akamai) often challenge or block known public Tor exit nodes.
Architecture
Host Client / Dependent Containers
│
├── HTTP Requests ────────► Privoxy (:8118)
│ │ (forward-socks5t)
├── SOCKS5 Requests ──────────┼───────────────► Tor Daemon (:9050)
│ │ │
└── REST Control API ─────► API Server (:8080) │ (Cookie Auth)
│ │
└─ ControlPort ─────┘ (:9051 loopback)
│
▼
Tor Onion Network
▼
Target Website🚀 Transparent Tor Gateway
Route any existing Docker container's entire outbound TCP and DNS traffic automatically through Tor — without modifying your applications or adding proxy flags.
services:
torproxy:
image: hapheus/torproxy:latest
pull_policy: always
cap_add:
- NET_ADMIN
environment:
TORPROXY_GATEWAY_MODE: "true"
TORPROXY_COUNTRY: ${TORPROXY_COUNTRY:-}
restart: unless-stopped
# Attach any application container directly to torproxy's network namespace:
my-app:
image: curlimages/curl:latest
network_mode: "service:torproxy"
depends_on:
torproxy:
condition: service_healthy
command: ["-s", "https://check.torproject.org/api/ip"]Why use Transparent Gateway mode?
Zero Application Changes: No need to configure
HTTP_PROXY,ALL_PROXY, or browser arguments.Tor DNSPort (:9053): All DNS requests on port 53 (UDP & TCP) are automatically resolved via Tor to prevent DNS leaks.
Fail-Closed Netfilter Kill Switch: All direct clearnet traffic is blocked. If Tor stops or disconnects, connections fail closed immediately.
Process-Scoped WAN Bypass: Only the dedicated unprivileged
toruser may reach the WAN (owner --uid-owner); the API, Privoxy, and attached app containers cannot bypass the kill switch.IPv6: Tor may bootstrap over IPv6 (its own exception); every other process remains blocked — no IPv6 clearnet leaks.
UDP Protection: Unsupported non-DNS UDP traffic (e.g. QUIC/HTTP-3) is blocked with ICMP port-unreachable, ensuring fast fallback to TCP without hangs.
See the ready-to-run Transparent Gateway Example for details.
🤖 Model Context Protocol (MCP)
torproxy includes a built-in, zero-dependency Model Context Protocol (MCP) server on port 2501 (SSE) and via Stdio (torproxy mcp), allowing AI agents (Claude Desktop, Cursor, Antigravity) to manage Tor circuits and execute anonymized web requests directly.
Claude Desktop Integration (claude_desktop_config.json)
Connect Claude Desktop to your running torproxy container via Stdio without exposing host ports:
{
"mcpServers": {
"torproxy": {
"command": "docker",
"args": ["exec", "-i", "torproxy", "torproxy", "mcp"]
}
}
}Cursor & Antigravity Integration (.cursor/mcp.json)
Connect via HTTP/SSE:
{
"mcpServers": {
"torproxy": {
"url": "http://127.0.0.1:2501/sse"
}
}
}Or use the root-level .mcp.json manifest auto-detected by Cursor and cursor.directory on workspace open.
Smithery.ai Integration (smithery.yaml)
Install directly with zero configuration via Smithery.ai:
npx -y @smithery/cli install hapheus/torproxy --client claudeKey Tools Available to Agents
torproxy_fetch: Zero-config fetch — execute HTTP/HTTPS or.onionrequests strictly routed through Tor (no local curl or host proxy setup needed).torproxy_status: Retrieve live bootstrap progress, egress IP, and GeoIP metadata.torproxy_get_ip: Query the current verified Tor exit IP.torproxy_reconnect: Request a new Tor identity (SIGNAL NEWNYM), optionally changing exit country (country="DE").torproxy_health&torproxy_diagnostics: Automated operational health and circuit diagnostics.
See docs/mcp.md for full configuration details, authentication options, and tool schemas.
Available Interfaces and Ports
Interface | Default Port | Internal Service | Description |
HTTP Proxy |
| Privoxy | HTTP/HTTPS forward proxy routing traffic to Tor. Fails closed (500/503) if Tor is disconnected. |
SOCKS5 Proxy |
| Tor | Direct Tor SOCKS5 listener. Supports remote DNS resolution via |
REST API |
| Python REST API | JSON management and health endpoint. Circuit rotation and connection management. |
MCP Server (SSE) |
| Python MCP Server | Model Context Protocol server (SSE) for AI agents (Cursor, Antigravity). |
TransPort (Gateway Mode) |
| Tor | Transparent TCP proxy redirect listener when |
DNSPort (Gateway Mode) |
| Tor | Transparent DNS resolver listener when |
REST API Reference
The lightweight API server on port 8080 manages circuits and monitors health without requiring clients to implement the Tor Control Protocol.
Endpoint | Method | Status Code | Purpose | Example Response |
|
|
| Connection status and current exit IP. |
|
|
|
| Current verified Tor exit IP. Returns 503 while bootstrapping. |
|
|
|
| Structured diagnostic health state across Tor, proxies, and egress. |
|
|
|
| Operational telemetry (uptime, reconnect counts, bootstrap progress). |
|
|
|
| Prometheus exposition format metrics for scrapers. | Plaintext Prometheus metrics. |
|
|
| Request new circuit ( |
|
|
|
| Pause Tor network traffic ( |
|
|
|
| Resume Tor network traffic ( |
|
HTTP Methods:
POSTis recommended for state mutations (/reconnect,/disconnect,/connect). LegacyGETcalls remain fully supported for backward compatibility. Mutations presented with a foreign browserOrigin/Refererare rejected with403 Forbidden(CSRF protection);curl/script calls without those headers are unaffected. Authentication (Recommended): Unauthenticated by default for backward compatibility. SettingTORPROXY_API_TOKEN(orTORPROXY_API_KEY) protects all endpoints withAuthorization: Bearer <token>orX-API-Key: <token>. Detailed schema definitions are documented in docs/api.md.
Container Health Checks
torproxy includes a ready-aware Docker health check (docker/healthcheck.sh). A container reports healthy only when:
Privoxy and Tor daemons are running under non-root user.
Tor bootstrap is 100% complete (
bootstrapped=done).SOCKS5 listener on port 9050 passes greeting handshake.
Egress IP is confirmed through Tor (
IsTor: true).
In Docker Compose, dependent services can wait for genuine Tor readiness using service_healthy:
services:
app:
image: my-scraper:latest
depends_on:
torproxy:
condition: service_healthyConfiguration
Default settings work out-of-the-box with zero configuration. You can customize runtime behavior using environment variables in .env or Docker Compose:
Variable | Default | Purpose |
| (unset) | Restrict exit nodes to specific countries (e.g. |
|
| When |
|
| Enable Transparent Tor Gateway mode ( |
| (unset) | Bearer token / API key securing REST API port |
|
| Opt-in: periodically download and refresh Tor's GeoIP database from Tor Project GitLab. |
📖 Full Configuration Reference: See docs/configuration.md for custom listening ports (
TORPROXY_LISTEN_PORT,TORPROXY_SOCKS_PORT,TORPROXY_API_PORT), address binding rules, and GeoIP update parameters.
Shipped Examples
Ready-to-run use cases with hardened configurations:
Example | Purpose | Guide |
Transparent Tor Gateway | Route any container's entire TCP & DNS traffic automatically through Tor without proxy settings. | |
Hardened Production | Read-only rootfs, dropped capabilities, and memory-backed tmpfs. | |
Browserless Chromium | Headless browser automation and scraping routed through Tor. | |
CRW Web Scraper | High-performance webpage-to-Markdown scraper via Tor proxy. | |
SearXNG Metasearch | Private, self-hosted search engine routing upstream queries via Tor. |
Security Model and Trust Boundaries
Non-Root Execution: The container init starts as root only to drop privileges — every daemon runs as an unprivileged user (
tor,privoxy,torproxy). In gateway mode the netfilter WAN bypass is scoped to the dedicatedtorUID, so the API/Privoxy cannot reach the WAN directly (ISSUE-03).Authenticated ControlPort: Tor's control port (
127.0.0.1:9051) requires ephemeral filesystem cookie authentication (CookieAuthentication 1).Fail-Closed Guarantee: If Tor disconnects or crashes, Privoxy drops traffic and returns HTTP 503 instead of leaking to clearnet.
DNS Leak Prevention: To prevent local DNS leaks, always use remote DNS resolution with SOCKS5 (
curl --socks5-hostname 127.0.0.1:9050orsocks5h://).Threat Model: See SECURITY.md for vulnerability reporting procedures, threat boundaries, and anonymity limitations.
Hardening Guide: See docs/hardening.md for read-only rootfs and dropped Linux capabilities.
Project Documentation
docs/compatibility.md — Backward compatibility contract and frozen interfaces.
docs/api.md — Exhaustive REST API specification and response schemas.
docs/configuration.md — Configuration guide and startup validation rules.
docs/hardening.md — Container runtime hardening, read-only rootfs, and security recommendations.
docs/releases.md — Semantic versioning policy, upgrade paths, and rollback procedures.
Contributing
We welcome contributions! Please review our Contributing Guidelines and Code of Conduct. All PRs must maintain backward compatibility, include hermetic unit tests, and maintain >= 90% test coverage.
License
Released under the MIT License.
💝 Support the Project
If you find this project helpful, consider showing some support:
☕ Buy me a coffee: Send a tip via PayPal.
❤️ Charity Donation: Donate to Österreichische Krebshilfe (Austrian Cancer Aid) or any local animal welfare organization.
🎯 Dream Support: I would love some tickets for the World Darts Championship at Ally Pally (Alexandra Palace) – hopefully, I will make it there one day!
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Route HTTP requests through the Tor network. Rotating exit IPs, .onion support, no body logging.
Tor gateway for AI agents: fetch URLs and rotate circuits through Tor, Bitcoin-settled.
No-KYC VPS + per-second code sandboxes AI agents run over MCP — 75 tools, SDK, pay BTC/XMR/USDC/USDT
Free remote MCP server for fetching public web pages through a rotating proxy pool.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceRoutes HTTP requests through the Tor network, enabling anonymous web fetching, exit IP checks, circuit renewal, and site reachability checks from MCP-compatible agents like Claude Desktop and Cursor.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables MCP-compatible agents to route HTTP requests through the Tor network, providing anonymity and access to .onion services. Includes tools for fetching URLs, checking exit IP, and forcing new Tor circuits.MIT
- AlicenseNot gradedqualityFmaintenanceLightweight MCP security proxy — compression (up to 86%) + SSRF protection + allow/deny + audit + rate limiting + injection detection60 npm180MIT
- AlicenseBqualityDmaintenanceMCP server that connects AI assistants to a supervised Firefox session routed through Tor, enabling browsing of HTTP(S) and .onion pages, reading content, taking screenshots, extracting forum data, and managing sessions.271MIT