Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

Security checklist for an MCP server that executes code

Short answer: an MCP tool that runs code turns any text the model reads into possible commands, so judge the server by where the code lands, who it acts as, and what it records, not by the tool description. The checklist

Short answer: an MCP tool that runs code turns any text the model reads into possible commands, so judge the server by where the code lands, who it acts as, and what it records, not by the tool description. The checklist below covers the ten questions we would ask of any code-execution MCP server, ours included, with the facts from the MCP specification and from Sandscale's docs.

1. Where does the code run?

A local stdio server runs with your user's permissions on your machine unless it starts something isolated. A remote server runs code wherever its operator runs it. Ask for the boundary in plain terms: a process, a container sharing a kernel, or a virtual machine with its own kernel.

Sandscale: both servers start sandboxes, and each sandbox is a Firecracker microVM with its own kernel. The server process itself does not run your code.

2. Who does each call act as?

A server holding one shared admin token turns every connected agent into that admin. Prefer a server that acts as the signed-in person, with that person's permissions.

Sandscale: the remote server at https://mcp.sandscale.dev/mcp uses OAuth sign-in and each call runs as you, with a short-lived credential that never leaves the server. The local sandscale mcp server uses your own CLI sign-in. Agents connected this way act with the person's own access, never more.

3. Are tool annotations honest, and does your client use them?

The MCP specification defines tool annotations, with fields such as readOnlyHint and destructiveHint in its schema, and says clients must treat annotations as untrusted unless they come from a trusted server. Treat them as a hint for your client's approval prompts, not as enforcement.

Sandscale: the generated tool references mark which tools change things. On the remote server sandbox_stop is marked as not undoable, because stopping deletes the sandbox's disk.

4. What is not offered as a tool?

The safest tool is the one the model never sees. Look for what the server leaves out on purpose.

Sandscale: the local server does not offer signing in, the vault or deleting anything as tools. No Sandscale MCP tool returns a Vault value; the remote server's vault_list_secrets lists names only.

5. What network does a new sandbox get?

Code execution plus open egress is how a prompt injection becomes data leaving. See prompt injection to code execution.

Sandscale: on the local server, sandbox_start gives a sandbox no network unless asked. In general, network access follows your plan and your organization's policy, and a sandbox can reach only what the organization's egress allowlist allows.

6. Can the server's limits stop a runaway agent?

An agent in a loop can call a tool thousands of times. Ask for per-app and per-person rate limits, and for plan or policy limits on how many sandboxes and how large.

Sandscale: the remote server allows up to 120 calls a minute per app and 60 per person, and every call goes through the same plan limits and policy as the API. A refused call returns the API's own error code to the assistant.

7. Is every call recorded somewhere you can read?

You need to answer "what did the agent do" after the fact.

Sandscale: every remote MCP call is in your organization's audit log with the tool, the region, the outcome and the app, never the arguments. The log is hash-chained, so a change or gap shows. See what an audit log for coding agents should record.

8. Does a command have a time limit?

Long commands and client timeouts interact badly: the client gives up, the command keeps running. Check both the server's command timeout and the sandbox's own lifetime.

Sandscale: the local sandbox_exec tool takes an optional timeout_seconds, and a sandbox stops by itself when its time limit runs out.

9. Can you revoke access at once?

Removing a server from a client config does not revoke tokens already issued.

Sandscale: revoke a remote connector with DELETE /api/v1/me/mcp-connectors/{id}, which ends the app's sessions at once. Every organization also has a kill switch that stops its agents.

10. What does your client ask before a call?

The server enforces what is allowed; the client decides what runs without a prompt. Configure approvals per tool: reads automatic, writes prompted, irreversible calls always prompted. Our Claude Code, Codex and Cursor guides show this for each client.

Applying it

Run this list against any MCP server that runs code before you add it to an agent. If you want one that answers each item from its docs, the Sandscale MCP server is one option, with a remote server for any MCP client and a local stdio server that comes with the CLI.

FAQ

Is it safe to give an AI agent an MCP tool that runs code?

It can be, if the code runs in an isolated environment, the server acts as you rather than as a shared admin, the network is limited, secrets never reach the model, calls are rate limited and recorded, and your client prompts before irreversible calls.

Are MCP tool annotations a security control?

No. The MCP specification says clients must treat annotations as untrusted unless the server is trusted. Use them to drive approval prompts, and rely on the server's own permissions for enforcement.

What does Sandscale record for an MCP call?

Each remote MCP call is in the organization's audit log with the tool, the region, the outcome and the app. The arguments are not recorded.

Does the Sandscale MCP server give the model secrets?

No. No Sandscale MCP tool returns a Vault value. The remote server lists secret names only, and the local server does not offer the vault as a tool.

Related

Sources

Originally published on the Sandscale blog.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.