Local MCP Servers: What a Security Review Asks About stdio

Most of our tutorials assume a remote server behind OAuth 2.1. Many products also ship a local server: a process the client launches on the user's machine and talks to over stdio. Security reviewers treat it as a different system. This tutorial covers what they ask and what answers them.

Why local servers are reviewed differently

A remote server is a network service you operate. A local server is code that runs on the customer's endpoint, as the user, with the user's file access and network reach. You do not control that machine. The customer's endpoint team does.

The MCP authorization specification is written for HTTP-based transports. It says stdio servers should not follow that flow and should take credentials from the environment instead. That removes the authorization server from the picture. It does not remove the need for a credential model. It moves the question to: where does the credential come from, and what can the process do with it?

Question 1: Where do credentials come from?

Reviewers ask how the local server authenticates to your API. Common answers, from weakest to strongest:

  1. A long-lived API key pasted into a config file. It sits in plaintext, gets copied into tickets, and has no per-user identity. Reviewers will flag it.
  2. The same key passed through an environment variable. Slightly better. It still persists on disk in the client's config.
  3. A short-lived token obtained through a user sign-in (OAuth authorization code with PKCE, per RFC 7636, in the system browser) and stored in the operating system keystore.

Option 3 gives you a per-user, revocable, auditable credential. Scope it the same way you scope a remote token. See our tutorials on designing scopes and on revocation. A local server that calls your API with a user token is, from your API's point of view, just another client.

Never write tokens to logs, crash reports, or the MCP client's debug output. Test for this explicitly.

Question 2: What can the process touch?

The local process inherits the user's privileges. A tool with a file-path argument can read anything the user can read, including SSH keys and cloud credentials. Constrain it:

  • Resolve paths and reject anything outside an allowed root. Check after resolving symlinks.
  • Do not pass tool arguments to a shell. Use argument arrays, not string concatenation.
  • Restrict outbound network access to the hosts the server needs, where the platform allows it.
  • Where the client or operating system supports it, run the server in a sandbox with a minimal filesystem view.

The MCP security best-practices guidance describes local server compromise as a distinct risk, including startup commands that run arbitrary code. Reviewers know it. Expect the question.

Question 3: How does it get installed?

Installation is where local servers fail reviews. A client config entry is a command line. If a user can be talked into pasting one, or a one-click install link supplies one, the command runs with their privileges.

What answers this:

  • Publish exact commands, versions, and checksums. Do not tell users to pipe a script into a shell.
  • Sign release artifacts and publish the verification steps.
  • Pin dependencies and publish an SBOM. See our supply chain tutorial.
  • Document what the process reads, writes, and connects to. Reviewers want a one-page list.
  • Make updates deliberate. An auto-updating local server is a remote code path into every endpoint. If you auto-update, say so, and say how updates are signed.

Question 4: Does it listen on a port?

Some local servers use the HTTP transport on localhost instead of stdio. That adds a network surface on the user's machine. A web page in the user's browser can attempt to reach it. The transport guidance in the specification calls for three controls:

  • Validate the Origin header on every incoming connection and reject unexpected values. This blocks DNS rebinding.
  • Bind to 127.0.0.1, not 0.0.0.0.
  • Authenticate connections. A listening port with no credential is open to every local process and every browser tab.

If stdio meets your needs, use stdio. There is no port to attack.

Question 5: What does the audit trail show?

A local server is invisible to your SIEM unless you make it visible. Calls from the local server reach your API with the user's token, so your API-side audit events still record them. Make sure those events identify the client as a local server, with its version. Without that, an incident responder cannot tell a compromised local build from normal use. See our audit events tutorial for the schema.

The customer's endpoint tooling sees the process itself. Give their team the process name, signing identity, and expected network destinations so they can write detections.

When you do not need a local server

If the tools only call your public API with the user's identity, a remote server is usually simpler to review. You operate it, patch it, and log it. A local server is justified when the tools must reach local files, local devices, or a network the cloud cannot reach. If none of those apply, we will say so in week one.

Evidence to send

Add these to the security evidence pack for any local server:

  • Credential flow diagram and storage location.
  • Filesystem and network access list.
  • Install and update procedure, with signing and verification steps.
  • Results of adversarial tests: path traversal, argument injection, and token leakage into logs.
  • Audit event fields that identify the local client and version.

The local path has fewer moving parts than a remote one. It also puts your code on a machine you do not control, so the review looks at it closely.