Repository navigation
Conversation
…n target any site
The plugin, comment, and user tools were the only WordPress-hitting
tools without a site_id parameter. The MCP SDK builds its validator from
each tool's inputSchema.properties as a plain (non-strict) z.object, so
a supplied site_id was SILENTLY STRIPPED before the handler ran and the
call went to the default site with no error — in a multi-site
configuration there was no way to inspect or moderate a secondary site's
plugins, comments, or users, and no signal that the wrong site had
answered. The README's multi-site section already promises "all tools
accept an optional site_id parameter".
Each of the fifteen schemas now declares the same optional site_id used
by the other tool groups, and each handler threads it through as the
request's { siteId } option, excluding it from the query/body sent to
WordPress (handlers passed `params` straight through as the payload, so
site_id would otherwise have leaked into the REST request). With site_id
omitted, every handler's payload is byte-identical to before — verified
by capturing all fifteen call shapes on both revisions and diffing.
README's tool-overview line now names all six groups.
Tests cover all fifteen handlers through the mocked transport, each with
a per-handler site id (so cross-wired or hardcoded routing cannot pass),
asserting: siteId lands in the request options; the payload deep-equals
the exact pre-change payload both with and without site_id; site_id
never appears in the payload; and every tool's input schema declares
site_id (a property missing from the schema is stripped by the SDK
before the handler sees it).
Co-Authored-By: Claude <noreply@anthropic.com>
|
Adversarial review record (one independent reviewer; findings verified, then fixed before this PR was opened): Found and fixed: the first version of the test file injected the same site id everywhere and never exercised the no- Clean, confirmed: payloads byte-identical to main for all fifteen handlers with Noted, pre-existing, untouched: |
|
Kilo Code Review could not run — your account is out of credits. Add credits or switch to a free model to enable reviews on this change. |
Bug
The plugin, comment, and user tools are the only WordPress-hitting tools without a
site_idparameter. Worse than a rejection: the MCP SDK builds its validator from each tool'sinputSchema.propertiesas a plain (non-strict)z.object, so a suppliedsite_idis silently stripped before the handler runs — the call goes to the default site with a clean success and no signal that the wrong site answered. In a multi-site configuration there is no way to inspect or moderate a secondary site's plugins, comments, or users.The README's multi-site section already promises: "all tools accept an optional
site_idparameter to target specific sites."Fix
All fifteen schemas (
list/get/activate/deactivate/create_plugin, the five comment tools, the five user tools) declare the same optionalsite_idthe other tool groups use, and each handler threads it through asmakeWordPressRequest's{ siteId }option — excluding it from the query/body, since these handlers passparamsstraight through as the payload andsite_idwould otherwise leak into the REST request.With
site_idomitted, every handler's payload is unchanged — verified by capturing all fifteen call shapes on both revisions and diffing (identical methods, endpoints, data values, and key order). The tool-overview line in the README now names all six groups; after this, the only tools withoutsite_idare the two wordpress.org-repository lookups andlist_sites, none of which target a site.Tests
tests/tools/site-id-routing.test.ts, 31 tests through the mocked transport. Each handler uses a per-handler site id (cross-wired or hardcoded routing can't pass), and each is exercised both withsite_id(siteId lands in options, payload deep-equals the exact pre-change payload, nosite_idkey in it) and without (siteIdundefined, same payload — guards every existing caller). A schema-shape test pins that all fifteen tools declaresite_id, since a property missing frominputSchema.propertiesis stripped by the SDK before the handler ever sees it.Full suite 66 passed / 2 skipped, green under
--sequence.shuffle,tscclean.Suggested CHANGELOG entry (release-time backfill, per repo convention):
🤖 Generated with Claude Code
https://claude.ai/code/session_012xFYsxskaCvMkg5mDw2iVH