Skip to main content
Glama
yogendhra9

Zerodha Trading Bot

by yogendhra9

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}`);
      }
    }
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 states the tool 'shows' data, implying a read-only operation, but doesn't clarify aspects like whether it requires specific permissions, how it handles errors, or what the output format is. This leaves significant gaps for a tool that likely interacts with user data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence that efficiently conveys the core action and target. It's front-loaded with the main purpose and avoids unnecessary elaboration, making it appropriately concise for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral traits like authentication needs, error handling, or output structure, which are crucial for a tool that accesses user-specific data. This leaves the agent with insufficient context to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't add parameter details, as there are none to explain, which aligns with the baseline expectation for zero-parameter tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose ('shows the current portfolio') and specifies the target resource ('of the given user'), which is clear. However, it doesn't differentiate this tool from potential siblings like 'Buy-Stock' or 'Sell-Stock' beyond the basic verb 'shows', making it somewhat vague in distinguishing its specific role within the server's toolset.

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 prerequisites (e.g., user authentication), exclusions, or comparisons to other tools like 'Buy-Stock' or 'Sell-Stock', leaving the agent with no usage context beyond the basic purpose.

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

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