How to Add an MCP Server to IOSM CLI with Least Privilege
An MCP server should enter an engineering runtime with less authority than it will eventually need.
That sounds inconvenient. It is also the only useful starting point. A server can expose ten tools while one task needs two. It can be correctly identified yet still receive the wrong permission. It can be trusted as an endpoint while returning untrusted data. If those distinctions collapse into one checkbox, integration becomes delegation by accident.
IOSM CLI 0.3.13 gives me a better path: scope the configuration, filter the tool surface, choose approval behavior per tool, and let Policy Engine v2 make a separate decision at execution time. The mechanism is small enough to use on one repository and strict enough to audit later.
Start in the project, not the user profile
IOSM CLI loads MCP configuration from two places:
~/.iosm/agent/mcp.jsonfor the user;.mcp.jsonin the project root, which overrides user configuration.
For a repository-specific integration, I start with project scope. This keeps the dependency beside the code that needs it and prevents an experimental server from silently becoming available in every workspace.
iosm mcp add docs \
--scope project \
--transport http \
--url https://mcp.example.com \
--tool-approval search=prompt \
--tool-approval get_file=prompt
The URL above is illustrative. The important artifact is the project-level declaration, not the particular endpoint.
Then I inspect what the runtime actually resolved:
iosm mcp list
iosm mcp tools
Configuration intent and runtime exposure are different facts. I want both.
Reduce the vocabulary before changing approval
The MCP configuration model supports includeTools and excludeTools. That matters because a tool the model cannot see is safer than a visible tool that policy must reject on every turn.
A narrow project configuration can look like this:
{
"mcpServers": {
"docs": {
"transport": "http",
"url": "https://mcp.example.com",
"enabled": true,
"trust": false,
"includeTools": ["search", "get_file"],
"tools": {
"search": { "approvalMode": "prompt" },
"get_file": { "approvalMode": "prompt" }
}
}
}
}
This is the first boundary: two named capabilities instead of the server's full present and future surface. If the server later adds delete_file, the project does not inherit it merely because discovery found it.
This complements the quarantine rule I use for untrusted tool output. Surface reduction controls what may be called. Quarantine controls how returned data may influence later actions. Neither replaces the other.
Trust and approval answer different questions
IOSM CLI's three per-tool approval modes are deliberately not three levels of trust:
| Mode | Runtime behavior |
|---|---|
auto |
Defer to normal policy behavior |
prompt |
Always require confirmation |
approve |
Auto-allow only when the MCP server is trusted |
A trusted server with a broad tool list is still broad. An untrusted server with approve does not gain automatic execution: the policy engine falls back to confirmation. The source code also requires an explicit MCP allow rule—specific server name plus specific tool—before a policy allow can bypass confirmation. A wildcard-shaped permission is not treated as equivalent.
That gives the integration two independent axes:
server identity: trusted / untrusted
tool decision: deny / ask / allow
I keep a new server untrusted and both tools on prompt until I have reviewed its ownership, transport, authentication, tool schemas, and side effects. Trust is not a convenience switch for removing prompts. It is a claim that should have evidence.
Promote one tool, not the whole server
Suppose search is read-only, its schema is stable, and repeated use has shown the expected behavior. get_file may expose repository content and still deserves confirmation. I change only the proven path:
iosm mcp add docs \
--scope project \
--transport http \
--url https://mcp.example.com \
--tool-approval search=approve \
--tool-approval get_file=prompt
Automatic approval still depends on trust=true. For policy-driven bypass, Policy Engine v2 expects an explicit rule equivalent to:
version = 2
[[rules]]
id = "docs-search"
effect = "allow"
tools = ["search"]
tool_source = ["mcp"]
mcp_name = ["docs"]
priority = 100
The exact policy location and surrounding rules depend on the active IOSM profile. The invariant does not: name the server, name the tool, and avoid * when granting automatic execution.
This is where IOSM CLI as an engineering runtime becomes concrete. The model may propose a call, but the runtime owns the permission result.
Verify the denial paths
A useful integration test proves more than the happy path. I check four cases:
searchon the trusteddocsserver follows the explicit allow rule;get_filestill asks;- the same
searchrequest asks when server trust is removed; - an undeclared tool is absent or denied.
IOSM CLI emits MCP policy-decision trace data with the server name, source and exposed tool names, trust state, approval mode, outcome, reason, rule ID, and policy layer. That trace is the review artifact. A successful tool response alone cannot show which boundary authorized it.
The codebase tests the critical failure condition directly: even in yolo permission mode, an untrusted MCP server does not receive the trusted explicit-allow bypass. It returns ask. This does not prove that every MCP server is safe, nor does it inspect remote implementation behavior. It proves a narrower and valuable property: declared trust and explicit per-tool policy remain prerequisites for bypassing confirmation.
The smallest safe integration is asymmetrical
Least privilege is not “deny everything forever.” It is staged asymmetry:
project before user
named tools before full discovery
prompt before approve
one promoted tool before a trusted server-wide surface
trace before assumption
I prefer this because it leaves a migration path. A server can earn a larger surface one tool at a time, while every promotion has a specific reason and a testable rollback. That is how an integration becomes part of an engineering system instead of another invisible default.