Add Select API Support to MCP Plugin Find Tools #14921
jhb-dev
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Add support for Payload's select API to the MCP plugin's
findResourceTool, enabling MCP clients to request only specific fields from documents. This would significantly reduce token usage in LLM interactions.Problem
Currently, the MCP plugin's find tools (
find{CollectionName}) always return complete documents with all fields populated. When an MCP client only needs specific fields (e.g., fetching just the titles of all pages), the entire document payload is still returned and transmitted.For example, if a user prompts: "List the titles of all blog posts"
The MCP client currently receives:
{ "id": "123", "title": "My Blog Post", "slug": "my-blog-post", "content": "... potentially thousands of characters of rich text ...", "author": { ... nested author object ... }, "categories": [ ... array of categories ... ], "meta": { ... SEO metadata ... }, "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z" }When all that's needed is:
{ "id": "123", "title": "My Blog Post" }This wastes tokens on both the request context and the response, increasing costs and potentially hitting context limits faster.
Proposed Solution
Add a
selectparameter to thefindResourcestool schema that accepts a JSON string representing the select query, following Payload's existing Select API.Benefits
Example Usage
MCP tool call to get only titles and slugs of pages:
{ "tool": "findPages", "arguments": { "limit": 50, "select": "{\"title\": true, \"slug\": true}" } }Response:
{ "docs": [ { "id": "1", "title": "Home", "slug": "home" }, { "id": "2", "title": "About", "slug": "about" }, { "id": "3", "title": "Contact", "slug": "contact" } ], "totalDocs": 3, "page": 1, "totalPages": 1 }Additional Considerations
depthparameter tofindResourcesas well, which would complementselectfor controlling relationship populationBeta Was this translation helpful? Give feedback.
All reactions