Principles
- The tool list is the security boundary, not R. The model can only call what the server exposes, but anything a tool can do, the model can trigger.
- Arguments are untrusted input. The model generates them, and the content it reads (data, documents, web pages) can steer it through prompt injection.
- Everything a tool returns leaves your infrastructure. The model provider reads every result, unless the model is self-hosted.
- Instructions are not enforcement. Telling a client “only use this MCP server” is a preference the model usually follows, not a guarantee. Only the tools actually available to it are enforced. In a default Claude Desktop or Claude Code setup, a mordew server sits next to other connectors and built-in tools that we do not control. Only two setups control the full tool list: a client we build ourselves (see Clients we build ourselves), and a Claude Code session restricted to the server.
Posit warns that mixing MCP servers can create the “lethal trifecta”: access to private data, exposure to untrusted content, and a way to send data out. A mordew server holds the first one by design, so the other two must be kept away.
Controls
| Risk | Control |
|---|---|
| Arbitrary code execution | No free-form “run R code” tool. check_tools()
statically flags eval(parse()), system(),
source() and similar direct calls in tool code: a lint, not
a proof. |
| Malformed or hostile arguments | Validation generated from the schema, before the function runs. |
| R can still reach the system | OS-level isolation in production: non-root container, read-only file
system, restricted network egress. On Linux, per-call sandboxing with
unix::eval_safe() or RAppArmor. |
| Runaway calls | A timeout per call (60 seconds by default) and a bounded queue; at
most run_mcp_server(tool_calls = ) tool calls and
completions = completion requests per second for each
session (10 each by default), task_requests = task requests
(20), and tasks = tasks running at once (one less than the
workers, so that a worker stays free for the calls). |
| Terminal codes in outputs | Every text sent to clients loses its terminal colours (ANSI escape sequences) and the control characters other than tab and line breaks. |
| Data leakage to the model provider | Aggregated outputs by default, @mcpLimit rows, and, on
the client side, the option of a self-hosted model. Known limit:
@mcpLimit rows caps one call, not a conversation: a model
can split its request to get around it. |
| Unauthorised access to an HTTP server | A shared bearer token, or a proxy that authenticates in front, with
a warning when the server is open beyond the machine; an
Origin that is not local is refused, as is a POST that is
not declared as JSON; for OAuth 2.1 as in the MCP authorization
specification, a gateway in front of the server. |
| Secrets exposed to the model | Secrets come from environment variables or config, never from tool arguments or results. |
Clients we build ourselves
A chat is outside mordew’s scope, but whoever builds one on top of a mordew server needs to know why it differs from third-party clients, and where it can still leak.
In Claude Code or Codex, we configure someone else’s product, which ships its own tools and reads other configuration sources: we can only remove what its vendor lets us remove. In a chat we build, we are the client. Our code (for example ellmer) calls the model API and sets the tool list sent with every request:
- A model called through an API has no tools by default: no shell, no files. It can only request the tools declared in the request, here the mordew registry.
- Tools run in the client’s code. A tool the model invents has no function behind it.
- Tools hosted by the model provider (web search, code execution) are only enabled if the request asks for them.
- Users cannot add connectors or MCP servers, and the system prompt is ours.
Three risks remain:
- Tool results still go to the model provider.
- Prompt injection through the data can still make the model misuse our own tools, hence argument validation and limits on the server side.
-
The chat UI itself can leak data. If it renders
Markdown images, an injected instruction can make the model write an
image whose URL carries data
(
), and the browser sends it when loading the image. Such a chat must not load remote images or other remote resources from model output: render images as plain links or drop them, and set a Content Security Policy that only allows the app’s own origin.