posthog icon indicating copy to clipboard operation
posthog copied to clipboard

fix(mcp): allow feature flag arrays to use operators beyond in/not_in

Open sreuter opened this issue 2 months ago • 10 comments

Problem

Fixes issue #145 in the standalone MCP repo (now moved to monorepo).

The MCP server was incorrectly rejecting feature flag property filters when using the exact operator (and other string operators) with array values. This prevented users from creating feature flags like:

{
  "key": "email",
  "value": ["[email protected]", "[email protected]", "[email protected]"],
  "operator": "exact"
}

The validation logic was too restrictive, only allowing in and not_in operators with arrays, even though PostHog's API supports arrays with many more operators.

Solution

Updated the PersonPropertyFilterSchema validation in products/mcp/typescript/src/schema/flags.ts:

  • String arrays can now use all string operators (exact, icontains, regex, etc.) + array operators (in, not_in)
  • Number arrays can use base operators (exact, is_not, etc.) + array operators
  • Prevents invalid combinations (e.g., number arrays with gt/gte operators which don't make semantic sense)
  • Maintains existing validation that array-specific operators require array values

Testing

Added comprehensive test suite in products/mcp/typescript/tests/tools/featureFlags.integration.test.ts:

  • ✅ String array with exact operator (the main bug)
  • ✅ String array with icontains operator
  • ✅ Number array with exact operator
  • ✅ Array with in operator (ensures existing functionality still works)

Impact

Users can now manage feature flags with multiple-value filters through the MCP server without falling back to PostHog's UI.

sreuter avatar Oct 28 '25 09:10 sreuter

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

posthog-bot avatar Nov 05 '25 07:11 posthog-bot

Keep it open and please review/merge.

sreuter avatar Nov 05 '25 07:11 sreuter

@sreuter thank you for this PR! Running the CI checks now so we can get it merged in.

joshsny avatar Nov 06 '25 16:11 joshsny

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

posthog-bot avatar Nov 14 '25 07:11 posthog-bot

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

posthog-bot avatar Nov 21 '25 07:11 posthog-bot

@joshsny any chance we still can get this in?

sreuter avatar Nov 21 '25 07:11 sreuter

@sreuter hey sorry our bot does that automatically when a PR is stale. I've reopened, set it to auto merge and re-run all CI checks. If the fail (e.g. due to formatting), do you mind pushing fixes to the branch? (unfortunately I can't push to your fork)

joshsny avatar Nov 21 '25 07:11 joshsny

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

posthog-bot avatar Dec 01 '25 07:12 posthog-bot

Don't mark this as stale - it should get merged once the temporary external contributor block is lifted

joshsny avatar Dec 01 '25 08:12 joshsny

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

posthog-bot avatar Dec 10 '25 07:12 posthog-bot