Glossary

MCP gateway

An MCP gateway is an operating layer that sits between an agent client and MCP servers, routing protocol traffic, enforcing policy, mediating credentials, and recording calls so tool access can be inspected, constrained, replayed, or blocked before work reaches privileged systems.

How it works

An MCP gateway sits on the path between the agent-facing MCP client and one or more MCP servers. The client still speaks the Model Context Protocol. The servers still expose resources, tools, prompts, or other protocol capabilities. The gateway becomes the control point where those interactions are named, routed, checked, and observed.

In a practical harness, the gateway usually performs a small set of jobs:

  • Discover available MCP servers and expose only the approved subset to a given agent, session, or workflow.
  • Route each request to the correct server without giving the agent direct network or credential access to every backend.
  • Enforce policy before invocation: permission scope, read-write limits, argument constraints, approval requirements, and execution budgets.
  • Mediate credentials so the model or agent loop does not handle long-lived secrets directly.
  • Record calls, results, denials, and policy decisions in an audit trail or execution trace.
  • Fail closed when the requested server, tool, identity, or policy state cannot be resolved.

The gateway is not the intelligence layer. It should not be treated as a second agent unless the design explicitly adds model reasoning there. Its main value is architectural: it turns a loose set of tool endpoints into a governable protocol boundary.

Why it matters in an agent harness

MCP makes tool and context access easier to standardize. That is useful, but standardization also concentrates risk. Once many tools can be presented through a common protocol, the harness needs a place to decide which tool surface is visible, which invocation is allowed, and which result is trustworthy enough to propagate.

An MCP gateway gives the harness that place. Without it, permission decisions tend to spread across client code, server implementations, prompts, environment variables, and informal operator habits. That is hard to audit and harder to reverse. A gateway does not remove the need for well-designed MCP servers, but it reduces the number of places where authority can leak.

The most important distinction is capability versus permission. An MCP server may be capable of sending email, writing to a database, reading a repository, or calling an internal API. The agent should not inherit that full capability just because the server exists. The gateway can present a narrower tool set for a particular run, require approval before writes, strip unsafe arguments, bind calls to scoped credentials, or block an operation when the run contract does not justify it.

This also improves observability. Tool calls are where vague model intent becomes concrete system behavior. A gateway can attach per-call attribution, correlate invocations with a workflow state, and keep a record of rejected requests as well as successful ones. Rejections matter. They show where the model tried to cross a boundary, where the operator policy was too narrow, or where a prompt-injection attempt reached the tool layer.

Reversibility improves when the gateway understands effect. A read-only request, a dry-run request, a queued write, and an irreversible external action should not be treated the same way. The gateway can mark risk, require checkpoints, or force transactional semantics where the downstream system supports them. When it cannot make an action reversible, it can at least make that fact visible before the call proceeds.

MCP gateway vs MCP server

The distinction changes who owns control. An MCP server owns a tool or context surface. An MCP gateway owns access to that surface across agents, sessions, and policies.

ConceptPrimary jobDesign question
MCP serverExpose capabilities through the Model Context ProtocolWhat can this backend do, and how should it describe that capability?
MCP gatewayRoute and govern protocol traffic before it reaches serversWhich agent may use which capability, under what conditions, with which evidence trail?
Agent harnessCoordinate the run, state, evaluation, permissions, and recovery modelHow does this work remain controllable from intent through effect?

Putting every control inside each MCP server can work for a small system, but it scales poorly when the same server is shared across agents with different autonomy levels. Putting every control in the agent client is also fragile, because client-side prompts and tool lists are easy to over-broaden. The gateway is the middle boundary where shared policy can stay close to the protocol traffic.

The Rifty take

We treat an MCP gateway as a control-plane component, not a convenience proxy. The useful version narrows authority, records why a call was allowed, and makes denial a normal system outcome.

The tradeoff is friction. A gateway adds another moving part, and it can slow early experimentation. We accept that cost when tools have meaningful side effects, credentials cross trust boundaries, or multiple agents share the same capability surface.

Common failure modes

  • Treating discovery as authorization. A tool being listed by an MCP server does not mean this run should be allowed to call it.
  • Passing tokens through the agent context. Credential mediation should happen at the boundary, not inside model-visible text.
  • Logging only successful calls. Denied calls, malformed arguments, and unresolved policy states are part of the operating record.
  • Using one global policy for every agent. Different workflows need different read, write, approval, and budget limits.
  • Failing open when routing or policy state is ambiguous. An unknown server, missing identity, or unavailable policy store should block the call.
  • Hiding irreversible effects behind neutral tool names. The gateway should distinguish inspection, mutation, publication, deletion, and external communication.
  • Letting server descriptions become the only guardrail. Tool descriptions help the model choose, but deterministic policy must still govern execution.

Frequently asked questions

Is an MCP gateway required for every MCP deployment?

No. A small local setup with one trusted user and low-risk read-only tools may not need a separate gateway. The case becomes stronger when agents share servers, credentials have real authority, tools can mutate state, or operators need a durable audit trail across many runs.

What should an MCP gateway enforce first?

Start with authority boundaries: which agent, session, or workflow may access which server and tool. Then add credential mediation, read-write scope, approval requirements for side effects, and trace logging. Sophisticated policy is less useful if basic routing and identity are still ambiguous.

How is an MCP gateway different from a guardrail?

A guardrail is a broad control pattern that may inspect prompts, outputs, tool arguments, or behavior. An MCP gateway is a specific protocol boundary. It governs MCP traffic before requests reach servers, so it can combine routing, permission checks, credential handling, and call attribution.

Can an MCP gateway prevent prompt injection?

It can contain the damage, but it should not be described as a complete prevention mechanism. If injected context convinces an agent to request a dangerous tool call, the gateway can block unauthorized scope, require approval, or deny malformed arguments before the request reaches the server.

Where should MCP gateway logs feed into the harness?

They should feed the execution trace or audit trail, not a separate dark corner of infrastructure. Tool calls are part of the run’s trajectory. The harness needs allowed calls, denied calls, arguments, credential scope, policy decisions, and outcomes available for review and evaluation.

Related glossary terms.