[MCP] Support object body param and Abilities API guidance#3455
Open
[MCP] Support object body param and Abilities API guidance#3455
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for passing structured (object) request bodies to the playground_request MCP tool without requiring manual JSON.stringify, and updates tool guidance to mention the Abilities API endpoint.
Changes:
- Introduces a new
string_or_objectparameter type and wires it through Zod + JSON Schema generation. - Auto-serializes object bodies in the
playground_requestexecutor. - Updates
playground_requestdescription guidance and adds an e2e test covering object body usage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/playground/mcp/tests/e2e/mcp-tools.spec.ts | Adds e2e coverage ensuring playground_request accepts object bodies. |
| packages/playground/mcp/src/tools/tool-executors.ts | Serializes object bodies to JSON before issuing the HTTP request. |
| packages/playground/mcp/src/tools/tool-definitions.ts | Adds string_or_object, updates tool guidance, and emits oneOf JSON Schema for the new type. |
| packages/playground/mcp/src/tools/register-mcp-server-tools.ts | Adds Zod validation support for string_or_object. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d205289 to
cf54a01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for the change, related issues
MCP clients (like Claude) naturally produce object values for structured parameters. Currently, callers must
JSON.stringifythe body before passing it toplayground_request, which is an unnecessary friction point — the tool should accept both forms.Additionally, the Abilities API (
/wp-json/wp-abilities/v1/abilities) is now available and should be surfaced in the tool's guidance so MCP clients know to use it.Implementation details
string_or_objectparam type – added toToolParamTypeand handled in both the Zod schema builder (register-mcp-server-tools.ts) and the JSON Schema builder (paramsToJsonSchemaintool-definitions.tsviaoneOf).tool-executors.tsnowJSON.stringifys the body when it receives an object, passing strings through unchanged.playground_requestdescription now mentions the Abilities API as a first-class REST endpoint and trims redundant guidance text.Testing Instructions