ScreenshotNeo

BlogAI agents

How to Use an MCP Router as a Gateway

Learn how to place an MCP router between clients and multiple MCP servers or REST APIs, with setup, security, routing, testing, and troubleshooting guidance.

By the ScreenshotNeo team1 October 202610 min read

How to use an MCP router as a gateway: run a client-facing MCP endpoint that authenticates requests, exposes an intentional tool catalog, and routes each tool call to a selected MCP server or REST operation. The exact behavior depends on the implementation. Some gateways proxy existing MCP servers; others translate MCP JSON-RPC calls into REST requests; some also provide lifecycle management, authorization, session-aware routing, or protocol translation.

A reliable deployment follows this sequence: choose the backend model, register upstreams or API operations, allowlist the tools, configure identity and authorization for discovery and invocation, deploy the endpoint, then verify initialization, tools/list, and a safe tool call.

What an MCP router gateway does

The terms router and gateway are used differently by different projects. Microsoft’s MCP Gateway describes a reverse proxy and management layer with adapters for direct MCP server access and a tool router that directs calls to registered tools. Its documentation also discusses session-aware routing and lifecycle management. Google Cloud API Gateway can act as a remote MCP server that maps MCP messages to HTTP REST operations and maps backend responses back to MCP responses. AWS describes the broader pattern as a centralized proxy for registered MCP servers that can provide one endpoint for authentication, authorization, routing, and protocol translation.

Do not assume every product supports every capability. Before selecting one, check:

  • Whether it proxies MCP servers, translates REST APIs, or supports both.
  • Which MCP transports and protocol versions it accepts.
  • How upstream servers are registered and how routes are selected.
  • Whether sessions require affinity or a distributed session store.
  • How tool discovery and tool invocation are authenticated.
  • How backend credentials, secrets, network access, and filesystem access are delegated.
  • Whether the implementation is stable, preview, self-hosted, or managed.

Reference architecture

A gateway normally sits between MCP clients such as an agent, IDE, or service and one or more backends:

  1. The client connects to one MCP endpoint.
  2. The gateway authenticates the client and applies discovery policy.
  3. The client initializes the MCP session and requests the available tools.
  4. The gateway returns only the tools selected for that client or deployment.
  5. A tool call is matched to a registered MCP server or REST operation.
  6. The gateway forwards the request with only the credentials and permissions that backend requires.
  7. The backend result is returned as an MCP result or error.

For HTTP transports, consult the MCP HTTP authorization guidance. The MCP specification states that STDIO implementations should not use that HTTP authorization framework; STDIO servers should retrieve credentials from the environment instead.

How do I connect multiple MCP servers through one endpoint?

1. Inventory the backends

Write down each server, transport, endpoint, credentials, intended tools, and data sensitivity. Decide whether the gateway should expose a server’s complete catalog or selected tools only. Start with the smallest useful surface.

2. Select the gateway topology

Topology Use it when Decisions to verify
MCP proxy You already operate MCP servers. Upstream transport, health checks, routing keys, credential forwarding, session handling.
MCP-to-REST translation Your capabilities are ordinary HTTP APIs. OpenAPI operation eligibility, tool names and descriptions, request mapping, response and error mapping.
Hybrid You have both MCP servers and REST APIs. Consistent authorization, naming, rate limits, and observability across both backend types.

3. Register servers or API operations

For an MCP proxy, configure one adapter or upstream definition per server, including its endpoint and transport. For a REST-backed gateway, configure the backend address and the OpenAPI operations that may appear as tools. Google’s configuration supports global or per-operation MCP exposure and allows an operation to be explicitly excluded. Eligible operations need a backend and resolvable tool descriptions.

4. Define the tool catalog deliberately

Tool discovery is an access decision. Use stable names, precise descriptions, input schemas, and safe defaults. Avoid exposing administrative, destructive, or broad data-export operations merely because they exist in an API. In Google’s implementation, names default to an operation ID and descriptions come from an operation description or summary unless overridden.

5. Configure identity and authorization

