Skip to main content
Glama

Show-Portfolio

Display the current portfolio of a user on the Zerodha Trading Bot, enabling real-time tracking of holdings and assets for informed decision-making in automated trading.

Instructions

This tool shows the current portfolio of the given user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.js:97-109 (registration)
    Registration of the "Show-Portfolio" MCP tool, which has no input parameters and delegates to ZerodhaTrading.getAllHoldings() via an initialized trading instance.
    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}` }] }; } } );
  • Core implementation that retrieves positions using KiteConnect.getPositions() and formats them into a string representing the portfolio.
    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}`); } }
  • Helper function to initialize the ZerodhaTrading instance with a valid access token, used by the Show-Portfolio handler.
    async function initializeTrading() { try { const accessToken = await tokenManager.getValidToken(); return new ZerodhaTrading(apiKey, accessToken); } catch (error) { console.error("Error initializing trading:", error.message); throw error; } }

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

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