Skip to main content
Glama
stampchain-io

Stampchain MCP Server

Official

get_stamp_market_data

Retrieve market data for a specific Bitcoin Stamp to analyze pricing, trends, and trading activity on the Stampchain platform.

Instructions

Retrieve detailed market data for a specific stamp (v2.3 feature)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stamp_idYesThe ID of the stamp to get market data for

Implementation Reference

  • The GetStampMarketDataTool class implements the core handler logic for the 'get_stamp_market_data' tool. It validates input, checks API feature availability, calls the StampchainClient.getStampMarketData method, formats the market data response, and handles errors.
    export class GetStampMarketDataTool extends BaseTool<
      z.input<typeof GetStampMarketDataParamsSchema>,
      GetStampMarketDataParams
    > {
      public readonly name = 'get_stamp_market_data';
    
      public readonly description = 'Retrieve detailed market data for a specific stamp (v2.3 feature)';
    
      public readonly inputSchema: MCPTool['inputSchema'] = {
        type: 'object',
        properties: {
          stamp_id: {
            type: ['number', 'string'],
            description: 'The ID of the stamp to get market data for',
          },
        },
        required: ['stamp_id'],
      };
    
      public readonly schema = GetStampMarketDataParamsSchema;
    
      public readonly metadata = {
        version: '1.0.0',
        tags: ['stamps', 'market', 'trading', 'v2.3'],
        requiresNetwork: true,
        apiDependencies: ['stampchain'],
      };
    
      private apiClient: StampchainClient;
    
      constructor(apiClient?: StampchainClient) {
        super();
        this.apiClient = apiClient || new StampchainClient();
      }
    
      public async execute(
        params: GetStampMarketDataParams,
        context?: ToolContext
      ): Promise<ToolResponse> {
        try {
          context?.logger?.info('Executing get_stamp_market_data tool', { params });
    
          // Validate parameters
          const validatedParams = this.validateParams(params);
    
          // Use API client from context if available, otherwise use instance client
          const client = context?.apiClient || this.apiClient;
    
          // Check if v2.3 features are available
          const features = client.getFeatureAvailability();
          if (!features.marketData) {
            return textResponse(
              'Market data is not available in the current API version. Please upgrade to v2.3 or later.'
            );
          }
    
          // Get stamp market data
          const marketData: StampMarketData = await client.getStampMarketData(validatedParams.stamp_id);
    
          if (!marketData) {
            return textResponse(`No market data found for stamp ${validatedParams.stamp_id}`);
          }
    
          // Format the response
          const lines = [`Market Data for Stamp #${validatedParams.stamp_id}:`];
          lines.push('---');
    
          lines.push(`Floor Price: ${marketData.floorPriceBTC || 'N/A'} BTC`);
          if (marketData.floorPriceUSD) {
            lines.push(`Floor Price USD: $${marketData.floorPriceUSD.toFixed(2)}`);
          }
          // Note: marketCapUSD not available in v2.3 marketData object
    
          lines.push(`Activity Level: ${marketData.activityLevel}`);
          if (marketData.lastActivityTime) {
            lines.push(`Last Activity: ${new Date(marketData.lastActivityTime * 1000).toISOString()}`);
          }
    
          if (marketData.volume24hBTC) {
            lines.push(`24h Volume: ${marketData.volume24hBTC} BTC`);
          }
          if (marketData.volume7dBTC) {
            lines.push(`7d Volume: ${marketData.volume7dBTC} BTC`);
          }
          if (marketData.volume30dBTC) {
            lines.push(`30d Volume: ${marketData.volume30dBTC} BTC`);
          }
    
          if (marketData.lastSaleTxHash) {
            lines.push('');
            lines.push('Last Sale Details:');
            lines.push(`- Transaction: ${marketData.lastSaleTxHash}`);
            if (marketData.lastSaleBuyerAddress) {
              lines.push(`- Buyer: ${marketData.lastSaleBuyerAddress}`);
            }
            if (marketData.lastSaleDispenserAddress) {
              lines.push(`- Dispenser: ${marketData.lastSaleDispenserAddress}`);
            }
            if (marketData.lastSaleBtcAmount) {
              lines.push(`- Amount: ${marketData.lastSaleBtcAmount} BTC`);
            }
            if (marketData.lastSaleBlockIndex) {
              lines.push(`- Block: ${marketData.lastSaleBlockIndex}`);
            }
          }
    
          return textResponse(lines.join('\n'));
        } catch (error) {
          context?.logger?.error('Error executing get_stamp_market_data tool', { error });
    
          if (error instanceof ValidationError) {
            throw error;
          }
    
          if (error instanceof ToolExecutionError) {
            throw error;
          }
    
          // Pass through the original error message for API errors
          if (error instanceof Error) {
            throw new ToolExecutionError(error.message, this.name, error);
          }
    
          throw new ToolExecutionError('Failed to retrieve stamp market data', this.name, error);
        }
      }
    }
  • Zod schema and TypeScript type definition for the input parameters of the get_stamp_market_data tool, validating the stamp_id parameter.
    export const GetStampMarketDataParamsSchema = z.object({
      stamp_id: z
        .union([z.number(), z.string()])
        .refine(
          (val) => {
            const num = typeof val === 'string' ? parseInt(val, 10) : val;
            return !isNaN(num) && num > 0;
          },
          {
            message: 'stamp_id must be a positive number',
          }
        )
        .transform((val) => {
          const num = typeof val === 'string' ? parseInt(val, 10) : val;
          return num;
        }),
    });
    
    export type GetStampMarketDataParams = z.infer<typeof GetStampMarketDataParamsSchema>;
  • Registration of the GetStampMarketDataTool class in the stampTools object, making it available for export and use in tool registries.
    export const stampTools = {
      get_stamp: GetStampTool,
      search_stamps: SearchStampsTool,
      get_recent_stamps: GetRecentStampsTool,
      get_recent_sales: GetRecentSalesTool,
      get_market_data: GetMarketDataTool,
      get_stamp_market_data: GetStampMarketDataTool,
    };
  • API client helper method that fetches market data for a specific stamp from the Stampchain API endpoint /stamps/{stampId}/marketData, used by the tool handler.
    async getStampMarketData(stampId: number): Promise<StampMarketData> {
      const response = await this.client.get<{ data: StampMarketData }>(
        `/stamps/${stampId}/marketData`
      );
      return response.data.data;
    }
  • The tool name 'get_stamp_market_data' is listed in the getAvailableToolNames() function for tool discovery.
    'get_stamp_market_data',
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. It states the tool retrieves data (implying read-only) but doesn't disclose behavioral traits like authentication needs, rate limits, error conditions, or what 'detailed market data' includes (e.g., pricing, trends, availability). For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves beyond basic purpose.

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 states the core purpose and includes a version note. It's appropriately sized for a simple tool, with no wasted words. However, the version note 'v2.3 feature' could be considered slightly extraneous if not critical for usage, but it doesn't significantly detract from conciseness.

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?

Given no annotations, no output schema, and a simple input schema, the description is incomplete. It doesn't explain what 'detailed market data' returns, potential errors, or usage constraints. For a tool with siblings offering similar data, more context is needed to understand its role and output. The version note adds some context but doesn't compensate for missing behavioral and output details.

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 description adds no parameter semantics beyond what the schema provides. The input schema has 100% description coverage, with the single parameter 'stamp_id' documented as 'The ID of the stamp to get market data for'. The description doesn't elaborate on ID format, examples, or constraints. With high schema coverage, the baseline is 3, as the 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 verb ('retrieve') and resource ('detailed market data for a specific stamp'), making the purpose understandable. It distinguishes from siblings like 'get_market_data' (likely general) and 'get_stamp' (likely basic info) by specifying 'detailed market data' and 'specific stamp', though it doesn't explicitly contrast them. The version note 'v2.3 feature' adds context but doesn't affect core purpose clarity.

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 siblings like 'get_market_data' (possibly broader market data), 'get_stamp' (likely general stamp info), and 'get_recent_sales' (possibly sales-focused data), there's no indication of when this specific tool is appropriate. The version note implies it's for newer features but doesn't help choose between tools.

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