Urgent.News

What's breaking now, across thousands of outlets.

Tech

What actually changes when an MCP server leaves your laptop

An MCP server that works locally is not the same as an MCP server that runs behind a gateway other people can reach. Every tutorial shows the local case because the local case is easy. The interesting problems only appear the moment another client, another tenant, or another team needs to talk to it. I built a small local lab to make those problems visible. This post is what I learned building…

When an MCP server operates locally on a laptop, it interacts with a single client, user, and workspace. In contrast, when an MCP server runs behind a gateway, it must accommodate multiple clients, each with distinct tokens, and multiple tenants, each possessing data that must remain segregated. A local demonstration of an MCP server fails to encapsulate these complexities, which become apparent when the server is accessed by other users or teams.

Four critical controls distinguish a local MCP server from one running behind a gateway:

1. Per-request authentication: A gateway cannot rely on long-lived sessions. Each request includes a bearer token, which the gateway verifies before consulting the tool registry. Failure to provide a correct token results in a 401 error, while an invalid path triggers a 404 error.

2. Tenant isolation at the gateway: Tenant scoping should occur at the edge, not within individual tools. If each tool is responsible for verifying tenant information, inconsistencies may arise. By enforcing tenant isolation before the tool is invoked, the gateway ensures that a tool cannot access another tenant’s data.

3. Write tools necessitate request-bound approval: Read-only tools can operate without additional measures. However, write tools require approval tied to a specific request ID and tool name, with an expiration time. This requirement ensures that write operations are managed securely and prevents unintended data modification.

4. Structured logs with a request ID per call: Every request is assigned a unique request ID, and all log entries include this ID. Sensitive information is masked within these logs before they are stored. This approach allows developers to trace the sequence of events leading to a failure, enhancing debugging and troubleshooting.

To illustrate these concepts, a small local lab was constructed, featuring a streamable HTTP gateway fronting a registry containing two tools: `documents.list` for read operations and `documents.archive` for write operations that require approval. A test client mimics a real MCP client's interactions with the gateway. The lab also incorporates deterministic failure injection to simulate scenarios such as a bad token (401), incorrect path (404), tool unavailability (408), and tool unresponsiveness (503).

The test suite consists of just 13 runtime tests, covering authentication, tenant boundaries, approval binding, and various failure statuses. This methodology does not rely on production dependencies, external services, or complex deployments. The full implementation is available at github.com/glatinone/mcp-local-to-hosted-deployment-fix.

Adopting this pattern when transitioning from a proof-of-concept MCP server to a production-ready solution enables teams to ensure secure, reliable, and well-documented interactions, addressing potential issues proactively.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The Retry That Restored Access

Retries keep distributed systems moving through timeouts and temporary failures. In an access system, though, an old retry can be more dangerous than a failed request.

More from Friday 11 September →