Seven Questions to Ask Before Running a Local MCP Server
A checklist for sandboxing local MCP servers, worked through on the GitHub server: short-lived tokens, sealed network, egress allowlist and pinned tool lists.
This article is published in English.
Sources: the seven questions i ask before running a local mcp server — part 2
Installing a local MCP server usually means pasting a snippet into a config file:
{
"mcpServers": {
"some-tool": { "command": "npx", "args": ["-y", "some-mcp-server"] }
}
}
That's three lines, with no review, no permissions dialog and no install step anyone really thinks about. It's worth pausing on what those lines do. A local MCP server isn't a service. It has no port, no login and no boundary. It's a program the agent launches, running as the current user, with access to that user's files and environment. The permission prompts an agent displays cover what the agent does, while the program behind a tool call already has the run of the machine.
A better habit is to ask seven questions before installing, and let the answers dictate the config.
The seven questions
- Does it run locally? Remote MCP servers live on a third party's machine and can't be boxed in, which makes the rest of the list moot. Sometimes this is a decision rather than a given, and choosing remote versus local carefully can make the other six questions disappear.
- Does it need credentials? Either none, or a specific one that can be named.
- Where does it connect? Either a short, fixed host list or any URL at all.
- Which files does it need? One workspace, everything, or nothing.
- Does it need anything else from the host? A desktop session, a socket, a browser.
- Does it run code it downloads? If so, that code needs pinning.
- How many tools does it offer, and can some be switched off? Each tool adds to the attack surface, and a few servers allow cutting the list down.
Questions one through six can be answered from the server's own documentation in roughly ten minutes, with no source-diving. Only the seventh has a measurement behind it: a single tools/list call after installation, and the count tends to exceed expectations.
Worked example: the GitHub server
| Question | Answer for GitHub's server |
|---|---|
| Runs locally? | Yes, and it already ships as a container image |
| Credentials | Required, because private repositories can't be read anonymously |
| Connects to | A single host, api.github.com |
| Files | None beyond the key. Work happens over the API, so no clone or checkout exists on disk |
| Other host needs | Nothing |
| Fetches code at runtime | No |
| Tool list | Trimmable through --toolsets and --exclude-tools |
Put together, the answers spell out the config: one credential, no mounted folder, a single destination and a tool list that should be pruned.
The credential is the harder half, since it can't be removed from the design. If an agent opens pull requests, it must hold write access. Guardrails go around it instead, and they start with using a GitHub App rather than a personal access token:
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--network",
"mcp-egress-github",
"--read-only",
"--tmpfs",
"/tmp",
"--cap-drop",
"ALL",
"--security-opt",
"no-new-privileges",
"--user",
"10001:10001",
"--log-driver",
"journald",
"-e",
"HTTPS_PROXY=http://mcp-egress-proxy:3128",
"-e",
"HTTP_PROXY=http://mcp-egress-proxy:3128",
"-v",
"/home/<user>/.config/mcp-gh/<app>.private-key.pem:/key.pem:ro",
"ghcr.io/github/github-mcp-server@sha256:508a0857ec762b1ab1cece29193345b501fab1dd9d1228a7b617062954cecac6",
"stdio",
"--app-id",
"NNNNNNN",
"--app-installation-id",
"NNNNNNNNN",
"--app-private-key-path",
"/key.pem",
"--toolsets",
"context,issues,pull_requests,repos",
"--exclude-tools",
"create_repository,fork_repository,get_teams,get_team_members,list_repository_collaborators"
]
}
}
}
The layers around that credential
- Short-lived tokens. A GitHub App mints tokens that expire quickly.
- Read-only mounts. The signing key is mounted read-only and owned by the UID the container maps to, not by the user. It doesn't live in
~/.ssh, where it would be neither an SSH key nor readable by the user any longer. - Unprivileged containers. The Docker daemon runs in rootless mode, the process uses a non-root user and no capabilities are granted.
- One repo, four permissions.
contents,issuesandpull_requestsget write,metadatagets read, and each minted token carries exactly that. - A sealed network. There's no direct route out, so a proxy is the only path.
- An egress allowlist. Whatever gets minted inside the container can be sent only to
api.github.com. - Pinned toolsets, then excluded tools.
--toolsetswithholds whole groups, and--exclude-toolsremoves whatever is left over inside the kept groups.
The last two get little attention. Cutting the tool list is least privilege that survives the need for write access. The allowlist protects more than local files, because it limits where a stolen credential can be used.
That claim deserves a measurement. With --toolsets context,issues,pull_requests,repos, the server exposes 42 tools. Five of them can't be used with these permissions. After --exclude-tools, 37 remain, and 15 of those can write. Since --toolsets selects whole groups, repos brings create_repository and fork_repository along whether or not the token could use them. 37 isn't a small number, but it's an honest one, and it's what least privilege looks like when an agent genuinely has to push a branch.
Why the allowlist isn't overkill
At first the allowlist looks like too much, until one asks what it prevents. Nobody can coax the container into contacting attacker.com, so a token created in there has nowhere hostile to go. The proxy log records both outcomes for every attempt:
10.123.2.3 TCP_TUNNEL/200 CONNECT api.github.com:443 HIER_DIRECT/140.82.121.6
10.123.2.3 TCP_DENIED/403 CONNECT example.com:443 HIER_NONE/-
The -e HTTPS_PROXY flag isn't what enforces that. Linux has no built-in notion of a proxy, neither a kernel switch nor a libc hook. The variable is merely text in the environment, and each HTTP client chooses whether to honor it. Go's net/http honors it, so this particular server needs no extra work. Node's built-in fetch doesn't, which means a Node server would ignore the setting entirely. The safeguard is the network layout: with no outbound route, a client that disregards the variable doesn't connect directly, it simply errors out. On a network with a route, that same oversight would leak traffic with no warning.
Checking against the OWASP MCP Top 10
A mapping of this setup to the OWASP MCP Top 10 marks each risk as addressed, residual and managed, unaddressed, or not applicable to a local stdio server, with notes on what stays open.
What's still out of scope
No sandbox is ever complete. Three topics sit outside this setup entirely: remote MCP servers, servers that fetch arbitrary URLs and the model itself.
Past this point the issue is no longer a forgotten flag. All of these controls apply per container, get written by hand and must be duplicated for each server added. Three servers need three allowlists and three toolset strings, and no component observes the session as a whole.
What's absent is a gateway, placed between the agent and its servers. A gateway can remove a tool from list_tools altogether and inspect each call again before passing it along, so the tool list is trimmed per session, not per config file. It still can't observe a running server's behavior: files opened, hosts contacted, credentials read. A compromised server needs no tool call to send keys elsewhere. A gateway stacks another layer on top and removes none of the existing ones.
Rules that carry over to any local server
The answers above belong to GitHub. The rules they produce apply to any local server about to be pasted into a config:
- Favor credentials that expire. A GitHub App beats a personal access token. The container keeps a signing key and creates a fresh token for each use, and that token lapses by itself instead of waiting for someone to revoke it.
- Scope permissions, not only the credential. One repository and four permissions, with every token carrying exactly those.
- Seal the network. With no route off the box, the proxy isn't a setting the server can decline, whereas
-e HTTPS_PROXYis merely a request. - Allowlist destinations. One host,
api.github.com. A credential stolen from that container can't be used elsewhere, and each attempt lands in the log either way. - Drop privileges. Run as a non-root user with
--user 10001, strip capabilities with--cap-drop ALL, add--security-opt no-new-privilegesand mount the filesystem--read-onlywith a tmpfs for scratch files. - Expose the minimum on disk. Give this server one path,
/key.pem:ro, and no workspace. Binding$HOMEinto a container doesn't count as sandboxing. - Narrow the tool list.
--toolsetswithholds groups and--exclude-toolstrims what survives, taking this server from 42 down to 37, 15 of them still able to write. - Reference images by digest. Avoid
latest, and avoid version tags too, since a tag can be repointed. Both images in this setup, the proxy included, use@sha256:…so they can't change underneath.
No single rule determines whether damage occurs. A poisoned document can still persuade the agent to make a tool call. Each rule limits how far a blast can spread and none locks the trigger. A sandbox governs where a program may speak, never what it says.
The allowlist illustrates the limit. It verifies that traffic goes to api.github.com but reveals nothing about the content. contents: write allows the agent to push a branch, and equally allows an injected instruction to commit a file. Branch names, commit messages and issue titles look fine individually, but strung together they can smuggle anything into a repository others can read. Any filter permissive enough for the agent to work lets data out, because the work itself consists of reading and writing on GitHub.
So treat all of this as the starting layer, not the finish line, and put it down first. The price is seven questions, around ten minutes of reading and a single tools/list call. In return there's a config that can be defended, where before there were three lines pasted in blind.