Skip to main content
Glama

get_sip009_collection_info

Retrieve SIP-009 NFT collection details including total supply and last token ID by providing contract address, name, and network.

Instructions

Get information about a SIP-009 NFT collection including total supply and last token ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractAddressYesThe contract address
contractNameYesThe contract name of the SIP-009 NFT collection
networkYesThe Stacks network

Implementation Reference

  • The complete tool definition and handler (execute function) for 'get_sip009_collection_info'. It calls read-only functions on the contract via Hiro API to get last token ID and optional collection info, then formats a markdown response with collection statistics.
    export const getSIP009CollectionInfoTool: Tool<undefined, typeof SIP009CollectionInfoScheme> = {
      name: "get_sip009_collection_info",
      description: "Get information about a SIP-009 NFT collection including total supply and last token ID.",
      parameters: SIP009CollectionInfoScheme,
      execute: async (args, context) => {
        try {
          await recordTelemetry({ action: "get_sip009_collection_info" }, context);
          
          // Get collection information
          const lastTokenIdResult = await callReadOnlyFunction(
            args.contractAddress,
            args.contractName,
            "get-last-token-id",
            [],
            args.network
          );
          
          const lastTokenId = lastTokenIdResult.okay 
            ? parseInt(lastTokenIdResult.result.replace('u', '')) 
            : 0;
          
          // Try to get additional collection info if available
          let collectionInfo = null;
          try {
            const collectionInfoResult = await callReadOnlyFunction(
              args.contractAddress,
              args.contractName,
              "get-collection-info",
              [],
              args.network
            );
            
            if (collectionInfoResult.okay) {
              collectionInfo = collectionInfoResult.result;
            }
          } catch {
            // Collection info function may not exist
          }
          
          return `# SIP-009 NFT Collection Information
    
    **Contract**: ${args.contractAddress}.${args.contractName}
    **Network**: ${args.network}
    
    ## Collection Stats
    - **Total Supply**: ${lastTokenId} NFTs
    - **Last Token ID**: ${lastTokenId}
    - **Token ID Range**: 1 to ${lastTokenId}
    
    ${collectionInfo ? `
    ## Additional Collection Details
    ${collectionInfo}
    ` : ''}
    
    ## Contract Verification
    ✅ This contract implements the SIP-009 NFT standard trait.
    
    ## Integration Notes
    - All token IDs start from 1 (SIP-009 requirement)
    - Use get_sip009_token_info to get details for specific tokens
    - Post-conditions are mandatory for all transfers`;
          
        } catch (error) {
          return `❌ Failed to get SIP-009 collection info: ${error}`;
        }
      },
  • Zod schema defining the input parameters: contractAddress, contractName, and network (mainnet/testnet/devnet).
    const SIP009CollectionInfoScheme = z.object({
      contractAddress: z.string().describe("The contract address"),
      contractName: z.string().describe("The contract name of the SIP-009 NFT collection"),
      network: NetworkScheme.describe("The Stacks network"),
    });
  • Registration of the tool in the FastMCP server using server.addTool().
    server.addTool(getSIP009CollectionInfoTool);
  • Import statement that brings the getSIP009CollectionInfoTool into the index file for registration.
    import {
      getSIP009TokenInfoTool,
      getSIP009CollectionInfoTool,
      generateSIP009TransferTool,
      generateSIP009TemplateTool
    } from "./stacks_blockchain/tokens/sip009_nft.js";
  • Helper function used by the handler to call read-only Clarity functions on the contract via Hiro Systems API.
    async function callReadOnlyFunction(
      contractAddress: string,
      contractName: string,
      functionName: string,
      functionArgs: any[],
      network: string
    ): Promise<any> {
      const apiUrl = network === "mainnet" 
        ? "https://api.hiro.so" 
        : "https://api.testnet.hiro.so";
      
      try {
        const response = await fetch(
          `${apiUrl}/v2/contracts/call-read/${contractAddress}/${contractName}/${functionName}`,
          {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
              sender: contractAddress,
              arguments: functionArgs,
            }),
          }
        );
        
        if (!response.ok) {
          const data: any = await response.json();
          throw new Error(data.error || `HTTP ${response.status}`);
        }
        
        return await response.json();
      } catch (error) {
        throw new Error(`Failed to call ${functionName}: ${error}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While it implies a read-only operation ('Get information'), it doesn't specify whether this requires authentication, has rate limits, returns paginated results, or what happens with invalid inputs. For a tool with zero 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.

Conciseness4/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. It wastes no words but could be slightly more structured by separating purpose from returned data points. Every word earns its place, making it appropriately concise for a simple retrieval tool.

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 3 parameters with full schema coverage but no annotations and no output schema, the description is minimally adequate. It states what information is returned (total supply, last token ID), which partially compensates for the missing output schema. However, for a tool with no behavioral annotations, it should ideally disclose more about operational constraints or error conditions.

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 already documents all three parameters (contractAddress, contractName, network) with descriptions and enum values. The description doesn't add any parameter-specific context beyond what's in the schema, such as format examples or interdependencies. Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose: 'Get information about a SIP-009 NFT collection including total supply and last token ID.' It specifies the verb ('Get'), resource ('SIP-009 NFT collection'), and key data points returned. However, it doesn't explicitly differentiate from sibling tools like 'get_sip009_token_info' (which gets info about individual tokens rather than collections).

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. It doesn't mention sibling tools like 'get_sip009_token_info' for token-level details or 'get_sip010_info' for fungible tokens, nor does it specify prerequisites or contextual constraints for collection information retrieval.

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/exponentlabshq/stacks-clarity-mcp'

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