Skip to main content
Glama
lordbasilaiassistant-sudo

base-price-oracle-mcp

get_volatility

Calculate price volatility from recent swap data on Base to assess token price stability and market risk.

Instructions

Calculate price volatility (standard deviation of returns) from recent swaps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address on Base
lookback_hoursNoHours to look back for swap data

Implementation Reference

  • The handler for the get_volatility MCP tool, which calculates price volatility based on swap history.
    async ({ token_address, lookback_hours }) => {
      try {
        const quoteAddress = WETH;
        const [tokenDecimals, quoteDecimals, tokenSymbol] = await Promise.all([
          getTokenDecimals(token_address),
          getTokenDecimals(quoteAddress),
          getTokenSymbol(token_address),
        ]);
    
        const pools = await findAllPools(token_address, quoteAddress);
        if (pools.length === 0) {
          return { content: [{ type: "text" as const, text: `No DEX pools found for ${token_address} on Base.` }] };
        }
    
        const bestPool = pools[0];
        // Base: ~2s blocks, so lookback_hours * 3600 / 2
        const lookbackBlocks = Math.min(Math.floor((lookback_hours * 3600) / 2), 50000);
        const swaps = await getSwapHistory(bestPool, tokenDecimals, quoteDecimals, lookbackBlocks);
    
        if (swaps.length < 3) {
          return {
            content: [{
              type: "text" as const,
              text: JSON.stringify({
                token: token_address,
                symbol: tokenSymbol,
                message: `Insufficient swap data (${swaps.length} swaps). Need at least 3 for volatility calculation.`,
              }, null, 2),
            }],
          };
        }
    
        const prices = swaps.map((s) => s.price);
        const returns = calculateReturns(prices);
        const vol = stddev(returns);
        const annualized = vol * Math.sqrt(365 * 24); // hourly returns annualized
  • src/index.ts:572-578 (registration)
    The registration of the get_volatility tool within the MCP server.
    server.tool(
      "get_volatility",
      "Calculate price volatility (standard deviation of returns) from recent swaps",
      {
        token_address: z.string().describe("Token contract address on Base"),
        lookback_hours: z.number().default(24).describe("Hours to look back for swap data"),
      },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'recent swaps' but doesn't specify data sources, rate limits, authentication needs, or error conditions. For a calculation tool with no annotation coverage, this leaves significant gaps in understanding how it behaves operationally.

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 front-loads the core purpose without unnecessary words. Every part of the sentence earns its place by specifying what is calculated and from what data.

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 the tool's moderate complexity (calculating volatility from swap data), lack of annotations, and no output schema, the description is minimally adequate. It states what the tool does but lacks details on behavior, output format, or error handling. This leaves the agent with gaps in understanding the full context of use.

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 both parameters thoroughly. The description adds minimal value beyond the schema by implying the parameters relate to 'recent swaps,' but it doesn't provide additional context like token address validation or lookback_hours constraints. Baseline 3 is appropriate when 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 tool's purpose: 'Calculate price volatility (standard deviation of returns) from recent swaps.' It specifies the verb ('calculate'), resource ('price volatility'), and method ('standard deviation of returns from recent swaps'). However, it doesn't explicitly differentiate from sibling tools like 'get_price_history' or 'get_market_summary' that might provide related metrics.

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 or contexts where volatility calculation is preferred over other metrics like price history or market summary. The agent must infer usage from the purpose alone.

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/lordbasilaiassistant-sudo/base-price-oracle-mcp'

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