Protect both the catalog and the calls. Google recommends securing tools/list; its documentation describes separate authentication behavior for discovery and invocation. Confirm that authorization is enforced on the routed backend call, not only on a gateway management endpoint. Use least-privilege credentials and restrict each backend’s environment variables, secrets, mounts, network access, and routing permissions.

6. Deploy and verify the protocol

Use a client or an HTTP test harness to perform the initialization handshake, enumerate tools, and invoke one harmless operation. The following example shows the shape of an MCP-over-HTTP request; adapt the URL, headers, protocol version, and session handling to your gateway.

curl -i https://gateway.example.com/mcp \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  --data-binary '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"initialize",
    "params":{
      "protocolVersion":"2025-06-18",
      "capabilities":{},
      "clientInfo":{"name":"gateway-check","version":"1.0.0"}
    }
  }'

After the server returns its negotiated protocol information, send the notification or follow-up required by that implementation, then list tools:

curl -i https://gateway.example.com/mcp \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  --data-binary '{
    "jsonrpc":"2.0",
    "id":2,
    "method":"tools/list",
    "params":{}
  }'

Finally call a non-destructive tool using its exact name and schema:

curl -i https://gateway.example.com/mcp \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  --data-binary '{
    "jsonrpc":"2.0",
    "id":3,
    "method":"tools/call",
    "params":{
      "name":"health_check",
      "arguments":{}
    }
  }'

Exposing a REST API as MCP tools

A REST translation gateway needs more than a URL rewrite. It must map an MCP tool name and JSON input schema to an HTTP method, path, query, headers, and body, then map the HTTP response into an MCP result or a structured error.

  1. Import or write an OpenAPI description with operation IDs, summaries, descriptions, request schemas, response schemas, and security requirements.
  2. Configure the backend URL and credentials separately from the public MCP endpoint.
  3. Allowlist only the operations intended for agents. If the gateway supports global exposure, explicitly opt sensitive operations out.
  4. Review generated tool names and descriptions; change them when they are ambiguous or reveal internal implementation details.
  5. Test validation failures, upstream timeouts, non-2xx responses, pagination, and empty responses.
  6. Confirm that authorization is applied to the underlying operation as well as to tool discovery.

Do not describe REST translation as a universal MCP gateway feature. Google documents this design for API Gateway, while other implementations may only proxy existing MCP servers.

Security checklist

  • Protect discovery: require authentication for tools/list when the catalog contains private capabilities.
  • Authorize invocation: enforce policy at the gateway and at the backend resource where possible.
  • Separate identities: use a distinct gateway identity and narrowly scoped backend credentials.
  • Minimize secrets: pass only the environment variables and secrets a server needs.
  • Restrict network reach: prevent a tool server from reaching unrelated internal services.
  • Review schemas: constrain paths, URLs, identifiers, and free-form commands that could enable data exfiltration or destructive actions.
  • Audit changes: record tool catalog changes, authorization decisions, backend failures, and operator changes.
  • Handle transports correctly: use HTTP authorization guidance for HTTP transports; use environment credentials for STDIO.
  • Re-test after changes: adding a tool or changing identity rules can alter what an agent can discover and invoke.

Sessions, routing, and scaling

Stateless tool calls can usually be distributed across gateway instances. Stateful MCP servers may require session affinity or a shared session store. Microsoft’s project documents session-aware routing and a distributed session store for production mode; that behavior is implementation-specific, not a requirement of every gateway.

Choose a routing key deliberately:

  • Use a session identifier when a backend keeps conversational state.
  • Use a tenant or principal identifier when isolation matters.
  • Use consistent hashing only when the gateway documents its failure and rebalancing behavior.
  • Prefer stateless backends when possible so instances can scale and recover independently.

Set separate timeouts for client request handling, gateway-to-backend connection, backend response, and streamed output. Bound concurrent calls per client and per backend. If a backend is slow, return a clear timeout error and preserve a correlation ID for investigation.

Performance, reliability, and cost

