Skip to main content
Glama

getLighthousePerformanceData

Retrieve performance metrics for a Lighthouse crypto portfolio by specifying a portfolio name and optional start date to analyze historical data securely.

Instructions

Get performance data for a Lighthouse portfolio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portfolioNoOptional portfolio name
startDateNoOptional start date. Formatted as YYYY-MM-DD

Implementation Reference

  • Handler function that executes the tool logic: resolves the portfolio slug, determines start date (default 30 days ago), fetches performance data via lighthouse client, and constructs a formatted markdown text response with timeframe, period return, asset type changes, top gainers, and top losers.
    execute: async (args) => {
      const portfolio = args.portfolio
        ? await lighthouse.findPortfolio(args.portfolio)
        : await lighthouse.findPortfolio();
    
      const startDate = args.startDate
        ? new Date(args.startDate)
        : new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
    
      const performanceData = await lighthouse.getPerformanceData(
        portfolio.slug,
        startDate.toISOString().split("T")[0]
      );
    
      return {
        content: [
          {
            type: "text",
            text: `# ${portfolio.name} Performance Data
            Timeframe: ${performanceData.startsAt} - ${performanceData.endsAt}
            Period Return: ${formatNumber(
              performanceData.usdValueChange
            )} (${formatPercentage(
              (performanceData.usdValueChange /
                performanceData.lastSnapshotUsdValue) *
                100
            )})
            ----
            Performance by asset type:
            ${performanceData.changeByType
              .sort((a, b) => b.diffUsdValue - a.diffUsdValue)
              .map((asset) => {
                return `- ${asset.type}: ${formatNumber(
                  asset.diffUsdValue
                )} (${formatPercentage(
                  asset.prevUsdValue / asset.currUsdValue
                )}%)`;
              })
              .join("\n")}
            ----
            Top 5 Gainers:
            ${performanceData.gainers
              .sort((a, b) => b.diffUsdValue - a.diffUsdValue)
              .slice(0, 5)
              .map((gainer) => {
                return `- ${gainer.symbol}: ${formatNumber(
                  gainer.diffUsdValue
                )} (${formatPercentage(
                  gainer.diffUsdValue / gainer.prevUsdValue
                )}%)`;
              })
              .join("\n")}
            ----
            Top 5 Losers:
            ${performanceData.losers
              .sort((a, b) => a.diffUsdValue - b.diffUsdValue)
              .slice(0, 5)
              .map((loser) => {
                return `- ${loser.symbol}: ${formatNumber(
                  loser.diffUsdValue
                )} (${formatPercentage(
                  loser.diffUsdValue / loser.prevUsdValue
                )}%)`;
              })
              .join("\n")}
            `,
          },
        ],
      };
    },
  • Zod schema for validating the tool's input parameters: optional portfolio name and optional start date (YYYY-MM-DD format).
    parameters: z.object({
      portfolio: z.string().optional().describe("Optional portfolio name"),
      startDate: z
        .string()
        .optional()
        .describe("Optional start date. Formatted as YYYY-MM-DD"),
    }),
  • index.ts:374-376 (registration)
    Registration of the getLighthousePerformanceData tool with FastMCP server, specifying name and description.
    server.addTool({
      name: "getLighthousePerformanceData",
      description: "Get performance data for a Lighthouse portfolio",
  • Helper method in the Lighthouse class that performs the actual API call to retrieve performance data for a given portfolio slug and start date from the Lighthouse API.
    public async getPerformanceData(
      portfolioSlug: string,
      startDate: string
    ): Promise<PortfolioPerformanceResponse> {
      const response = await this.fetcher(
        `https://lighthouse.one/v1/workspaces/${portfolioSlug}/performance?startsAt=${startDate}`
      );
    
      if (!response.ok) {
        throw new Error(`API request failed with status ${response.status}`);
      }
    
      return await response.json();
    }
  • TypeScript interface defining the expected structure of the performance data returned from the Lighthouse API, used for type safety.
    export interface PortfolioPerformanceResponse {
      startsAt: string;
      endsAt: string;
      presets: TimeRangePresets; // Reusing TimeRangePresets
      usdValueChange: number;
      lastSnapshotUsdValue: number;
      snapshots: Snapshot[]; // Reusing Snapshot
      gainers: GainerLoserItem[]; // Reusing GainerLoserItem
      losers: GainerLoserItem[]; // Reusing GainerLoserItem
      changeByType: ChangeByTypeItem[]; // Reusing ChangeByTypeItem
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/l3wi/mcp-lighthouse'

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