Title: mcpx: argument rules -- allow a call by its arguments, per tool and per argument (JSON Schema; depends on #254) · Issue #1986 · developing-today/code · GitHub
Open Graph Title: mcpx: argument rules -- allow a call by its arguments, per tool and per argument (JSON Schema; depends on #254) · Issue #1986 · developing-today/code
X Title: mcpx: argument rules -- allow a call by its arguments, per tool and per argument (JSON Schema; depends on #254) · Issue #1986 · developing-today/code
Description: Relocated from dezren39/darwin-nix#355 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/ni...
Open Graph Description: Relocated from dezren39/darwin-nix#355 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue referenc...
X Description: Relocated from dezren39/darwin-nix#355 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue refe...
Opengraph URL: https://github.com/developing-today/code/issues/1986
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: argument rules -- allow a call by its arguments, per tool and per argument (JSON Schema; depends on #254)","articleBody":"Relocated from dezren39/nix#355 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).\n\n## Summary\n\nTool filters (`tools`, `extraIncludeTools`, `excludeTools`; #351, #352) decide by **tool name**: a tool is either callable with any arguments or not callable at all. Many tools are safe with some arguments and unsafe with others, and the choice today is to give up the tool or accept its worst case:\n\n| tool | safe | unsafe |\n| --- | --- | --- |\n| `github.create_repository` | `private: true` in a known organization | `private: false`, or no `organization` (lands in a personal account) |\n| `github.push_files`, `create_or_update_file`, `delete_file` | a feature branch | `main` |\n| `datadog.execute_datadog_workflow` | a few reviewed workflow ids | any workflow |\n| any tool taking `owner`/`org` | the caller's own organizations | anyone's |\n\nThis adds **argument rules**: per tool, and per argument across tools, a JSON Schema constraint that a call's arguments must satisfy, or mcpx refuses the call before it reaches the server.\n\n## Depends on\n\n- **#254**, JSON Schema validation. Rules are schemas, so they need a real validator (2020-12 by default, draft-07 and 2019-09 as servers use them, local `$ref` only). Shipping this first would mean a second partial validator alongside `internal/mcpspec`'s test subset. #254 lands the validator, and both upstream `inputSchema` validation and these rules use it.\n\nRelated: #114 (tool views: pin, rename, narrow a schema; this is its \"narrow a schema\" and part of \"pin an argument\"), #340 (ask/allow/deny write policy; see below), #257 (annotation trust: rules are keyed by name and arguments, never by server-supplied hints).\n\n## Proposal\n\nA per-server `argumentRules` map in the `mcpx` block, also allowed in the top-level `pool` block. **Keys** are tool patterns, matched exactly as `tools`/`excludeTools` match: exact name, glob (`delete_*`), or `/regexp/`. **Values** are JSON Schema objects. A call is allowed only if its arguments validate against every rule whose key matches the tool.\n\n```jsonc\n\"github\": {\n \"mcpx\": {\n \"argumentRules\": {\n // Per function: the whole argument object.\n \"create_repository\": {\n \"required\": [\"private\", \"organization\"],\n \"properties\": {\n \"private\": { \"const\": true },\n \"organization\": { \"pattern\": \"^(my-org|my-org-sandbox)$\" }\n }\n },\n // Several functions, one rule.\n \"/^(push_files|create_or_update_file|delete_file)$/\": {\n \"required\": [\"branch\"],\n \"properties\": { \"branch\": { \"not\": { \"enum\": [\"main\", \"master\"] } } }\n },\n // Per argument, across every tool that has it: `properties` applies only\n // when the argument is present, so tools without an `owner` are untouched.\n \"*\": {\n \"properties\": { \"owner\": { \"pattern\": \"^(my-org|my-user)$\" } }\n }\n }\n }\n},\n\"datadog\": {\n \"mcpx\": {\n \"argumentRules\": {\n \"execute_datadog_workflow\": {\n \"required\": [\"workflow_id\"],\n \"properties\": { \"workflow_id\": { \"enum\": [\"\u003cid-1>\", \"\u003cid-2>\"] } }\n }\n }\n }\n}\n```\n\nPer function and per argument are the same mechanism: a per-argument rule is a schema with `properties` under a key matching many tools. No second syntax is needed. A shorthand could come later if the `properties` wrapper proves noisy.\n\n### What a constraint can say\n\nAnything JSON Schema says, including:\n- `const`, `enum`, `not`\n- `pattern` (regular expressions; see the dialect note under Limits)\n- `minimum`/`maximum`, `maxLength`, `maxItems`\n- `required`\n- `if`/`then` across arguments, e.g. \"if `organization` is absent, refuse\"\n- `items` for array arguments, e.g. every path in `push_files.files[*].path` under `docs/`\n\n### Semantics\n\n- **Where it is checked:** in `resolveAndGuard`, the step every tool call path shares (`Call`, `CallReporting`, `CallAsk`). It runs after the hidden-tool check and before `elicit.confirmDestructive`, and before the pool is touched, so a refused call starts nothing.\n- **Refusal:** 400, as a hidden tool is. The message names the argument path (`/organization`), what was sent, the constraint, and where the rule came from (config file, server, key). It's rendered like `mcpx diagnose` output, so an agent can correct itself.\n- **Combining:** every matching rule applies (`allOf`). Pool and server rules add up, and so do rules from layered config files: rules only tighten, and a nearer file cannot loosen a farther one's. That's the same reasoning as `excludeTools`.\n- **Advertising:** the effective schema is the upstream `inputSchema` `allOf` every matching rule. It's what `mcpx types`, the generated TypeScript client, search, and the MCP pass-through's `tools/list` show. An agent sees `private: true` in the types before it ever calls, and `mcpx diagnose`/the pre-run check refuse a script that cannot satisfy it without running it.\n- **Validation of the rules themselves:** a value that is not a valid schema, or a `pattern` that does not compile, is a configuration error naming the server and key, the same as a bad tool pattern today.\n- **Dead rules:** a key matching no tool, or a `properties` entry naming an argument no matched tool has, is a warning at load and on every catalog change. A server that renames `organization` to `org` must not silently disable the rule. `catalog-history` already detects the schema change and can say which rule it orphaned.\n- **Server defaults are invisible:** a schema constrains what is sent, not what the server fills in. `create_repository` defaults `private` to `true` today, but a rule that relies on that is one server release from wrong. Constraints that matter should list the argument in `required`. The docs should say so plainly.\n\n### Relationship to #340 (ask/allow/deny)\n\nAn argument rule is a deny with a condition. #340 needs the same condition for \"ask before `execute_datadog_workflow` unless the id is one of these\". Design the two together:\n\n- **Shared:** one rule shape, `{ tool pattern, when: \u003cschema>, action: deny | ask | allow }`. `argumentRules` is the deny-only form, and can be implemented first as exactly that.\n- **Separate:** whatever ends up in the config, the evaluator is one function so the two can never disagree.\n\n### Possible follow-up: pinning (#114)\n\n`\"set\": { \"private\": true }` would inject a value when the caller omits it and refuse a different one. It's useful but changes what reaches the server, so it should be a separate step with its own tests, after deny-only rules are solid.\n\n## Limits\n\n- **Pattern dialect.** JSON Schema `pattern` is ECMA-262. If #254 picks a Go RE2-based validator, lookaround and backreferences are unsupported. A rule using them must be a load-time error, not a pattern that silently never matches.\n- **Free-form arguments.** A `query`/`jql`/`sql` string can be pattern-matched but not truly constrained. `pattern: \"env:production\"` does not stop `OR env:*`. The docs should say that a tool whose danger lives in a free-form argument belongs in `excludeTools`, not in a rule.\n- **Equivalent arguments.** Some servers accept the same thing two ways, such as `owner` vs `organization`, or an id vs a URL. A rule must cover each spelling, and the dead-rule warning cannot detect a missed synonym.\n- **Arguments are not effects.** A rule constrains the request mcpx forwards. It does not stop a server from doing something its arguments did not say.\n\n## Acceptance\n\n- Unit tests:\n - tool-pattern keys\n - `allOf` composition across pool, server and layered files\n - schema validity and pattern-dialect errors\n - dead-rule detection, including after a catalog change\n- Registry test over all three call paths: a violating call is refused before the pool is touched; a conforming one reaches it. That's the shape of `TestAHiddenToolCannotBeCalled`.\n- An e2e test through the real daemon and fake server: refused and allowed calls, the 400 body naming the argument path, and the tightened schema in `mcpx types` and the generated client.\n- A pass-through test: an MCP client sees the tightened `inputSchema` in `tools/list` and gets an error result, not a transport failure, on a refused call.\n- Falsification for each mechanism, recorded in the commit body: disable the check, the composition, and the advertising in turn, and show the test that fails.\n- Docs: a section beside \"Hiding tools\" in `docs/configuration.md`, with the server-default and free-form-argument cautions.\n\n## Open questions\n\n1. **Name:** `argumentRules`, `argumentConstraints`, or rules folded into a single `policy` block shared with #340.\n2. **Per-argument shorthand:** should `\"args\": { \"owner\": {...} }` exist as sugar for `\"properties\"`, or is one syntax better?\n3. **Refusal on the pass-through:** an MCP client gets a tool result with `isError: true` and the explanation (agent-readable, recommended) or a JSON-RPC error.\n\n## Acceptance criteria\n\n- [ ] Blocked on #254: a shared JSON Schema validator (2020-12 default; draft-07/2019-09; local `$ref` only) exists and is used by both upstream `inputSchema` validation and argument rules\n- [ ] `argumentRules` is accepted in per-server `mcpx` blocks and the top-level `pool` block; keys match exactly as `tools`/`excludeTools` do (exact, glob, `/regexp/`)\n- [ ] A call is refused before reaching the server when its arguments fail any matching rule, with a refusal that names the rule; calls matching no rule are untouched\n- [ ] The worked examples from the proposal (create_repository private+org pin, branch-not-main, owner allowlist, workflow-id allowlist) are covered by tests, including the per-argument `*` form applying only when the argument is present\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:55:56Z","url":"https://github.com/developing-today/code/issues/1986"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fe8c0d85-7899-86f8-9209-6bff861de2a3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8EC:26A1D6:53A80A:6CDA3E:6B061F0D |
| html-safe-nonce | dbccf6a8ca82ba27d64092a6c0091adf6e0d67f8180d2e162df592b543bd7af2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEVDOjI2QTFENjo1M0E4MEE6NkNEQTNFOjZCMDYxRjBEIiwidmlzaXRvcl9pZCI6IjQ5NjUwNTEwNzg2NTcwNTY1MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 49ce685812c038aa4d6eb1de7910af343c15e84e2243b6b5a40bb8439fc7573f |
| hovercard-subject-tag | issue:6089020562 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1986/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d1902a597f421dd76e0a68864b8249abcb74d56f857d0ccd64decfb5029e350a/developing-today/code/issues/1986 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d1902a597f421dd76e0a68864b8249abcb74d56f857d0ccd64decfb5029e350a/developing-today/code/issues/1986 |
| og:image:alt | Relocated from dezren39/darwin-nix#355 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue referenc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b25c3080e84402f75431d8dc7a96b2635219cec7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width