Concern Practical guidance
Latency Measure gateway overhead separately from backend time. Keep routing and policy checks local and avoid unnecessary protocol conversions.
Cold starts Keep gateway and adapter processes warm when startup cost affects interactive agents.
Retries Retry only idempotent operations. Never blindly retry mutations or calls with unknown commit status.
Backpressure Cap concurrent calls and queue depth. Return bounded, actionable errors when limits are reached.
Availability Run multiple gateway instances when supported, and ensure session state is replicated if sessions are not disposable.
Observability Track request ID, principal, tool name, backend, duration, status, timeout, and policy decision without logging secrets or sensitive arguments.
Cost Account for gateway hosting, backend calls, logging, network egress, and any managed gateway request charges. REST translation may add processing and serialization overhead.

Troubleshooting

Symptom Likely cause Fix
Initialization fails with an unsupported version Client and gateway do not share a protocol version. Inspect the gateway’s supported versions and negotiate one it documents. Upgrade only after checking backend compatibility.
tools/list is empty No server or operation is registered, exposure is disabled, or policy hides the catalog. Check registration, allowlists, operation IDs, and discovery authorization separately.
Tools are visible but calls return unauthorized Discovery and invocation use different policies or backend credentials are missing. Test the actual tool call with the intended principal and verify backend authorization and credential forwarding.
Gateway returns “tool not found” The client used a display label instead of the registered tool name. Copy the exact name from tools/list and check for namespace or adapter prefixes.
REST calls return 404 Path templating or backend base URL is wrong. Log the resolved method and URL without secrets, then compare it with the OpenAPI server and path template.
REST calls return 400 Input schema does not match query, path, or body mapping. Validate the MCP arguments against the generated schema and inspect required fields and types.
Requests hang Backend timeout, stream handling issue, or a missing session route. Set bounded timeouts, test the backend directly, and verify affinity or shared session state.
Calls reach the wrong server Ambiguous tool names or a route selector that is too broad. Namespace tools, make routing rules deterministic, and add a test for every critical mapping.
Works on one instance but not another In-memory session state or inconsistent configuration. Use a shared session store where required and deploy identical gateway and adapter configuration.
STDIO authentication fails after adding HTTP headers HTTP authorization rules were applied to a STDIO server. Provide credentials through the environment as required by the MCP specification.

Or skip the browser setup

If one of the tools behind your gateway needs website screenshots, ScreenshotNeo gives you a single HTTP endpoint instead of maintaining a browser worker. It accepts a URL and returns PNG, JPEG, WebP, or PDF. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools, so an AI agent can call it directly.

See the ScreenshotNeo API documentation for the complete option list and gateway integration details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' }); const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Every plan includes the same feature set: full-page and element capture, dark mode, device presets, retina scale, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, bulk capture, usage reporting, and an OpenAPI specification. You get 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

Deployment checklist

  • Backend servers and REST operations are inventoried.
  • Only intended tools are exposed.
  • Tool names, descriptions, and schemas are reviewed by an operator.
  • tools/list and tools/call have explicit authorization behavior.
  • Backend credentials and network access are least privilege.
  • Initialization, discovery, one safe call, timeout, and denial paths are tested.
  • Session affinity or shared state is configured if a backend needs it.
  • Logs include correlation data but exclude secrets and sensitive arguments.
  • Preview or changing product features are checked against current vendor documentation.

FAQ

Is an MCP router a standard product?

No. It is a gateway pattern implemented by different projects and managed services with different transports, routing, security, and lifecycle features.

Can one gateway combine MCP servers and REST APIs?

Some implementations support both, but a proxy for MCP servers and an MCP-to-REST translator are different designs. Confirm that the selected gateway documents both modes.

Should every backend tool be exposed?

No. Treat discovery as part of the security boundary and allowlist the smallest tool set that fulfills the use case.

Does MCP authorization apply to STDIO?

The HTTP authorization framework applies to HTTP transports. The specification directs STDIO implementations to obtain credentials from the environment.

Do I need a physical router appliance?

No. The researched gateway examples are software or managed service patterns.

When do I need session affinity?

Only when the backend keeps state tied to a session or instance. Stateless servers can generally be load balanced without affinity.