flowchart LR
start([Tool call]) --> tool{Tool<br/>configured?}
tool -- yes --> deny{Deny rule<br/>matches?}
deny -- no --> allow{Allow rule<br/>matches?}
allow -- yes --> flags{Flags +<br/>constraints<br/>pass?}
flags -- yes --> pargs{Positional args<br/>within limit?}
pargs -- yes --> exec([Execute])
tool -- no --> refuse([Refuse])
deny -- yes --> refuse
allow -- no --> refuse
flags -- no --> refuse
pargs -- no --> refuse
classDef ok fill:#efe,stroke:#2a7
classDef no fill:#fee,stroke:#E60028
class exec ok
class refuse no
Configuration reference
Top-level shape
Configuration uses top-level mcp and admin sections. The former server section and its nested web section are not supported: move MCP settings from server to mcp, and move review UI settings from server.web to admin.
| Previous key | Replacement |
|---|---|
server.transport |
mcp.transport |
server.listen |
mcp.listen |
server.auth_token_file |
mcp.auth_token_file |
server.request_log |
mcp.request_log |
server.allowed_cwd_roots |
mcp.allowed_cwd_roots |
server.web.listen |
admin.listen |
server.web.auth_token_file |
admin.auth_token_file |
mcp: # how the MCP transport is exposed
admin: # operator-only request review UI
tools: # one entry per wrapped CLI tool
mcp_servers: # local stdio MCP servers, filtered by tool namemcp_servers declares local stdio MCP servers that wraptool spawns and filters. Only explicitly allowed upstream tool names are exposed; deny wins. Argument schemas and values pass through without CLI-style constraints. Capability requests and the config editors do not manage these rules. See MCP integration.
If no config exists at the resolved path, wraptool serve and wraptool up write a commented starter there (mode 0600) and log the location, rather than erroring. They never overwrite an existing file. The starter enables one privileged tool — git pull — so the server comes up and demonstrates the point of wraptool: it wraps commands that need host credentials the agent never sees. Read-only local git (status, log, diff) is intentionally not included — it needs no credentials and the agent can run it itself. Edit the file to expose the tools you want; it hot-reloads on save.
mcp
| Field | Type | Default | Description |
|---|---|---|---|
transport |
sse | unix |
sse |
MCP transport |
listen |
string | — | host:port (sse) or socket path (unix) |
auth_token_file |
string | auto-provisioned (sse) |
Bearer token file. On sse, an unset key is auto-provisioned at mcp-token in the config directory (mode 0600) rather than left tokenless; set this key to override the location. On unix, whose socket is already restricted to mode 0600, the key stays optional |
log_level |
string | info |
parsed and defaulted; currently does not change logging |
request_log |
string | XDG data dir | path to capability-request JSONL |
allowed_cwd_roots |
[]string |
— | when non-empty, constrains a client-supplied cwd to these roots (symlinks resolved); a cwd outside them is refused. Empty = no containment |
The sse/unix TCP listener serves both MCP HTTP transports on the one port — legacy SSE at /sse and Streamable HTTP at /mcp — behind the same auth_token_file Bearer check. Clients hit whichever their generated config targets.
admin
Starts an operator-facing review UI for reviewing capability requests inside the serve process, on its own listener — independent of the MCP transport, so it works regardless of transport. Leave listen empty to disable.
| Field | Type | Default | Description |
|---|---|---|---|
listen |
string | — | host:port for the UI; bind 127.0.0.1 — it is not agent-facing |
auth_token_file |
string | — | required token, distinct from mcp.auth_token_file. Browsers authenticate via ?token= or a login form ⇒ an HttpOnly session cookie; scripts send it as a Bearer header |
mcp:
transport: sse
listen: 127.0.0.1:8717
auth_token_file: ~/.config/wraptool/mcp-token
admin:
listen: 127.0.0.1:8718
auth_token_file: ~/.config/wraptool/admin-tokenApproving with apply to config runs the same config.ApplyRequest merge as requests approve --apply; the running server hot-reloads via the config file-watch.
tools.<name>
Each tool is keyed by the user-visible name (which becomes the MCP tool prefix: git → git_pull, git_push, …).
tools:
gcloud:
binary: /usr/bin/gcloud # absolute path, validated at startup
working_dir: /var/lib/wraptool # optional cwd for child processes
timeout: 30s # per-call timeout
env: # inline env vars (override env_files)
CLOUDSDK_CORE_PROJECT: my-project
env_files: # KEY=VALUE files, merged left-to-right
- /etc/wraptool/gcloud.env
introspection:
cache_ttl: 24h
overrides_file: ~/.config/wraptool/overrides/gcloud.yaml allow:
- subcommand: [compute, instances, list]
flags: ["--format", "--filter"]
deny_flags: ["--quiet"]
flag_constraints:
"--filter": { pattern: "^[a-zA-Z0-9_ =.\"'-]+$" }
arg_constraints:
positional_max: 2
deny:
- subcommand: [auth]Env file format
Each line of an env_files file is KEY=VALUE, optionally prefixed with export. Blank lines and lines starting with # are skipped. A line without =, or with an empty name, is an error that names the file and line number.
| Rule | Example line | Resulting value |
|---|---|---|
| Quotes around a value are stripped | TOKEN="squ_abc" |
squ_abc |
Inside double quotes only \", \\ and \n are processed |
TOKEN="a\nb" |
a, newline, b |
| Single quotes are fully literal | TOKEN='a\nb' |
a\nb |
A # comment after the value is dropped |
TOKEN=abc # note |
abc |
A # without leading whitespace is kept |
TOKEN=abc#def |
abc#def |
| An unmatched quote is kept | TOKEN="abc |
"abc |
export SONARQUBE_TOKEN="squ_example" # quotes are not part of the valueAllow rules
| Field | Type | Description |
|---|---|---|
subcommand |
[]string |
Token list; matched exactly ([remote, set-url] does not match [remote]) |
flags |
[]string |
Allowed flags |
deny_flags |
[]string |
Flags blocked even though in flags |
flag_constraints |
map[flag]Constraint |
Value-level rules |
arg_constraints.positional_max |
int |
Max positional args |
arg_constraints.placeholders |
map[name]Constraint |
Value rules for :name segments of subcommand (see below) |
Help flags are always permitted. At config load wraptool seeds -h and --help into every allow rule’s flags (config.SeedHelpFlags), so they are callable and introspectable on any approved subcommand without listing them. The MCP schema renders them as boolean params. To revoke help on a rule, list the flag under its deny_flags — deny wins.
Values inside the subcommand path
Some CLIs take a value in the middle of the subcommand path. Forgejo’s fj edits an issue title with fj issue edit <ISSUE> title <TITLE>. wraptool normally puts every agent-supplied value after --, which fj then reads as a plain argument instead of the title subcommand.
Write such a value as a placeholder segment: a colon followed by a name. The agent supplies the value; wraptool puts it in place of the segment.
tools:
fj:
binary: /usr/bin/fj
allow:
- subcommand: [issue, edit, ":issue", title]
flags: ["--repo"]
arg_constraints: {positional_max: 1, placeholders: {issue: {type: integer}}}positional_max is required alongside placeholders when the command also takes positional args: it applies whenever arg_constraints is present, and without it every positional arg is refused.
This rule registers the MCP tool fj_issue_edit_title. The placeholder segment is left out of the tool name. The tool gets a required parameter issue, next to the usual flag parameters and the args array. A call with issue: 50, repo: pti/wraptool and args: ["New title"] runs:
fj issue edit 50 title --repo pti/wraptool -- "New title"| Rule | Detail |
|---|---|
| Syntax | :name, where name starts with a letter or _ and holds only letters, digits and _, at most 64 characters |
| Position | Anywhere except the first segment. A placeholder may be the last segment |
| Names | Unique within the rule, and different from args and from the rule’s flag parameter names (including help and h) |
| Tool name | Minted from the literal segments only. Two rules that mint the same name are rejected when either has a placeholder |
| Presence | Every placeholder is required. A missing value, or a value for a placeholder the rule does not declare, is a denial |
| Default shape | Every value must match ^[A-Za-z0-9][A-Za-z0-9._/@:+-]{0,255}$: no leading -, no whitespace, no shell metacharacter, at most 256 characters |
| Constraints | arg_constraints.placeholders.<name> takes the flag constraint fields type (string or integer), min, max and pattern. A constraint narrows the default shape; it never widens it. boolean and deny are rejected, and so is a constraint for a name the rule does not declare |
| Schema type | number when the constraint says integer, otherwise string |
| Denials | The reason names the placeholder and the failed check. It never repeats the value. A deny on the path with the values put in names that path, as a literal deny does |
| Audit | The call’s audit record carries the values under placeholders |
The default shape is the guard that matters. A placeholder value sits before --, so -- does not protect it. The default shape keeps it a plain word the CLI cannot read as an option. Add a constraint whenever the CLI could also read the word as a subcommand; type: integer does that for an issue number.
wraptool does not run --help for a rule with a placeholder, because that path has no fixed help command. Set a flag’s type with flag_constraints or the introspection overrides file instead.
A deny rule is checked twice against a placeholder rule:
- Before any allow rule, exactly against the template. A deny rule written with the same template text,
[issue, edit, ":issue", title], denies that allow rule. - After the values pass their checks, against the path with the values put in. A deny rule that equals that path, or is a prefix of it, denies the call. Words are compared without regard to case.
The second check stops a value from spelling out a denied subcommand word. CLIs such as cobra, clap and git match subcommand words literally, so a deny rule can name one:
allow:
- subcommand: [issue, ":x"]
deny:
- subcommand: [issue, delete] # refuses x: deleteIt also means deny: [issue, edit] denies every call through [issue, edit, ":issue", title].
The deny check matches literal text only. It cannot know a CLI’s aliases: kubectl get accepts secrets, secret and secrets.v1. for the same resource. For a slot whose values have aliases, list the allowed values with a pattern. The deny rule is then only a backstop for exact spellings.
allow:
- subcommand: [get, ":resource"]
arg_constraints:
positional_max: 1
placeholders:
resource: { pattern: "^(pods|deployments|services)$" }
deny:
- subcommand: [get, secrets] # backstop only; does not stop "secret"Literal allow rules keep exact deny matching. A deny rule that is only a prefix of a literal allow rule does not deny it (see below).
Placeholders cannot be requested with wraptool_request_capability. Applying an approved request whose subcommand contains one fails. Add a placeholder rule in the configuration file or the rules editor.
Deny rules
Evaluated before allow rules, so a match here overrides any allow rule for the same subcommand.
A deny rule’s subcommand is matched exactly, the same as an allow rule’s (see the table above) — it is not a prefix match. deny: [auth] blocks auth and nothing else; it does not cover auth print-access-token, which needs its own entry:
deny:
- subcommand: [exec]
- subcommand: [auth]
- subcommand: [auth, print-access-token]wraptool doctor’s policy.deny-prefix-gap check flags a deny rule whose subcommand is a strict prefix of an allowed one, since that shape is the usual sign the deny was meant to cover the longer form too.
Flag constraints
| Field | Type | Description |
|---|---|---|
required |
bool | Flag must be provided |
type |
string | integer, boolean, string, or text |
min, max |
int | Range for integer values |
pattern |
string | Regex the value must match |
deny |
bool | Flag is always denied |
Free-text flags. Every argument is normally refused if it holds a shell metacharacter or a newline (see Security). A flag whose value is prose, such as a pull-request body or an issue comment, cannot carry Markdown under that rule. Set type: text on that one flag to relax it:
tools:
fj:
binary: /usr/bin/fj
allow:
- subcommand: [pr, create]
flags: ["--title", "--body", "--base", "--head"]
flag_constraints:
"--title": { type: text }
"--body": { type: text }| Rule | Detail |
|---|---|
| Scope | One flag of one allow rule. There is no per-tool or global setting, and text is rejected for a placeholder |
| Accepted | Newlines, tabs, punctuation, quotes, Markdown, Unicode, and every shell metacharacter |
| Refused | A value starting with -, a carriage return, any other control character (including ESC), and more than 64 KiB |
pattern |
Still applies. Use (?s) for a pattern that must span lines |
| Schema | Renders as a string parameter whose description says free text is accepted |
| Everything else | Flag names, positional arguments, placeholder values, and the values of all other flags keep the strict rule |
Mark only flags the tool treats as data. Never mark a flag the tool hands to a shell, an editor, or a helper command, such as --exec or --pager. An agent can ask for the type through wraptool_request_capability by sending flag_types: {"--body": "text"}; approval writes it as a flag_constraints entry like the one above.
Boolean (valueless) flags. A flag’s value-taking-ness is decided by, in order: an explicit type constraint, then --help introspection, then a name heuristic. The heuristic treats --no-*/--enable-*/--disable-* prefixes and the well-known switches --yes/-y, --force, --dry-run, --quiet, --verbose as boolean, so they render as a bare --flag (not --flag true) without needing a flag_constraints entry. Short -f is deliberately excluded (it’s a filename flag as often as a force switch). If a tool uses one of these names with a value, introspection detects it (or set type: string).
Evaluation order
Validating a config
Check a config before the server loads it:
wraptool config validate # default / $WRAPTOOL_CONFIG path
wraptool config validate ./config.yaml # an explicit fileIt exits non-zero with a message on the first problem, and touches nothing — no server, no spawned tools. Validation, server startup, and hot reload all strictly decode the YAML: a misspelled key such as flag_constraint (instead of flag_constraints) is reported rather than silently dropped. It then applies defaults and runs the same semantic checks serve does at startup.
Handy before an edit that the server would otherwise hot-reload: a config that fails validation is rejected on reload and the previous policy stays in effect, so validating first tells you whether a change will actually take.
CLI introspection
wraptool parses --help output at startup to enrich MCP tool schemas with real flag descriptions and types. Supported styles:
- Git/Cobra (
git commit -h,kubectl get -h) - GNU (
curl --help,wget --help) - Fallback regex extraction
Second-level discovery
By default wraptool_discover lists only a tool’s top-level commands, such as issue or pr. A tool that groups its commands (fj issue search) hides the second level from the agent, which then cannot name it in a capability request. Set discover_depth: 2 for that tool to list entries such as issue search:
tools:
fj:
binary: /usr/bin/fj
introspection:
discover_depth: 2 # default 1; valid values are 1 and 2Depth 2 is off by default because it runs commands that no allow rule covers. For each top-level command, wraptool runs <tool> <command> -h. When that fails or prints almost nothing, it runs <tool> <command> --help, then <tool> help <command>. That is up to three runs per command, within a 60-second budget per tool. Probing stops when the budget runs out, and the next cache refresh retries. Only plain lowercase command names from the tool’s own help are probed, at most 64 per tool.
A command that ignores -h runs for real, with the tool’s HOME and env. Enable depth 2 only for a tool whose top-level commands all treat -h as help. Depth 2 reaches one level only: for gcloud, it lists compute instances but not compute instances list.
Results cache to ~/.cache/wraptool/introspection/. Override misparses with a YAML file referenced from the tool’s introspection block:
# ~/.config/wraptool/overrides/git.yaml
subcommands:
commit:
description: "Record changes to the repository"
flags:
"--message":
short: "-m"
type: string
description: "Commit message"Environment isolation
Each child process gets a minimal base environment:
PATH— the tool binary’s own directory prepended to the server’s inheritedPATH(falling back to/usr/bin:/binonly when that is unset), so a tool finds both co-located helpers (e.g.kubectl→gke-gcloud-auth-plugin) and genuine runtime deps in a separate prefix (e.g.git→sshon a store-based distro like Guix)HOME— copied from the server environment; override it in toolenvwhen user-global configuration or credentials must not be visibleLANG=C.UTF-8- Variables from
env_files(merged in order) - Variables from inline
env(overrideenv_files)
No other parent variable is inherited. This minimizes ambient environment exposure, but inheriting HOME means it is not by itself credential isolation for host-side child processes.
mcp_servers.<name>
| Field | Type | Default | Description |
|---|---|---|---|
command |
string | required | Child command; resolved by exec, not required to be absolute |
args |
[]string |
— | Child arguments |
working_dir |
string | — | Parsed, but currently not applied to the child process |
env, env_files |
map, list | — | Child environment additions |
timeout |
duration | 30s |
Per-tool-call timeout |
init_timeout |
duration | 10s |
Initialization budget |
name_prefix |
string | map key | Prefix for exposed tools |
allow, deny |
list of {tool: name} |
— | Exact upstream names; default-deny and deny-first |
Platform paths
| Purpose | Linux | macOS |
|---|---|---|
| Config | ~/.config/wraptool/ |
~/Library/Application Support/wraptool/ |
| Data | ~/.local/share/wraptool/ |
~/Library/Application Support/wraptool/ |
| Cache | ~/.cache/wraptool/ |
~/Library/Caches/wraptool/ |
Override with WRAPTOOL_CONFIG or --config.