Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYesThe 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)'),
    },
  • 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
    }
Behavior4/5

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

No annotations provided; description specifies ordering by timestamp ascending, returns complete receipt objects, and states it's read-only retrieval. Does not cover authentication or edge cases, but sufficient for typical use.

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?

Three sentences, first sentence front-loads action and resource, followed by context and use cases. No wasted words.

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?

No output schema but description explains return value (complete receipt objects) and ordering. For a single-param retrieval tool, all necessary context is present.

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 already covers the one parameter (chain_id) with format and example. Description adds no extra semantic value beyond stating it identifies the chain.

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 verb 'Retrieve' and the resource 'all receipts belonging to a chain', distinguishing it from sibling tools like get_receipt (single receipt) and list_receipts (filtered list).

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?

Explicit use cases are provided: audit workflow, calculate cost/duration, identify failed step. Lacks explicit exclusion guidance, but context is clear.

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/webaesbyamin/agent-receipts'

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