Skip to content

Conversation

leahwithablackcat
Copy link

@leahwithablackcat leahwithablackcat commented Aug 18, 2025

  • Add support for any Contentful API query parameter via catchall(z.any())
  • Increase entry limit from 3 to 100 (default 10)
  • Add field-based searches (fields.title, fields.slug, etc.)
  • Add system field searches (sys.id[in], sys.createdAt, etc.)
  • Add metadata searches (tags)
  • Add full-text search capability
  • Maintain backward compatibility with existing parameters

This enhancement enables comprehensive content discovery and filtering capabilities for AI agents working with Contentful data.

Summary

Description

Motivation and Context

PR Checklist

  • I have read the CONTRIBUTING.md file
  • All commits follow conventional commits
  • Documentation is updated (if necessary)
  • PR doesn't contain any sensitive information
  • There are no breaking changes

- Add support for any Contentful API query parameter via catchall(z.any())
- Increase entry limit from 3 to 100 (default 10)
- Add field-based searches (fields.title, fields.slug, etc.)
- Add system field searches (sys.id[in], sys.createdAt, etc.)
- Add metadata searches (tags)
- Add full-text search capability
- Maintain backward compatibility with existing parameters

This enhancement enables comprehensive content discovery and filtering
capabilities for AI agents working with Contentful data.
@leahwithablackcat leahwithablackcat requested a review from a team as a code owner August 18, 2025 14:29
@leahwithablackcat leahwithablackcat deleted the feat/enhanced-search-entries branch August 18, 2025 14:30
@leahwithablackcat leahwithablackcat restored the feat/enhanced-search-entries branch August 18, 2025 19:56
@Niko-Berry-Contentful
Copy link

Hey Leah. Thanks for opening this PR. The Team and I are giving it a review and will provide feedback and figure out next step over the next week.

.string()
.optional()
.describe('Filter by content type ID'),
'sys.createdAt[gte]': z
Copy link
Contributor

Choose a reason for hiding this comment

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

For ISO 8601 datetimes, you can use the z.string().datetime() for zod v3, or z.iso.date() for zod v4

V3 https://v3.zod.dev/?id=strings | V4 https://zod.dev/api#iso-dates

.describe('Skip this many entries for pagination'),
order: z.string().optional().describe('Order entries by this field'),

// Full-text search (like ivo version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just use // Full-text search as the comment here

query: {
...args.query,
limit: Math.min(args.query.limit || 3, 3),
limit: Math.min(args.query.limit || 10, 100), // Allow up to 100 results, default 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this to a reusable fn so we don't need to duplicate the code below in the summarize data.

Something like:

function searchLimit(userLimit?: number) {
  return Math.min(userLimit || 10, 100)
}

Copy link
Collaborator

@chasepoirier chasepoirier left a comment

Choose a reason for hiding this comment

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

@leahwithablackcat thanks again for putting this PR together! We've just got a few comments to check out but once addressed we'll approve and merge this.

@chasepoirier
Copy link
Collaborator

Closing in favor of #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants