Repository navigation
fix(runtime): reject unenforceable mcpApps tool policy instead of silently ignoring it - #6292
Conversation
BenTaylorDev
left a comment
There was a problem hiding this comment.
Approving. Good change — it converts a silent, security-relevant gap into a loud one.
Premise verified: the installed @ag-ui/[email protected] has zero occurrences of includeTools/excludeTools anywhere in its type surface, so those keys really are dropped on the floor today.
I also checked how risky the throw is, since turning a previously-working config into an error is the kind of thing that bites on upgrade. It's low: the keys were never documented (no hits anywhere in showcase/ or skills/ on main) and McpAppsServerConfig never declared them — which is why your code needs the as unknown as Record<string, unknown> cast to see them at all. So anyone carrying them guessed, or copied from another MCP wrapper, or was told to by an LLM. Small population — but for them the current behavior is that they believe tools are filtered and nothing is filtering. Rare and severe is exactly when throwing beats warning.
Verified: packages/runtime at 131 files / 1850 tests (baseline 130/1835). Fork PRs get no automatic CI here, so this was the first run.
One note, and it's a simplification rather than an addition: the validation runs inside configureAgentForRequest, so it re-checks on every request and a misconfigured runtime fails on first traffic rather than at startup. Validating once when the runtime is constructed would be less work per request and would surface the mistake at deploy time. Worth doing whenever this area is next touched — not a condition of merge.
Please drop .changeset/enable-mcp-apps-tool-filters.md before merge — releases go through nx release and there are no files under .changeset/ on main. (Also, the filename says "enable" while the change rejects; worth a glance that the description matches the final intent.)
I bless the code with a glad heart.
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
## What does this PR do? Community PRs keep arriving with `.changeset/*.md` files even though the repo migrated off Changesets to conventional-commit-driven releases. `.changeset/` has now been deleted from `main` twice (`5afa55f067` on 2026-06-16, `1e5ba689e0` on 2026-07-29) and **five open PRs carry changeset files today** (#6287, #6289, #6290, #6292, #6346). Three mechanisms keep feeding it: 1. **Stale forks.** `rodboev/CopilotKit`'s default branch still contains 10 of the pre-cleanup `.changeset/*.md` debris files. Three of the five open PRs come from that fork — the contributor's agent opens the repo, sees a directory full of changesets, and adds one more. (No `config.json`, and `@changesets/cli` isn't installed anywhere, so these are hand-written by agents, not CLI output.) 2. **Merging stale PRs re-seeds `main`.** The two files Tyler removed in `1e5ba689e0` arrived via 2026-06-10-authored branches (#2910, #5360) merged on 2026-07-25 — they sat on `main` for four days, and anyone who forked in that window inherited the directory. His hunch in that commit message was right. 3. **Convention inference, uncontradicted.** #6346 is from a branch in this repo, where `.changeset/` does *not* exist, and it still has one. The repo reads as a Changesets repo: pnpm workspace monorepo, per-package `CHANGELOG.md` in Changesets' exact `### Patch Changes` output format, `chore: release monorepo vX.Y.Z` release PRs. Nothing in `CONTRIBUTING.md`, the PR template, `AGENTS.md`, `CLAUDE.md`, or `.claude/docs/` said otherwise, so the guess was well-supported. This PR closes all three off: - **`CONTRIBUTING.md`** — new "Changelogs and releases — do not add a changeset" section: we did use Changesets, `scripts/release/` now builds changelogs from commit subjects, `.changeset/*.md` is inert, write a good conventional commit subject instead, and leave versions/changelogs to maintainers. Includes a note to rebase old forks. - **`AGENTS.md` / `CLAUDE.md`** — the same rule as an Essentials bullet. This is the highest-leverage change: the contributors doing this are coding agents, and agents load these files automatically while mostly not reading `CONTRIBUTING.md`. - **`static / check binaries`** — fail the PR on added `.changeset/*` files, so this stops depending on review catching it (which is what failed in July and restarted the loop). Added to the existing forbidden-files gate rather than a new workflow: it already runs on every PR to `main`, is fork-safe (`contents: read`, no secrets), and has exactly this `git diff --name-only origin/BASE...HEAD` + `VIOLATIONS` shape. Filters on `--diff-filter=AM` so a PR that *deletes* stale changesets still passes. - **`.oxfmtrc.json`** — drop the ignore entry for `.github/actions/changesets-action/src/run.ts`, a path that hasn't existed for a long time. It was the last grep-visible "we use changesets" signal in a root config file. ## Related PRs and Issues - Follows up `1e5ba689e0` ("fix: remove all changesets"), whose commit message asked for exactly this: a durable record of the decision that future agents can find. - Open PRs that would be caught by the new gate: #6287, #6289, #6290, #6292, #6346. ## Testing Docs + CI-config change, so verification focused on the guard. `actionlint` was run on the workflow, then the step body was extracted with `yq` and executed against real branches. **Lint / parse:** ``` $ actionlint .github/workflows/static_check-binaries.yml actionlint: clean $ python3 -c "import json; json.load(open('.oxfmtrc.json'))" # oxfmtrc still valid JSON oxfmtrc JSON OK ``` **True positive** — real head of #6292, via `yq '.jobs.check-binaries.steps[1].run'` piped to bash with `BASE_REF=main`: ``` ::error::Changeset files detected in PR: .changeset/enable-mcp-apps-tool-filters.md This repo no longer uses Changesets — releases are driven by conventional commit subjects (see scripts/release/). Nothing reads .changeset/*.md. Delete these files and describe the change in your commit subject instead. See the 'Changelogs and releases' section of CONTRIBUTING.md. This PR contains files that should not be committed (see the errors above). Please remove them and update your .gitignore if needed. exit=1 ``` **True negative** — same script on this branch, which has five changed files and no changesets: ``` $ git diff --name-only origin/main...HEAD .github/workflows/static_check-binaries.yml .oxfmtrc.json AGENTS.md CLAUDE.md CONTRIBUTING.md $ BASE_REF=main bash step.sh No binary artifacts or oversized files detected. exit=0 ``` **Delete-safety** — a commit that *removes* changesets must not be punished. Using the real cleanup commit (`8806f668d1...1e5ba68`): ``` unfiltered: with --diff-filter=AM (what the gate uses): .changeset/coalesce-...md (empty) .changeset/fix-parallel-...md ``` Not verified locally: the gate firing in real GitHub Actions — that needs this PR's own CI run (the `static / check binaries` check on this PR exercises the true-negative path). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…policy error (#7612) Refs #5930. This does not implement the per-tool filter. It corrects the error that #6292 added for it. ## Problem Setting `includeTools` or `excludeTools` on an `mcpApps.servers` entry raises a configuration error. That error says `@ag-ui/[email protected]` owns per-server tool policy. The runtime moved to `^0.1.0` in 8454999 and now depends on `^0.1.1` (`packages/runtime/package.json`). The `McpAppsServerConfig` doc comment and the docs page `backend/copilot-runtime.mdx` also name `0.0.3`. ## Change The error, the doc comment and the docs sentence now refer to "the release the runtime depends on" instead of a version number. A hard-coded number goes stale at every bump, and reading the installed version at runtime would mean a JSON import, which #7609 removes from the v2 runtime for Cloudflare Workers. The error still names the package, the offending key and server, and links #5930. Example message: ``` Unsupported MCP Apps tool policy: includeTools at server[0] (weather). @ag-ui/mcp-apps-middleware owns per-server tool policy, and the release the runtime depends on does not support these keys; see #5930. ``` The docs page also told readers to "use a compatible middleware release" once the upstream policy exists. That advice could not work, because the runtime rejects the keys whatever middleware is installed. The second commit says the runtime has to adopt the policy first and links #5930. Not changed: `packages/runtime-dotnet/src/McpAppsAgent.cs:20` mentions "MCP Apps middleware 0.0.3 HTTP config hashing". That comment is about the hashing scheme, which 0.1.1 keeps, and it lives in the .NET runtime. Not changed: `showcase/shell-docs/src/content/doctest.json` pins `@ag-ui/[email protected]` alongside `@copilotkit/[email protected]`. That pin is a matched set for compiling doc snippets, not a statement about the current runtime. ## Testing - `mcp-apps-servers.test.ts` asserts the new wording. Run against the **old** source, it fails: ``` Tests 6 failed | 4 passed (10) ``` On this branch: ``` Tests 10 passed (10) ``` - `vitest run` in `packages/runtime` (full suite): 194 files, 2803 tests, all pass. - `nx run @copilotkit/runtime:check-types --skip-nx-cache`: pass. - `oxfmt` on the changed files: clean. - The pre-commit hook (`lint-fix`, `test`, `publint`, `attw` on affected projects): pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
mcpApps.serversentries that carryincludeToolsorexcludeToolsare currently accepted even though the pinned@ag-ui/mcp-apps-middlewarepackage has no option for them. The runtime then ignores the keys, so tools an operator intended to restrict remain available. This change rejects that configuration instead of allowing a silent no-op.What CopilotKit owns
mcpApps.serversconfiguration andagentIdscoping.MCPAppsMiddleware.Discovery, model-emitted tool execution, frontend-proxied execution, server identity, and tool provenance belong to
@ag-ui/mcp-apps-middleware.Changes
resolveMcpAppsServers, which scans all configured entries for defined policy keys, filters byagentId, strips onlyagentId, and forwards other fields unchanged.Why the filter stays external
The pinned package is version
0.0.3. It owns the private server maps, UI-tool discovery, model-emitted execution, and frontend proxy execution. A CopilotKit middleware could observe only one of those paths and would have to duplicate private server identity and tool provenance. The completeincludeToolsandexcludeToolsimplementation belongs in the external package, where one predicate can cover discovery and both execution paths.Current behavior
Plain JavaScript or JSON configuration can supply
excludeTools: ["delete_account"]without a TypeScript excess-property check. The runtime currently accepts the configuration, constructsMCPAppsMiddleware, and leaves the tool available. The new behavior returns an HTTP 500 through the existing runtime error path, names the unsupported key and dependency, and does not construct the middleware.Follow-up
The counterpart change in
@ag-ui/mcp-apps-middlewareshould add the fields to the per-server configuration, preserve absent versus empty include lists, resolve server identity through its existing maps, and apply one predicate after UI-resource discovery and before model-emitted and proxied tool execution. Once that version is released, CopilotKit can remove the rejection and pass the fields through unchanged.Related issue
Refs #5930.
The cross-repository ownership split follows the proposal in #5930 (comment). This PR does not close the issue.
Test plan
pnpm -C packages/runtime exec vitest run src/v2/runtime/__tests__/mcp-apps-servers.test.ts src/v2/runtime/__tests__/mcp-apps-middleware-integration.test.tspassed, 2 files and 20 testspnpm -C packages/runtime exec vitest runpassed, 129 files and 1,836 testspnpm exec nx run @copilotkit/runtime:check-typespassedpnpm exec oxlintandpnpm exec oxfmt --checkpassed on changed TypeScript filespnpm check:plugin-skillspassedCI green for static / quality and test / unit on Node 20, 22, and 24