You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tools/call and resources/read currently serialize full results without limits, pulling heavy fields (post HTML content, large plugin/theme lists, etc.) and quickly burning tokens in Claude.
Page/post searches via REST aliases (/wp/v2/pages, /wp/v2/posts) do not set _fields/context=embed or enforce small pagination, so large objects are returned.
Truncate tool textual responses to 10k characters in ToolsHandler::call_tool (replace direct wp_json_encode($result) with an intermediate variable, clamp, append [truncated]).
Truncate resource text to 10k characters in ResourcesHandler::read_resource (build $json first, clamp, append [truncated]).
Add preCallback for wp_posts_search and wp_pages_search in McpPostsTools/McpPagesTools: enforce per_page <= 10 (default 5), set _fields=id,title,excerpt,link,date,slug and context=embed. Optionally, in McpCustomPostTypesTools::search_custom_post_types, map $query->posts to a minimal field set (exclude post_content).
Acceptance criteria
tools/call responses with long JSON include [truncated] and length ≤ 10,000 bytes.
resources/read responses are also truncated to 10,000 bytes and include [truncated] when applicable.
By default, page/post searches return ≤ 10 items and only the listed _fields (no heavy content.rendered).
Response sizes drop significantly on typical queries (expected 50–90%).
Problem
tools/callandresources/readcurrently serialize full results without limits, pulling heavy fields (post HTML content, large plugin/theme lists, etc.) and quickly burning tokens in Claude./wp/v2/pages,/wp/v2/posts) do not set_fields/context=embedor enforce small pagination, so large objects are returned.Affected files:
includes/RequestMethodHandlers/ToolsHandler.php,includes/RequestMethodHandlers/ResourcesHandler.php,includes/Tools/McpPostsTools.php,includes/Tools/McpPagesTools.php, optionallyincludes/Tools/McpCustomPostTypesTools.php.Proposed solution
ToolsHandler::call_tool(replace directwp_json_encode($result)with an intermediate variable, clamp, append[truncated]).ResourcesHandler::read_resource(build$jsonfirst, clamp, append[truncated]).preCallbackforwp_posts_searchandwp_pages_searchinMcpPostsTools/McpPagesTools: enforceper_page <= 10(default 5), set_fields=id,title,excerpt,link,date,slugandcontext=embed. Optionally, inMcpCustomPostTypesTools::search_custom_post_types, map$query->poststo a minimal field set (excludepost_content).Acceptance criteria
tools/callresponses with long JSON include[truncated]and length ≤ 10,000 bytes.resources/readresponses are also truncated to 10,000 bytes and include[truncated]when applicable._fields(no heavycontent.rendered).How to test (commands)