get_record
Retrieve a single record from a Gadget app by providing its model name, record ID, and desired fields.
Instructions
Get a single Gadget record by ID. Specify the model name, record ID, and fields to return.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model name in camelCase, e.g. shopifyOrder, label | |
| id | Yes | Record ID | |
| fields | Yes | GraphQL field selection, e.g. "id name email createdAt" |
Implementation Reference
- src/tools.ts:282-293 (handler)The handler case for 'get_record' in the handleTool switch statement. It extracts {model, id, fields} from args, builds a GraphQL query to fetch a single record by ID, executes it via the gql() helper, and returns the record data as JSON.
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) }] }; } - src/tools.ts:514-526 (schema)The tool definition/schema for 'get_record' in the TOOL_DEFINITIONS array. Specifies the name, description, required arguments (model, id, fields), and the input schema properties.
{ name: "get_record", description: "Get a single Gadget record by ID. Specify the model name, record ID, and fields to return.", inputSchema: { type: "object", required: ["model", "id", "fields"], properties: { model: { type: "string", description: "Model name in camelCase, e.g. shopifyOrder, label" }, id: { type: "string", description: "Record ID" }, fields: { type: "string", description: "GraphQL field selection, e.g. \"id name email createdAt\"" }, }, }, }, - src/index.ts:48-53 (registration)The MCP server registration that wires up the tool. TOOL_DEFINITIONS is exposed via ListToolsRequestSchema, and the handler function handleTool (which contains the get_record case) is called via CallToolRequestSchema.
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>); });