Skip to main content
Glama

introspect_filters

Discover filter fields and their types for a Gadget model to construct valid filter arguments for queries and counts.

Instructions

Show all available filter fields and their types for a Gadget model. Use this to construct valid filter arguments for query_records and count_records.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel name in singular camelCase, e.g. shopifyOrder, label

Implementation Reference

  • Handler case for 'introspect_filters' inside handleTool(). Extracts the 'model' arg, resolves the list field to get the filter type name, then runs a GraphQL introspection query (__type) to get inputFields (name, description, type) for that filter type. Returns the filter schema as JSON.
    case "introspect_filters": {
      const { model } = args as { model: string };
    
      const resolved = await resolveListField(model);
      if (!resolved?.filterArgType) {
        return {
          content: [{ type: "text", text: `No filter type found for model "${model}". Use list_models to verify the model name.` }],
          isError: true,
        };
      }
    
      // Extract base type name from e.g. "[ShopifyOrderFilter!]" → "ShopifyOrderFilter"
      const filterTypeName = resolved.filterArgType.replace(/[\[\]!]/g, "");
    
      const data = await gql(`
        query IntrospectFilters($name: String!) {
          __type(name: $name) {
            name
            inputFields {
              name
              description
              type {
                name kind
                ofType { name kind ofType { name kind } }
              }
            }
          }
        }
      `, { name: filterTypeName });
    
      if (!data.__type) {
        return {
          content: [{ type: "text", text: `Filter type "${filterTypeName}" not found in schema.` }],
          isError: true,
        };
      }
    
      return { content: [{ type: "text", text: JSON.stringify(data.__type, null, 2) }] };
    }
  • src/tools.ts:527-538 (registration)
    Tool definition for 'introspect_filters' in the TOOL_DEFINITIONS array. Declares the name, description ('Show all available filter fields and their types for a Gadget model'), inputSchema (required 'model' string in camelCase), and is registered via ListToolsRequestSchema handler in index.ts.
    {
      name: "introspect_filters",
      description:
        "Show all available filter fields and their types for a Gadget model. Use this to construct valid filter arguments for query_records and count_records.",
      inputSchema: {
        type: "object",
        required: ["model"],
        properties: {
          model: { type: "string", description: "Model name in singular camelCase, e.g. shopifyOrder, label" },
        },
      },
    },
  • resolveListField() helper used by the introspect_filters handler. Introspects the GraphQL schema to find the query field for a model's connection type and extracts the filter argument type string (e.g., '[ShopifyOrderFilter!]'). This is cached per model for efficiency.
    async function resolveListField(model: string): Promise<ResolvedListField | null> {
      const cached = listFieldCache.get(model);
      if (cached !== undefined) return cached;
    
      if (!queryFieldsCache) {
        const data = await gql(`
          query {
            __schema {
              queryType {
                fields {
                  name
                  args {
                    name
                    type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }
                  }
                  type {
                    kind name
                    ofType { kind name ofType { kind name } }
                  }
                }
              }
            }
          }
        `);
        queryFieldsCache = data.__schema.queryType.fields;
      }
    
      const modelType = model.charAt(0).toUpperCase() + model.slice(1);
    
      // Find the query field whose return type is <ModelType>Connection
      const field = queryFieldsCache!.find((f: any) => {
        let t = f.type;
        // Unwrap NON_NULL
        if (t?.kind === "NON_NULL") t = t.ofType;
        return t?.name === `${modelType}Connection`;
      });
    
      if (!field) {
        listFieldCache.set(model, null);
        return null;
      }
    
      const filterArg = field.args?.find((a: any) => a.name === "filter");
      const filterArgType = filterArg ? typeString(filterArg.type) : undefined;
    
      const sortArg = field.args?.find((a: any) => a.name === "sort");
      const sortArgType = sortArg ? typeString(sortArg.type) : undefined;
    
      const result: ResolvedListField = { fieldName: field.name, filterArgType, sortArgType };
      listFieldCache.set(model, result);
      return result;
    }
  • src/index.ts:48-53 (registration)
    MCP server request handlers. ListToolsRequestSchema returns the TOOL_DEFINITIONS array (which includes introspect_filters). CallToolRequestSchema dispatches to handleTool() which routes to the introspect_filters case.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
    
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
      return handleTool(name, (args ?? {}) as Record<string, any>);
    });
Behavior4/5

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

No annotations provided, so description carries full burden. It accurately describes a read-only introspection tool without side effects, but could be improved by noting any authentication requirements or potential performance impact.

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

Conciseness5/5

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

Two sentences, no filler. Every sentence provides essential information: what it does and how to use it.

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

Completeness4/5

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

Given the simple single-parameter input and no output schema, the description adequately covers purpose and usage. It could briefly mention what the output contains (e.g., list of fields with types), but it's still sufficient for an introspection tool.

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 coverage is 100%, so baseline is 3. The description does not add extra meaning beyond the schema's 'Model name in singular camelCase' example; it simply restates the parameter role.

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

Purpose5/5

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

The description clearly states the tool shows all available filter fields and their types for a Gadget model, using specific verb 'show' and resource. It distinguishes from siblings like query_records and count_records by explicitly linking to filter argument construction.

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

Usage Guidelines4/5

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

The description explicitly states to use this tool for constructing valid filter arguments for query_records and count_records, providing clear context. However, it does not mention when not to use it or alternatives like introspect_model.

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/Stronger-eCommerce/gadget-mcp'

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