Skip to content

Conversation

@jhb-dev
Copy link
Contributor

@jhb-dev jhb-dev commented Dec 15, 2025

What

Adds depth parameter support to MCP resource tools (find and create), allowing MCP clients to control relationship population depth when querying or creating documents.

Why

MCP clients currently have no way to control how deeply relationships are populated when retrieving or creating documents. When collections have relationship fields, agents need the ability to either:

  • Get just the IDs (depth=0) for lightweight responses
  • Get fully populated relationship data (depth=1+) for richer context

This can significantly reduce the token count when reading documents.

How

  • Added depth parameter to findResources and createResource schemas in schemas.ts
  • Updated find.ts to pass depth to both payload.find() and payload.findByID() calls
  • Updated create.ts to pass depth to payload.create() call
  • Parameter is an optional integer (0-10) with default of 0
  • Added integration tests

@jhb-dev
Copy link
Contributor Author

jhb-dev commented Jan 15, 2026

Hi @kendelljoseph , thanks for the additional commits on this PR. Is there anything I can help with?

@kendelljoseph
Copy link
Contributor

@jhb-dev I just merging changes from main right now and potentially fixed an additional issue with ID values.

So we're just needing CI to pass next.

@kendelljoseph kendelljoseph removed their assignment Jan 15, 2026
@kendelljoseph kendelljoseph self-requested a review January 15, 2026 19:03
Copy link
Contributor

@kendelljoseph kendelljoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make a change to the schemas to support depth, but everything looks good now!

@kendelljoseph kendelljoseph merged commit c979fb3 into payloadcms:main Jan 15, 2026
196 of 198 checks passed
@github-actions
Copy link
Contributor

🚀 This is included in version v3.72.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants