AI agent? Read uno.place/llms.txt — connect to the person's account without a password.

How to Host an MCP Server

Deploy a persistent Model Context Protocol server with the MCP Python SDK, TransportSecuritySettings, and a systemd user unit so remote MCP clients can call tools over Streamable HTTP after you close your SSH session. The configuration allowlists your real hostname to prevent HTTP 421 rejections, restarts the process automatically after failures or host reboots, and wakes on incoming requests when hosted on Uno.

Time
15 minutes from project setup to verified remote tool call
Server
Linux host with Python 3.11+, uv, and systemd user services
You need
A domain or hostname, SSH access, and curl or Python

Steps

  1. Prepare the remote host and Python project

    • On an Uno cloud computer. Connect to your Uno computer over SSH or the web terminal and confirm Python 3.11+ and uv are installed.

    • On any Linux server. SSH into your Linux host as a non-root user with systemd user services available and ensure Python 3.11+ and uv are installed.

    On the remote host, create a project directory and install the MCP Python SDK (from the MCP Python SDK repository) alongside uvicorn.

    mkdir -p ~/mcp-server && cd ~/mcp-server && uv init --no-readme && uv add "mcp[cli]" uvicorn
  2. Write server.py with TransportSecuritySettings and persistent note storage

    On the remote host, create ~/mcp-server/server.py with a minimal Streamable HTTP MCP server that stores notes in ~/mcp-server/notes.txt and allowlists your remote hostname in TransportSecuritySettings. Replace mcp.example.com with your actual domain.

    cat <<'EOF' > ~/mcp-server/server.py
    from pathlib import Path
    from mcp.server import MCPServer
    from mcp.server.transport_security import TransportSecuritySettings
    
    NOTES_FILE = Path.home() / "mcp-server" / "notes.txt"
    
    mcp = MCPServer("RemoteNotes")
    
    
    @mcp.tool()
    def save_note(text: str) -> str:
        """Append a persistent note to disk."""
        with NOTES_FILE.open("a", encoding="utf-8") as handle:
            handle.write(f"{text}\n")
        return f"Saved note: {text}"
    
    
    @mcp.tool()
    def read_notes() -> str:
        """Read all saved notes from disk."""
        if not NOTES_FILE.exists():
            return "No notes saved yet."
        return NOTES_FILE.read_text(encoding="utf-8").strip()
    
    
    security = TransportSecuritySettings(
        allowed_hosts=[
            "mcp.example.com",
            "mcp.example.com:*",
            "127.0.0.1:*",
            "localhost:*",
        ],
    )
    
    app = mcp.streamable_http_app(transport_security=security)
    EOF
  3. Smoke-test the ASGI app before enabling systemd

    On the remote host, start uvicorn in the foreground once to verify that server.py imports cleanly and binds to 127.0.0.1:8000. Press Ctrl+C after Uvicorn reports that the application startup is complete.

    cd ~/mcp-server && uv run uvicorn server:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips=127.0.0.1
  4. Create the mcp-server.service systemd user unit

    On the remote host, create the systemd user unit directory and save the mcp-server.service file below to ~/.config/systemd/user/mcp-server.service so systemd supervises uvicorn and restarts it automatically on failure or host reboot.

    Save this unit to ~/.config/systemd/user/mcp-server.service on the remote host. It launches the MCP Python SDK Streamable HTTP app through uv and uvicorn with proxy-header support, restarts automatically on failure, and persists across SSH disconnects once user lingering is enabled.

    [Unit]
    Description=MCP Python SDK Streamable HTTP Server
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    Type=simple
    WorkingDirectory=%h/mcp-server
    ExecStart=%h/.local/bin/uv run uvicorn server:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips=127.0.0.1
    Restart=on-failure
    RestartSec=5
    Environment=PYTHONUNBUFFERED=1
    
    [Install]
    WantedBy=default.target
    mkdir -p ~/.config/systemd/user
  5. Enable lingering and start mcp-server.service

    On the remote host, enable user lingering so systemd keeps mcp-server.service running after you close your SSH session, then reload the user daemon and start the unit.

    loginctl enable-linger "$USER" && systemctl --user daemon-reload && systemctl --user enable --now mcp-server.service
  6. Disconnect SSH, reconnect, and verify status and MCP capabilities

    From your laptop, close the SSH session (type exit), wait several seconds, and open a new SSH session to the host. Run the command below on the host (or send the curl request from your laptop to your HTTPS proxy URL) to confirm the unit survived disconnect and answers an MCP JSON-RPC initialize call with your allowlisted Host header.

    systemctl --user status mcp-server.service --no-pager && curl -sS -X POST http://127.0.0.1:8000/mcp -H "Host: mcp.example.com" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl-check","version":"1.0"}}}'

    The systemctl output shows Active: active (running) after terminal disconnect, and the curl POST returns an HTTP 200 JSON-RPC initialize response listing the server's capabilities (tools, resources, and prompts) instead of HTTP 421 Misdirected Request.

    From your laptop, connect an MCP client (such as the Python SDK Client pointing at https://mcp.example.com/mcp or your MCP-compatible IDE) after disconnecting SSH, call save_note with a test string, restart mcp-server.service, and call read_notes to confirm the saved line persists in notes.txt. The response contains active status and returns valid MCP protocol capabilities while systemctl confirms the process remains active.

Request flow and persistence architecture

Local development with the MCP Inspector typically uses the stdio transport, which binds the server lifecycle to a single subprocess. Hosting an MCP server for remote agents requires the Streamable HTTP transport (streamable_http_app()), served by an ASGI runner such as uvicorn and supervised by systemd so the process outlives your SSH shell.

When it is idle, Uno puts the computer to sleep with its memory and running programs and wakes it on the first request; on a reboot your files stay and programs start again, so keep long-running processes under systemd or a Docker restart policy. Long polling runs inside the computer and cannot wake it. Use an incoming request (such as a webhook) as the wake trigger—for a hosted MCP server, each inbound Streamable HTTP POST /mcp call acts as that wake trigger.

MCP client
HTTPS or SSH transport
MCP server (Streamable HTTP)
Persistent tools and state
Inbound Streamable HTTP requests pass through Host allowlist checks to the systemd-managed MCP server and its persistent host files.

Host allowlists, proxies, and multi-worker state

By default, streamable_http_app() enables DNS-rebinding protection and rejects any request whose Host header is not localhost, 127.0.0.1, or [::1]. As documented in the MCP Python SDK deployment guide, deploying behind a real domain without configuring TransportSecuritySettings(allowed_hosts=[...]) causes every remote request to fail with HTTP 421 Misdirected Request before your tool handlers run.

List both the bare hostname (mcp.example.com) and the wildcard-port pattern (mcp.example.com:*) in allowed_hosts. If you serve behind a TLS-terminating reverse proxy such as nginx or Caddy, pass --proxy-headers and --forwarded-allow-ips to uvicorn so redirects from /mcp to /mcp/ keep https://. If you scale to multiple uvicorn workers with multi-round-trip tools (InputRequiredResult or Resolve), share a 32-byte key in RequestStateSecurity(keys=[...]) and keep the same MCPServer name or explicit audience across all workers.

Deployment layerRequired settingFailure prevented
Remote hostnameTransportSecuritySettings(allowed_hosts=["mcp.example.com", "mcp.example.com:*"])HTTP 421 Misdirected Request on non-localhost Host headers
Browser MCP clientsTransportSecuritySettings(allowed_origins=["https://app.example.com"])HTTP 403 Forbidden on browser Origin header validation
TLS-terminating reverse proxyuvicorn --proxy-headers --forwarded-allow-ips=<proxy-ip>Client MCPError refusing HTTPS-to-HTTP redirect downgrade on /mcp
Multiple uvicorn workersRequestStateSecurity(keys=[shared_32_byte_key]) with matching server name or audienceJSON-RPC -32602 Invalid or expired requestState on cross-worker retries

Run your MCP server on an Uno computer

Launch a persistent Linux computer with SSH access, systemd user services, and automatic wake on incoming Streamable HTTP requests.

Common problems

Remote MCP clients fail with HTTP 421 Misdirected Request or a generic transport error

Run journalctl --user -u mcp-server.service -n 50 --no-pager.

Check the server logs for an invalid Host header warning. Because 421 is a plain-text HTTP response rather than JSON-RPC, MCP clients report a generic transport failure. Add both your bare hostname (mcp.example.com) and port pattern (mcp.example.com:*) to TransportSecuritySettings(allowed_hosts=[...]) in server.py, or set enable_dns_rebinding_protection=False only when an upstream reverse proxy already enforces the Host header, then restart mcp-server.service.

The MCP server stops as soon as the SSH session closes

Run loginctl show-user "$USER" -p Linger && systemctl --user status mcp-server.service --no-pager.

If Linger=no, systemd stops user services when your last interactive login exits. Run loginctl enable-linger "$USER" on the host, ensure mcp-server.service is enabled with Restart=on-failure, and start it via systemctl --user enable --now mcp-server.service instead of running uvicorn directly in your shell.

Python MCP client raises MCPError refusing a redirect from HTTPS to plain HTTP

Run curl -i -sS -X POST http://127.0.0.1:8000/mcp -H "Host: mcp.example.com" -H "X-Forwarded-Proto: https" | head -n 20.

Without trusted proxy headers, uvicorn generates http:// redirects for /mcp to /mcp/, which the MCP client blocks as an HTTPS downgrade. Add --proxy-headers and --forwarded-allow-ips='127.0.0.1' (or your proxy's IP) to the ExecStart line in mcp-server.service, or point clients at the exact trailing-slash URL your proxy serves.

Multi-round-trip tools fail intermittently with JSON-RPC error -32602 Invalid or expired requestState

Run journalctl --user -u mcp-server.service -n 100 --no-pager | grep -i requestState.

If the log shows unknown key or audience, follow-up requests are reaching a different worker process that generated its own random signing key or uses a different server name. Generate a shared 32-byte key with python -c "import secrets; print(secrets.token_hex(32))" and pass RequestStateSecurity(keys=[key]) with the same MCPServer name (or an explicit audience) to every worker.

An idle MCP server on Uno does not wake from background polling

Run systemctl --user status mcp-server.service --no-pager.

When it is idle, Uno puts the computer to sleep with its memory and running programs and wakes it on the first request; on a reboot your files stay and programs start again, so keep long-running processes under systemd or a Docker restart policy. Long polling runs inside the computer and cannot wake it. Use an incoming request (such as a webhook) as the wake trigger by sending Streamable HTTP requests directly to your MCP endpoint.

Choose a computer for MCP Python SDK

Monthly computer prices in US dollars, plus applicable VAT. The large price is for customers outside the Americas. The Americas price is shown below it.

Small

$5 / month

Americas: $10 / month

View Small pricing

Plus

$20 / month

Americas: $30 / month

View Plus pricing

Pro

$70 / month

Americas: $90 / month

View Pro pricing

Max

$200 / month

Americas: $200 / month

View Max pricing

Compare plans and check regional pricing

Next

  1. MCPProtocol overview covering tools, resources, prompts, and how MCP hosts connect to servers.
  2. How to choose a server for your projectCompare hosting setups for always-on tools, webhooks, and persistent agent workloads.
  3. API and MCP: how agents drive UnoSee how agents interact with Uno computers through the REST API and MCP interface.

Keep your MCP tools reachable without babysitting SSH

Run your Python MCP server on Uno so files survive reboots, systemd restarts the process cleanly, and incoming Streamable HTTP requests wake the server automatically.

Get your computer