Skip to main content
Glama
stampchain-io

Stampchain MCP Server

Official

get_collection

Retrieve detailed information about a specific Bitcoin Stamps collection by its ID, optionally including paginated stamp data.

Instructions

Retrieve detailed information about a specific stamp collection by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_idYesThe ID of the collection to retrieve
include_stampsNoWhether to include stamps in the collection
stamps_pageNoPage number for stamps if included
stamps_limitNoNumber of stamps per page

Implementation Reference

  • The GetCollectionTool class implements the core logic for the 'get_collection' tool. It validates input, calls the Stampchain API (using searchCollections as fallback), formats collection information and optional stamps into a table, and returns a multi-part response including text summary and JSON data.
    export class GetCollectionTool extends BaseTool<
      z.input<typeof GetCollectionParamsSchema>,
      GetCollectionParams
    > {
      public readonly name = 'get_collection';
    
      public readonly description =
        'Retrieve detailed information about a specific stamp collection by its ID';
    
      public readonly inputSchema: MCPTool['inputSchema'] = {
        type: 'object',
        properties: {
          collection_id: {
            type: 'string',
            description: 'The ID of the collection to retrieve',
          },
          include_stamps: {
            type: 'boolean',
            description: 'Whether to include stamps in the collection',
            default: false,
          },
          stamps_page: {
            type: 'number',
            description: 'Page number for stamps if included',
            minimum: 1,
            default: 1,
          },
          stamps_limit: {
            type: 'number',
            description: 'Number of stamps per page',
            minimum: 1,
            maximum: 100,
            default: 20,
          },
        },
        required: ['collection_id'],
      };
    
      public readonly schema = GetCollectionParamsSchema;
    
      public readonly metadata = {
        version: '1.0.0',
        tags: ['collections', 'query'],
        requiresNetwork: true,
        apiDependencies: ['stampchain'],
      };
    
      private apiClient: StampchainClient;
    
      constructor(apiClient?: StampchainClient) {
        super();
        this.apiClient = apiClient || new StampchainClient();
      }
    
      public async execute(params: GetCollectionParams, context?: ToolContext): Promise<ToolResponse> {
        try {
          context?.logger?.info('Executing get_collection tool', { params });
    
          // Validate parameters
          const validatedParams = this.validateParams(params);
    
          // Since the API doesn't have a direct getCollection method,
          // we'll search for collections with the specific ID
          const collectionResponse = await this.apiClient.searchCollections({
            query: validatedParams.collection_id,
            page: 1,
            page_size: 1,
          });
    
          if (!collectionResponse || collectionResponse.length === 0) {
            throw new ToolExecutionError(
              `Collection with ID ${validatedParams.collection_id} not found`,
              this.name,
              { collectionId: validatedParams.collection_id }
            );
          }
    
          const collection = collectionResponse[0];
          const contents = [];
    
          // Add formatted collection info
          const collectionInfo = [
            `Collection: ${collection.collection_name}`,
            `ID: ${collection.collection_id}`,
            `Description: ${collection.collection_description}`,
            `Creators: ${collection.creators.join(', ')}`,
            `Stamps: ${collection.stamp_count}`,
            `Total Editions: ${collection.total_editions}`,
          ].join('\n');
          contents.push({ type: 'text' as const, text: collectionInfo });
    
          // If stamps are requested, fetch them
          if (validatedParams.include_stamps) {
            try {
              const stampsResponse = await this.apiClient.searchStamps({
                collection_id: validatedParams.collection_id,
                page: validatedParams.stamps_page,
                page_size: validatedParams.stamps_limit,
              });
    
              if (stampsResponse && stampsResponse.length > 0) {
                contents.push({
                  type: 'text' as const,
                  text: `\n\nStamps in Collection (Page ${validatedParams.stamps_page}):\n`,
                });
    
                const stampTable = createTable(stampsResponse, [
                  { key: 'stamp', label: 'ID' },
                  { key: 'cpid', label: 'CPID' },
                  {
                    key: 'creator',
                    label: 'Creator',
                    format: (v: unknown) =>
                      typeof v === 'string' ? v.substring(0, 12) + '...' : String(v),
                  },
                  { key: 'supply', label: 'Supply' },
                  {
                    key: 'floorPrice',
                    label: 'Floor Price',
                    format: (v: unknown) => (v ? `${String(v)} BTC` : 'N/A'),
                  },
                ]);
    
                contents.push({ type: 'text' as const, text: stampTable });
                contents.push({
                  type: 'text' as const,
                  text: `\nTotal stamps in collection: ${stampsResponse.length}`,
                });
              }
            } catch (error) {
              context?.logger?.warn('Failed to fetch stamps for collection', { error });
              contents.push({
                type: 'text' as const,
                text: '\n\nNote: Unable to fetch stamps for this collection',
              });
            }
          }
    
          // Add JSON representation
          contents.push({
            type: 'text' as const,
            text: JSON.stringify(collection, null, 2),
          });
    
          return multiResponse(...contents);
        } catch (error) {
          context?.logger?.error('Error executing get_collection tool', { error });
    
          if (error instanceof ValidationError) {
            throw error;
          }
    
          if (error instanceof ToolExecutionError) {
            throw error;
          }
    
          throw new ToolExecutionError('Failed to retrieve collection information', this.name, error);
        }
      }
    }
  • Zod schema defining the input parameters for the get_collection tool, including collection_id (required), and optional flags for including stamps with pagination.
    export const GetCollectionParamsSchema = z.object({
      collection_id: z.string().describe('The ID of the collection to retrieve'),
      include_stamps: z
        .boolean()
        .optional()
        .default(false)
        .describe('Whether to include stamps in the collection'),
      stamps_page: z
        .number()
        .int()
        .positive()
        .optional()
        .default(1)
        .describe('Page number for stamps if included'),
      stamps_limit: z
        .number()
        .int()
        .positive()
        .max(100)
        .optional()
        .default(20)
        .describe('Number of stamps per page'),
    });
  • Factory function that instantiates the GetCollectionTool (as 'get_collection') with optional API client, used for tool registration.
    export function createCollectionTools(apiClient?: StampchainClient) {
      return {
        get_collection: new GetCollectionTool(apiClient),
        search_collections: new SearchCollectionsTool(apiClient),
      };
    }
  • Central factory that creates all tool instances including 'get_collection' from createCollectionTools, spreading them into the main tools registry.
    export function createAllTools(apiClient?: StampchainClient): Record<string, ITool> {
      const client = apiClient || new StampchainClient();
    
      const stamps = createStampTools(client);
      const collections = createCollectionTools(client);
      const tokens = createTokenTools(client);
      const analysis = createStampAnalysisTools(client);
    
      return {
        ...stamps,
        ...collections,
        ...tokens,
        ...analysis,
      };
    }
  • API client method to fetch a specific collection by ID, though the tool uses searchCollections instead (noted in tool comments).
    async getCollection(collectionId: string): Promise<CollectionResponse> {
      const response = await this.client.get<CollectionResponse>(`/collections/${collectionId}`);
      return response.data;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves information, implying a read-only operation, but doesn't mention potential side effects, authentication needs, rate limits, or response format. For a tool with 4 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that front-loads the core purpose ('retrieve detailed information about a specific stamp collection by its ID') with zero wasted words. Every part of the sentence contributes directly to understanding the tool's function.

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

Completeness3/5

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

Given no annotations and no output schema, the description adequately covers the basic purpose but lacks details on behavioral traits, response format, and usage context. For a retrieval tool with 4 parameters, it provides a minimal viable foundation but doesn't fully compensate for the missing structured data, leaving room for improvement in completeness.

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 description coverage is 100%, so the schema fully documents all 4 parameters (collection_id, include_stamps, stamps_page, stamps_limit). The description adds no parameter-specific information beyond implying the collection_id is required, which is already clear from the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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 'detailed information about a specific stamp collection by its ID', making the purpose unambiguous. It distinguishes from siblings like 'search_collections' by focusing on a single collection rather than searching multiple. However, it doesn't explicitly contrast with 'get_stamp' or other get_* tools, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_collections' for finding collections or 'get_stamp' for individual stamps. It mentions retrieving by ID but doesn't specify prerequisites (e.g., needing the ID first) or exclusions, leaving usage context implied rather than explicit.

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/stampchain-io/stampchain-mcp'

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