Skip to main content
Glama

introspect_actions

List all mutations and their arguments available in a Gadget app to understand write operations on a read-only server.

Instructions

List all actions (mutations) available in this Gadget app, including their arguments. Useful for understanding what write operations are available, even though this server is read-only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the 'introspect_actions' tool. Executes a GraphQL introspection query to fetch the mutation type's fields (actions) from the schema, then maps each field to an object with name, description, and arguments. Returns the list of actions as JSON.
    case "introspect_actions": {
      const data = await gql(`
        query {
          __schema {
            mutationType {
              fields {
                name
                description
                args {
                  name
                  description
                  type {
                    name kind
                    ofType { name kind ofType { name kind } }
                  }
                }
              }
            }
          }
        }
      `);
    
      if (!data.__schema.mutationType) {
        return { content: [{ type: "text", text: "No actions (mutations) found in this schema." }] };
      }
    
      const actions = (data.__schema.mutationType.fields as any[]).map((f) => ({
        name: f.name,
        description: f.description ?? "",
        args: (f.args ?? []).map((a: any) => ({
          name: a.name,
          type: typeString(a.type),
          description: a.description ?? "",
        })),
      }));
    
      return { content: [{ type: "text", text: JSON.stringify(actions, null, 2) }] };
    }
  • Input schema definition for the 'introspect_actions' tool. It has no required parameters and an empty properties object, as it simply lists all available mutations from the schema.
    {
      name: "introspect_actions",
      description:
        "List all actions (mutations) available in this Gadget app, including their arguments. Useful for understanding what write operations are available, even though this server is read-only.",
      inputSchema: { type: "object", properties: {} },
    },
  • src/tools.ts:117-452 (registration)
    The main handleTool function dispatches tool calls via a switch statement. The case 'introspect_actions' at line 335 is the registration/dispatch point. The TOOL_DEFINITIONS array (line 454-564) is exported and used in index.ts (line 48) for the ListTools request handler.
    // ── Tool handler ──────────────────────────────────────────────────────────────
    export async function handleTool(name: string, args: Record<string, any>): Promise<{
      content: { type: string; text: string }[];
      isError?: boolean;
    }> {
      try {
        switch (name) {
          case "list_models": {
            const data = await gql(`
              query {
                __schema {
                  queryType {
                    fields {
                      name
                      description
                      type { name kind }
                    }
                  }
                }
              }
            `);
            const fields: any[] = data.__schema.queryType.fields;
            const models = fields
              .filter((f) => f.name && !f.name.startsWith("__") && f.type?.kind === "OBJECT")
              .map((f) => ({ name: f.name, description: f.description ?? "" }));
            return { content: [{ type: "text", text: JSON.stringify(models, null, 2) }] };
          }
    
          case "introspect_model": {
            const { model } = args as { model: string };
            const typeName = model.charAt(0).toUpperCase() + model.slice(1);
            const data = await gql(`
              query IntrospectModel($name: String!) {
                __type(name: $name) {
                  name
                  fields {
                    name
                    description
                    type {
                      name
                      kind
                      ofType { name kind }
                    }
                  }
                }
              }
            `, { name: typeName });
            if (!data.__type) {
              return {
                content: [{ type: "text", text: `No type found for "${typeName}". Try list_models to see available model names, then adjust casing.` }],
              };
            }
            return { content: [{ type: "text", text: JSON.stringify(data.__type, null, 2) }] };
          }
    
          case "query_records": {
            const { model, fields, filter, sort, limit = 10, after } = args as {
              model: string;
              fields: string;
              filter?: unknown;
              sort?: unknown;
              limit?: number;
              after?: string;
            };
            const first = Math.min(limit, 50);
    
            const resolved = await resolveListField(model);
            if (!resolved) {
              return {
                content: [{ type: "text", text: `No connection field found for model "${model}". Use list_models to browse available models.` }],
                isError: true,
              };
            }
    
            const { fieldName, filterArgType, sortArgType } = resolved;
            const varParts: string[] = ["$first: Int"];
            const argParts: string[] = ["first: $first"];
            const varsVal: Record<string, unknown> = { first };
    
            if (after) {
              varParts.push("$after: String");
              argParts.push("after: $after");
              varsVal.after = after;
            }
    
            if (filter !== undefined && filterArgType) {
              varParts.push(`$filter: ${filterArgType}`);
              argParts.push("filter: $filter");
              varsVal.filter = filter;
            }
    
            if (sort !== undefined && sortArgType) {
              varParts.push(`$sort: ${sortArgType}`);
              argParts.push("sort: $sort");
              varsVal.sort = sort;
            }
    
            const query = `
              query QueryRecords(${varParts.join(", ")}) {
                ${fieldName}(${argParts.join(", ")}) {
                  edges {
                    node {
                      ${fields}
                    }
                  }
                  pageInfo { hasNextPage endCursor }
                }
              }
            `;
    
            const data = await gql(query, varsVal);
            const connection = data[fieldName];
            const records = connection.edges.map((e: any) => e.node);
            return {
              content: [{
                type: "text",
                text: JSON.stringify({
                  records,
                  hasMore: connection.pageInfo.hasNextPage,
                  endCursor: connection.pageInfo.endCursor ?? null,
                }, null, 2),
              }],
            };
          }
    
          case "count_records": {
            const { model, filter } = args as { model: string; filter?: unknown };
    
            const resolved = await resolveListField(model);
            if (!resolved) {
              return {
                content: [{ type: "text", text: `No connection field found for model "${model}". Use list_models to browse available models.` }],
                isError: true,
              };
            }
    
            const { fieldName, filterArgType } = resolved;
            const varParts: string[] = [];
            const argParts: string[] = [];
            const varsVal: Record<string, unknown> = {};
    
            if (filter !== undefined && filterArgType) {
              varParts.push(`$filter: ${filterArgType}`);
              argParts.push("filter: $filter");
              varsVal.filter = filter;
            }
    
            const varsDef = varParts.length ? `(${varParts.join(", ")})` : "";
            const argsClause = argParts.length ? `(${argParts.join(", ")})` : "";
    
            const query = `
              query CountRecords${varsDef} {
                ${fieldName}${argsClause} {
                  count
                }
              }
            `;
    
            const data = await gql(query, Object.keys(varsVal).length ? varsVal : undefined);
            const count = data[fieldName].count;
            return {
              content: [{ type: "text", text: JSON.stringify({ model, count }, null, 2) }],
            };
          }
    
          case "get_record": {
            const { model, id, fields } = args as { model: string; id: string; fields: string };
            const query = `
              query GetRecord($id: GadgetID!) {
                ${model}(id: $id) {
                  ${fields}
                }
              }
            `;
            const data = await gql(query, { id });
            return { content: [{ type: "text", text: JSON.stringify(data[model], null, 2) }] };
          }
    
          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) }] };
          }
    
          case "introspect_actions": {
            const data = await gql(`
              query {
                __schema {
                  mutationType {
                    fields {
                      name
                      description
                      args {
                        name
                        description
                        type {
                          name kind
                          ofType { name kind ofType { name kind } }
                        }
                      }
                    }
                  }
                }
              }
            `);
    
            if (!data.__schema.mutationType) {
              return { content: [{ type: "text", text: "No actions (mutations) found in this schema." }] };
            }
    
            const actions = (data.__schema.mutationType.fields as any[]).map((f) => ({
              name: f.name,
              description: f.description ?? "",
              args: (f.args ?? []).map((a: any) => ({
                name: a.name,
                type: typeString(a.type),
                description: a.description ?? "",
              })),
            }));
    
            return { content: [{ type: "text", text: JSON.stringify(actions, null, 2) }] };
          }
    
          case "get_schema_overview": {
            const data = await gql(`
              query {
                __schema {
                  queryType {
                    fields {
                      name
                      type {
                        kind name
                        ofType { kind name }
                      }
                    }
                  }
                  types {
                    name
                    kind
                    description
                    fields {
                      name
                      description
                      type {
                        name kind
                        ofType { name kind ofType { name kind } }
                      }
                    }
                  }
                }
              }
            `);
    
            // Identify model names from Connection return types in query fields
            const modelNames = new Set<string>();
            for (const f of data.__schema.queryType.fields as any[]) {
              let t = f.type;
              if (t?.kind === "NON_NULL") t = t.ofType;
              if (t?.name?.endsWith("Connection")) {
                modelNames.add(t.name.replace(/Connection$/, ""));
              }
            }
    
            const models = (data.__schema.types as any[])
              .filter((t) => modelNames.has(t.name) && t.kind === "OBJECT")
              .map((t) => ({
                name: t.name,
                description: t.description ?? "",
                fields: (t.fields ?? []).map((f: any) => ({
                  name: f.name,
                  type: typeString(f.type),
                  description: f.description ?? "",
                })),
              }))
              .sort((a, b) => a.name.localeCompare(b.name));
    
            return { content: [{ type: "text", text: JSON.stringify(models, null, 2) }] };
          }
    
          case "run_graphql": {
            const { query, variables } = args as { query: string; variables?: Record<string, unknown> };
            const trimmed = query.trim().toLowerCase();
            if (trimmed.startsWith("mutation")) {
              return {
                content: [{ type: "text", text: "Mutations are not allowed — this server is read-only." }],
                isError: true,
              };
            }
            const data = await gql(query, variables);
            return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
          }
    
          default:
            return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
        }
      } catch (err: any) {
        return {
          content: [{ type: "text", text: `Error: ${err?.message ?? String(err)}` }],
          isError: true,
        };
      }
    }
Behavior3/5

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

Without annotations, the description bears the full burden. It adds important context that the server is read-only, which informs the agent about the nature of the listed actions. However, it does not disclose other behavioral aspects like authentication requirements or whether the list is exhaustive.

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?

The description is two sentences, with the main purpose in the first sentence and useful context in the second. Every sentence adds value, and there is no redundancy.

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

Completeness5/5

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

Given the simple nature of the tool (no parameters, no output schema), the description provides sufficient information for an agent to understand and use it correctly.

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

Parameters4/5

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

The input schema has no parameters, and schema description coverage is 100%. As per guidelines, a tool with zero parameters gets a baseline of 4. The description does not need to add parameter semantics.

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 it lists all actions (mutations) in the Gadget app, including their arguments. This distinguishes it from sibling introspection tools like 'introspect_filters' or 'introspect_model', which focus on other aspects.

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 mentions the tool is useful for understanding write operations despite the server being read-only, providing clear context for when to use it. However, it does not explicitly state when not to use it or name alternatives.

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