listLighthousePortfolios
Retrieve detailed information on all Lighthouse portfolios, including total portfolio value, associated wallets, and their individual balances for comprehensive crypto portfolio analysis.
Instructions
List all Lighthouse portfolios, their total portfolio value, the wallets within each portfolio and their total value
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:60-95 (handler)Handler function that executes the listLighthousePortfolios tool. Fetches user portfolios, retrieves detailed data for each portfolio, calculates total portfolio value, formats the output listing each portfolio's name, total USD value, number of wallets, and wallet details.execute: async () => { const portfolios = await lighthouse.getUserData(); const porfolioData = await Promise.all( portfolios.user.portfolios.map(async (portfolio) => { return await lighthouse.getPortfolioData(portfolio.slug); }) ); //Sum the portfolios const totalPortfolioValue = porfolioData.reduce( (acc, data) => acc + data.usdValue, 0 ); /// Format the porfolio data const formattedPorfolioData = porfolioData.map((data, i) => { return `# ${i + 1}. ${ portfolios.user.portfolios[i].name }\n\n## Total Portfolio Value: $${data.usdValue.toLocaleString()}\n\n## Wallets (${ Object.keys(data.accounts).length }):\n${Object.entries(data.accounts) .map(([accountId, account]) => `- ${account.name} (${account.type})`) .join("\n")}`; }); return { content: [ { type: "text", text: `# Lighthouse Portfolios\n\n${formattedPorfolioData.join( "\n" )}\n\n## Total Portfolio Value: $${totalPortfolioValue.toLocaleString()}`, }, ], }; },
- index.ts:59-59 (schema)Zod schema for tool parameters: no parameters required.parameters: z.object({}),
- index.ts:55-96 (registration)Registration of the listLighthousePortfolios tool with FastMCP server, specifying name, description, schema, and handler.server.addTool({ name: "listLighthousePortfolios", description: "List all Lighthouse portfolios, their total portfolio value, the wallets within each portfolio and their total value", parameters: z.object({}), execute: async () => { const portfolios = await lighthouse.getUserData(); const porfolioData = await Promise.all( portfolios.user.portfolios.map(async (portfolio) => { return await lighthouse.getPortfolioData(portfolio.slug); }) ); //Sum the portfolios const totalPortfolioValue = porfolioData.reduce( (acc, data) => acc + data.usdValue, 0 ); /// Format the porfolio data const formattedPorfolioData = porfolioData.map((data, i) => { return `# ${i + 1}. ${ portfolios.user.portfolios[i].name }\n\n## Total Portfolio Value: $${data.usdValue.toLocaleString()}\n\n## Wallets (${ Object.keys(data.accounts).length }):\n${Object.entries(data.accounts) .map(([accountId, account]) => `- ${account.name} (${account.type})`) .join("\n")}`; }); return { content: [ { type: "text", text: `# Lighthouse Portfolios\n\n${formattedPorfolioData.join( "\n" )}\n\n## Total Portfolio Value: $${totalPortfolioValue.toLocaleString()}`, }, ], }; }, });