get_chain
Retrieve all receipts in a workflow chain ordered by timestamp. Use to audit complete multi-step agent workflows, calculate total cost and duration, or detect failed steps.
Instructions
Retrieve all receipts belonging to a chain, ordered by timestamp ascending to show the sequence of operations. A chain groups related receipts from a multi-step agent workflow. Returns the complete receipt objects for every step. Use to audit a complete workflow, calculate total chain cost and duration, or identify which step in a pipeline failed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes | The chain ID to retrieve (format: "chain_" followed by 8 alphanumeric characters) |
Implementation Reference
- The MCP tool handler for 'get_chain'. Registers a server.tool that accepts a chain_id parameter, calls engine.getChain(), and returns the receipts as JSON.
export function registerGetChain(server: McpServer, engine: ReceiptEngine): void { server.tool( 'get_chain', 'Retrieve all receipts belonging to a chain, ordered by timestamp ascending to show the sequence of operations. A chain groups related receipts from a multi-step agent workflow. Returns the complete receipt objects for every step. Use to audit a complete workflow, calculate total chain cost and duration, or identify which step in a pipeline failed.', { chain_id: z.string().describe('The chain ID to retrieve (format: "chain_" followed by 8 alphanumeric characters)'), }, async (params) => { const receipts = await engine.getChain(params.chain_id) if (receipts.length === 0) { return { content: [{ type: 'text' as const, text: `No receipts found for chain: ${params.chain_id}` }], } } return { content: [{ type: 'text' as const, text: JSON.stringify(receipts, null, 2) }], } }, ) - Input schema for get_chain: requires a chain_id string parameter.
{ chain_id: z.string().describe('The chain ID to retrieve (format: "chain_" followed by 8 alphanumeric characters)'), }, - packages/mcp-server/src/tools/index.ts:43-43 (registration)Registration of registerGetChain in the registerAllTools function.
registerGetChain(server, engine) - Engine layer getChain method that delegates to the store's getChain.
async getChain(chainId: string): Promise<ActionReceipt[]> { return this.store.getChain(chainId) } - Base store getChain implementation: lists receipts filtered by chain_id, sorted ascending by timestamp, limited to 1000 results.
async getChain(chainId: string): Promise<ActionReceipt[]> { const result = await this.list({ chain_id: chainId }, 1, 1000, 'timestamp:asc') return result.data }