Skip to main content
Glama
0xReisearch

REI Crypto MCP Server

by 0xReisearch

get_price_percentage

Calculate percentage price changes for cryptocurrency tokens over specified time periods using chain and address identifiers.

Instructions

GET /coins/percentage/{coins}

Get percentage change in price over time.

Parameters:
    coins: comma-separated tokens in format {chain}:{address}
    timestamp: timestamp of data point (defaults to now)
    look_forward: whether to look forward from timestamp (default: False)
    period: duration between data points (default: '24h')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinsYes
timestampNo
look_forwardNo
periodNo24h

Implementation Reference

  • The handler function for the 'get_price_percentage' tool. Decorated with @mcp.tool() for registration. Calls DefiLlama API /coins/percentage/{coins} to get percentage change in price over a specified period.
    @mcp.tool()
    async def get_price_percentage(
        coins: str,
        timestamp: Optional[int] = None,
        look_forward: bool = False,
        period: str = "24h"
    ) -> str:
        """GET /coins/percentage/{coins}
        
        Get percentage change in price over time.
        
        Parameters:
            coins: comma-separated tokens in format {chain}:{address}
            timestamp: timestamp of data point (defaults to now)
            look_forward: whether to look forward from timestamp (default: False)
            period: duration between data points (default: '24h')
        """
        params = {
            'lookForward': str(look_forward).lower(),
            'period': period
        }
        if timestamp is not None:
            params['timestamp'] = timestamp
        result = await make_request('GET', f'/coins/percentage/{coins}', params)
        return str(result)
  • The @mcp.tool() decorator registers the get_price_percentage function as an MCP tool.
    @mcp.tool()
  • Shared helper function used by get_price_percentage to make HTTP requests to the DefiLlama API.
    async def make_request(method: str, endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any:
        """Make a request to the DefiLlama API."""
        try:
            response = await client.request(method, endpoint, params=params)
            response.raise_for_status()
            return response.json()
        except Exception as e:
            return f"Error: {str(e)}"

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/0xReisearch/crypto-mcp-beta'

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