introspect_model
List all fields and their types for a Gadget model. Use this to discover available fields when unsure.
Instructions
List all fields and their types for a Gadget model. Run this first when you're unsure what fields exist on a model.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model name in camelCase, e.g. shopifyOrder, label, shopifyShop |
Implementation Reference
- src/tools.ts:145-170 (handler)The main handler for the 'introspect_model' tool. It takes a 'model' argument (camelCase), constructs a GraphQL introspection query to get the model type's fields, and returns the type information as JSON.
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) }] }; } - src/tools.ts:456-469 (schema)The tool definition/input schema registration for 'introspect_model'. Defines the tool name, description, and required 'model' string parameter.
{ name: "introspect_model", description: "List all fields and their types for a Gadget model. Run this first when you're unsure what fields exist on a model.", inputSchema: { type: "object", required: ["model"], properties: { model: { type: "string", description: "Model name in camelCase, e.g. shopifyOrder, label, shopifyShop", }, }, }, - src/index.ts:48-53 (registration)Registration of the tool definitions (including introspect_model) with the MCP server via ListToolsRequestSchema, and dispatching tool calls via CallToolRequestSchema which calls handleTool.
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>); });