Skip to main content
Glama
stampchain-io

Stampchain MCP Server

Official

search_collections

Find stamp collections by name, description, or creator address with sorting and pagination options for Bitcoin Stamps data.

Instructions

Search for stamp collections with various filtering criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch query for collection name or description
creatorNoFilter by creator address
sort_byNoSort fieldcreated_at
sort_orderNoSort orderDESC
pageNoPage number
page_sizeNoItems per page

Implementation Reference

  • The execute method of the SearchCollectionsTool class, which validates input parameters, constructs query params, calls the Stampchain API's searchCollections method, formats the results into a table and detailed view, and returns a multi-response with metadata.
    public async execute(
      params: SearchCollectionsParams,
      context?: ToolContext
    ): Promise<ToolResponse> {
      try {
        context?.logger?.info('Executing search_collections tool', { params });
    
        // Validate parameters
        const validatedParams = this.validateParams(params);
    
        // Build query parameters
        const queryParams = {
          query: validatedParams.query,
          creator: validatedParams.creator,
          sort_by: validatedParams.sort_by,
          sort_order: validatedParams.sort_order,
          page: validatedParams.page,
          page_size: validatedParams.page_size,
        };
    
        // Remove undefined values
        Object.keys(queryParams).forEach((key) => {
          if (queryParams[key as keyof typeof queryParams] === undefined) {
            delete queryParams[key as keyof typeof queryParams];
          }
        });
    
        // Search collections
        const searchResponse = await this.apiClient.searchCollections(queryParams);
    
        if (!searchResponse || searchResponse.length === 0) {
          return textResponse('No collections found matching the search criteria');
        }
    
        // Note: searchCollections returns CollectionResponse[] directly
        const collections = searchResponse;
    
        // Create summary
        const lines = [`Found ${collections.length} collections`];
        lines.push('---');
    
        // Create table view
        const collectionTable = createTable(collections, [
          { key: 'collection_name', label: 'Name' },
          {
            key: 'collection_id',
            label: 'ID',
            format: (v: unknown) => (typeof v === 'string' ? v.substring(0, 8) + '...' : String(v)),
          },
          {
            key: 'creators',
            label: 'Creators',
            format: (v: unknown) =>
              Array.isArray(v)
                ? v.join(', ').substring(0, 20) + (v.join(', ').length > 20 ? '...' : '')
                : String(v),
          },
          { key: 'stamp_count', label: 'Stamps' },
          { key: 'total_editions', label: 'Editions' },
        ]);
    
        lines.push(collectionTable);
    
        // Add detailed view for each collection
        lines.push('\n\nDetailed View:');
        lines.push('---');
    
        collections.forEach((collection, index) => {
          lines.push(`\n${index + 1}. ${collection.collection_name}`);
          lines.push(`   ID: ${collection.collection_id}`);
          lines.push(`   Creators: ${collection.creators.join(', ')}`);
          lines.push(`   Stamps: ${collection.stamp_count}`);
          lines.push(`   Total Editions: ${collection.total_editions}`);
          if (collection.collection_description) {
            lines.push(
              `   Description: ${collection.collection_description.substring(0, 100)}${collection.collection_description.length > 100 ? '...' : ''}`
            );
          }
        });
    
        // Include metadata
        const metadata = {
          results_count: collections.length,
          query_params: queryParams,
        };
    
        return multiResponse(
          { type: 'text', text: lines.join('\n') },
          { type: 'text', text: `\n\nSearch Metadata:\n${JSON.stringify(metadata, null, 2)}` }
        );
      } catch (error) {
        context?.logger?.error('Error executing search_collections tool', { error });
    
        if (error instanceof ValidationError) {
          throw error;
        }
    
        throw new ToolExecutionError('Failed to search collections', this.name, error);
      }
    }
  • Zod schema defining the input parameters for the search_collections tool, including optional query, creator filter, sorting options, and pagination.
    export const SearchCollectionsParamsSchema = z.object({
      query: z.string().optional().describe('Search query for collection name or description'),
      creator: z.string().optional().describe('Filter by creator address'),
      sort_by: z
        .enum(['created_at', 'stamp_count', 'name'])
        .optional()
        .default('created_at')
        .describe('Sort field'),
      sort_order: z.enum(['ASC', 'DESC']).optional().default('DESC').describe('Sort order'),
      page: z.number().int().positive().optional().default(1).describe('Page number'),
      page_size: z.number().int().positive().max(100).optional().default(20).describe('Items per page'),
    });
  • Export of the collectionTools object that registers the SearchCollectionsTool class under the 'search_collections' key.
    export const collectionTools = {
      get_collection: GetCollectionTool,
      search_collections: SearchCollectionsTool,
    };
  • The createAllTools function in the central tools index that instantiates and includes the search_collections tool via createCollectionTools(client) in the spread of all tools.
    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,
      };
    }
  • Factory function that creates instances of SearchCollectionsTool for use in the tools registry.
    export function createCollectionTools(apiClient?: StampchainClient) {
      return {
        get_collection: new GetCollectionTool(apiClient),
        search_collections: new SearchCollectionsTool(apiClient),
      };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'various filtering criteria' but doesn't explain what happens when no filters are applied, whether results are paginated (implied by schema but not stated), what the response format looks like, or any rate limits/authentication requirements. For a search tool with 6 parameters, this leaves significant behavioral questions unanswered.

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 gets straight to the point. Every word contributes to understanding the tool's purpose without any fluff or redundancy. It's appropriately sized for a search tool and front-loads the essential information.

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

Completeness2/5

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

For a search tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes a 'stamp collection' versus individual stamps, what fields are searchable beyond name/description, what the response contains, or how results are structured. The agent would need to guess about important behavioral aspects despite having a complete parameter schema.

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?

The schema description coverage is 100%, so all parameters are well-documented in the schema itself. The description adds minimal value beyond stating 'various filtering criteria' - it doesn't explain how parameters interact, what 'creator address' means in context, or provide examples of effective queries. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('search') and resource ('stamp collections'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'search_stamps' or 'search_tokens' - both are search tools for different resources. The description could be more specific about what makes stamp collections unique versus other searchable entities.

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. With multiple search tools available (search_stamps, search_tokens), the agent has no indication whether this is for collections of stamps versus individual stamps versus tokens. There's no mention of prerequisites, typical use cases, or relationships to other tools like 'get_collection'.

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