Skip to main content
Glama

Show-Portfolio

Display current investment holdings and positions for Zerodha trading accounts to monitor portfolio status and track performance.

Instructions

This tool shows the current portfolio of the given user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'Show-Portfolio' tool. It initializes the ZerodhaTrading instance and calls getAllHoldings() to retrieve and return the portfolio data.
    async () => { try { const trading = await initializeTrading(); const response = await trading.getAllHoldings(); return { content: [{ type: "text", text: String(response) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } }
  • index.js:97-109 (registration)
    Registers the 'Show-Portfolio' MCP tool with the server, including description and inline handler function.
    server.tool( "Show-Portfolio", "This tool shows the current portfolio of the given user", async () => { try { const trading = await initializeTrading(); const response = await trading.getAllHoldings(); return { content: [{ type: "text", text: String(response) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } );
  • Helper method in ZerodhaTrading class that fetches positions using KiteConnect API and formats the holdings information for display.
    async getAllHoldings() { try{ const holdings = await this.kc.getPositions(); let allHoldings = " "; for(const holdings of holdings) { allHoldings += `stock:{holding.tradingsymbol} qty:{holding.quantity} avg_price:{holding.average_price} current_price:{holding.last_price}` allHoldings += `\n` } return allHoldings; } catch(err) { throw new Error(`Error getting all holdings: ${err.message}`); } }

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/yogendhra9/ZerodhaMCP'

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