Skip to content

feat: add list_customers tool with metadata filtering#7

Open
ignaciomendeznole wants to merge 5 commits intovoucherifyio:mainfrom
ignaciomendeznole:feat/list-customers-tool
Open

feat: add list_customers tool with metadata filtering#7
ignaciomendeznole wants to merge 5 commits intovoucherifyio:mainfrom
ignaciomendeznole:feat/list-customers-tool

Conversation

@ignaciomendeznole
Copy link
Copy Markdown

@ignaciomendeznole ignaciomendeznole commented Apr 14, 2026

Summary

  • Adds list_customers MCP tool — search/filter customers by metadata fields and standard fields (name, email, source_id, created_at) with pagination
  • Adds list_vouchers MCP tool — search/filter vouchers by holder_id, campaign_id, is_referral_code, type, active, and metadata fields with pagination
  • Adds list_voucher_redemptions MCP tool — list all redemptions for a voucher code, returning the customer who redeemed it for each entry
  • All three tools are read-only, consistent with all other tools

Motivation

  • find_customer only supports lookup by email or ID — no way to search/filter by metadata
  • No way to list vouchers for a customer — the qualifications API doesn't surface referral codes owned by the customer as a referrer
  • No way to see who redeemed a specific voucher code — needed to trace redemption activity

New Tools

list_customers

Paginated customer search with flexible metadata filtering. Mirrors list_products filter structure.

# Find customers by metadata
list_customers(filters={
    "metadata.club": {"conditions": {"$is": "VIP-Warsaw"}}
})

# Multiple metadata filters
list_customers(filters={
    "metadata.foo": {"conditions": {"$is": "bar"}},
    "metadata.club": {"conditions": {"$is": "Katowice"}}
})

list_vouchers

Paginated voucher search with filtering by holder, campaign, type, referral status, and metadata.

# Find all vouchers held by a customer
list_vouchers(filters={
    "holder_id": {"conditions": {"$is": "cust_abc123"}}
})

# Find referral codes for a customer
list_vouchers(filters={
    "holder_id": {"conditions": {"$is": "cust_abc123"}},
    "is_referral_code": {"conditions": {"$is": true}}
})

# Find vouchers in a campaign
list_vouchers(filters={
    "campaign_id": {"conditions": {"$is": "camp_abc123"}}
})

list_voucher_redemptions

Paginated redemption history for a voucher code. Each redemption includes the customer who redeemed it.

list_voucher_redemptions(code="WELCOME10")

Implementation

  • All three tools reuse existing dict_to_querystring() and async_make_voucherify_request() infrastructure
  • list_customers calls GET /v1/customers with filter query parameters
  • list_vouchers calls GET /v1/vouchers with filter query parameters
  • list_voucher_redemptions calls GET /v1/vouchers/{code}/redemptions

Test Plan

  • scenario_7_list_customers.py — single metadata filter + multiple metadata filters
  • scenario_8_list_vouchers.py — filter by holder_id + filter by campaign_id
  • Manual verification of list_voucher_redemptions against sandbox

🤖 Generated with Claude Code

ignaciomendeznole and others added 5 commits April 14, 2026 20:21
Adds a new list_customers MCP tool that supports filtering customers by
metadata fields and standard fields with pagination. Follows the same
pattern as list_products. Enables use cases like finding referees by
metadata.referrerUserId or metadata.referralCampaignName.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds two test customers with referrerUserId/referralCampaignName metadata
to prepare_project.py and a new scenario_7_list_customers.py that verifies
the LLM correctly uses list_customers with metadata filters to find referees.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a tool to list all redemptions for a given voucher code via
GET /v1/vouchers/{code}/redemptions. Returns customer details for
each redemption, enabling referral investigation (find all referees
who redeemed a referrer's referral code).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reuse existing club/foo metadata from test data instead of
referral-specific fields. Tests now cover single and multiple
metadata filter scenarios generically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a generic list_vouchers MCP tool that supports filtering by
holder_id, campaign_id, is_referral_code, type, active status, and
metadata fields. Enables finding all vouchers for a customer (including
referral codes not surfaced by qualifications API).

Includes test scenario and test data setup for customer 2.

Co-Authored-By: Claude Opus 4.6 (1M context) <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