Skip to main content
Glama

filter_deals

Filter deals by categories, stores, price range, rating, and tags to find specific offers from aggregated deal sources.

Instructions

Filter deals using advanced criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dealsYesArray of deals to filter
categoriesNoCategories to include
storesNoStores to include
priceRangeNoPrice range filter
ratingRangeNoRating range filter
tagsNoTags to filter by

Implementation Reference

  • MCP tool handler for 'filter_deals': parses input, delegates filtering to aggregator, returns formatted JSON response.
    private async handleFilterDeals(args: any) {
      const { deals, ...filterOptions } = args;
      const filter = FilterSchema.parse(filterOptions);
      const filteredDeals = this.aggregator.filterDeals(deals, filter);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              original_count: deals.length,
              filtered_count: filteredDeals.length,
              deals: filteredDeals
            }, null, 2),
          },
        ],
      };
    }
  • Core implementation of deal filtering logic based on categories, stores, price range, rating range, and tags.
    filterDeals(deals: Deal[], filter: Filter): Deal[] {
      return deals.filter(deal => {
        // Category filter
        if (filter.categories && filter.categories.length > 0) {
          if (!deal.category || !filter.categories.includes(deal.category.toLowerCase())) {
            return false;
          }
        }
    
        // Store filter
        if (filter.stores && filter.stores.length > 0) {
          if (!deal.store || !filter.stores.some((store: string) => 
            deal.store.toLowerCase().includes(store.toLowerCase()))) {
            return false;
          }
        }
    
        // Price range filter
        if (filter.priceRange) {
          if (filter.priceRange.min !== undefined && 
              (deal.price === undefined || deal.price < filter.priceRange.min)) {
            return false;
          }
          if (filter.priceRange.max !== undefined && 
              (deal.price === undefined || deal.price > filter.priceRange.max)) {
            return false;
          }
        }
    
        // Rating range filter
        if (filter.ratingRange) {
          if (filter.ratingRange.min !== undefined && 
              (deal.rating === undefined || deal.rating < filter.ratingRange.min)) {
            return false;
          }
          if (filter.ratingRange.max !== undefined && 
              (deal.rating === undefined || deal.rating > filter.ratingRange.max)) {
            return false;
          }
        }
    
        // Tags filter
        if (filter.tags && filter.tags.length > 0) {
          if (!deal.tags || !filter.tags.some((tag: string) => 
            deal.tags!.some((dealTag: string) => dealTag.toLowerCase().includes(tag.toLowerCase())))) {
            return false;
          }
        }
    
        return true;
      });
    }
  • src/server.ts:198-242 (registration)
    Tool registration in getAvailableTools(): defines name, description, and input schema for listTools response.
    {
      name: 'filter_deals',
      description: 'Filter deals using advanced criteria',
      inputSchema: {
        type: 'object',
        properties: {
          deals: {
            type: 'array',
            description: 'Array of deals to filter',
          },
          categories: {
            type: 'array',
            items: { type: 'string' },
            description: 'Categories to include',
          },
          stores: {
            type: 'array',
            items: { type: 'string' },
            description: 'Stores to include',
          },
          priceRange: {
            type: 'object',
            properties: {
              min: { type: 'number' },
              max: { type: 'number' },
            },
            description: 'Price range filter',
          },
          ratingRange: {
            type: 'object',
            properties: {
              min: { type: 'number' },
              max: { type: 'number' },
            },
            description: 'Rating range filter',
          },
          tags: {
            type: 'array',
            items: { type: 'string' },
            description: 'Tags to filter by',
          },
        },
        required: ['deals'],
      },
    },
  • Zod schema for Filter type, used to parse and validate filter options in handleFilterDeals.
    export const FilterSchema = z.object({
      categories: z.array(z.string()).optional(),
      stores: z.array(z.string()).optional(),
      priceRange: z.object({
        min: z.number().optional(),
        max: z.number().optional()
      }).optional(),
      ratingRange: z.object({
        min: z.number().optional(),
        max: z.number().optional()
      }).optional(),
      tags: z.array(z.string()).optional()
    });
    
    export type Filter = z.infer<typeof FilterSchema>;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Filter deals' implies a read-only operation, but the description doesn't clarify whether this is a safe query, what happens with invalid inputs, whether it's paginated, or what the output format looks like. It mentions 'advanced criteria' but doesn't explain what makes them advanced or how they're applied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without unnecessary words. However, it's arguably too concise given the tool's complexity (6 parameters including nested objects) and lack of other documentation. Every word earns its place, but more information might be warranted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 6 parameters (including nested objects), no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes a 'deal' object, how filtering logic works (AND/OR between criteria), what the output looks like, or error conditions. The agent must rely heavily on the schema alone without contextual guidance.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema - it doesn't explain how parameters interact, provide examples of valid values, or clarify the 'advanced criteria' mentioned. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'filters deals using advanced criteria', which provides a basic verb+resource combination. However, it's vague about what 'advanced criteria' means and doesn't differentiate from sibling tools like 'search_deals' or 'get_top_deals' that might also involve filtering operations. The purpose is understandable but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'search_deals' and 'get_top_deals' that likely involve filtering, there's no indication of when this tool is preferred, what prerequisites exist, or what scenarios it's designed for. Usage must be inferred from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/karthiksivaramms/bargainer-mcp-client'

If you have feedback or need assistance with the MCP directory API, please join our Discord server