Skip to content

Enable filters parameter with flattened agent-friendly schema#32

Open
themightychris wants to merge 1 commit into
anyproto:mainfrom
themightychris:feature/flatten-filter-schema
Open

Enable filters parameter with flattened agent-friendly schema#32
themightychris wants to merge 1 commit into
anyproto:mainfrom
themightychris:feature/flatten-filter-schema

Conversation

@themightychris
Copy link
Copy Markdown

Summary

This PR enables the filters parameter for search endpoints with a properly structured schema that's optimized for LLM agents.

Previously, the filters parameter was explicitly excluded from the MCP tool schema with TODO comments. This change:

  • Removes the filter exclusion guards
  • Adds a flattened schema following the existing PropertyValue pattern in the codebase
  • Provides clear property descriptions and enums for filter conditions

Approach

Rather than exposing the complex recursive FilterExpression with 12 oneOf variants, we flatten it into a single object with all possible fields as optional properties. This mirrors how the codebase already handles PropertyValue schemas and is much easier for LLMs to understand and use correctly.

Schema Structure

{
  "operator": "and" | "or",
  "conditions": [{
    "property_key": "done",
    "condition": "eq",
    "checkbox": false
  }],
  "filters": [/* nested expressions */]
}

Tested Working

  • Checkbox filters: {"conditions": [{"property_key": "done", "condition": "eq", "checkbox": false}]}
  • Existence filters: {"conditions": [{"property_key": "links", "condition": "nempty"}]}

Note

Object ID filters (condition: "in"/"all" with objects array) return 400 from the API - this appears to be an API-side limitation, not related to this MCP change.

🤖 Generated with Claude Code

Previously, the filters parameter was explicitly excluded from the MCP
tool schema. This change enables filter support with a properly structured
schema that flattens the complex FilterExpression oneOf into a single
object with all possible fields - following the existing PropertyValue
pattern in the codebase.

The flattened schema includes:
- operator: "and" | "or" for combining conditions
- conditions: array of filter items with:
  - property_key: the field to filter on
  - condition: eq/ne/gt/lt/empty/nempty/in/contains/etc
  - type-specific value fields (text/number/checkbox/date/objects/etc)
- filters: nested expressions for complex boolean logic

Tested working:
- Checkbox filters: {"conditions": [{"property_key": "done", "condition": "eq", "checkbox": false}]}
- Existence filters: {"conditions": [{"property_key": "links", "condition": "nempty"}]}

Note: Object ID filters (condition: "in"/"all" with objects array) return
400 from the API - this appears to be an API limitation, not MCP.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants