Skip to main content
Glama
0xReisearch

REI Crypto MCP Server

by 0xReisearch

get_price_percentage

Calculate the percentage change in cryptocurrency prices over a specified period by providing token details and optional timestamp. Designed for tracking price trends without managing individual API keys.

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
look_forwardNo
periodNo24h
timestampNo

Implementation Reference

  • The handler function for the 'get_price_percentage' MCP tool. It is registered via the @mcp.tool() decorator and implements the logic to query the DefiLlama API for percentage price changes of specified coins over a given period, handling parameters like timestamp and look_forward direction.
    @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 function signature and docstring define the input schema/parameters for the tool, including types and descriptions matching the DefiLlama API requirements.
    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 this function as an MCP tool named 'get_price_percentage' with the FastMCP server.
    @mcp.tool()
  • Shared helper function used by the get_price_percentage tool (and all others) 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