Skip to main content
Glama
VaishnaviK23

Trading MCP Server

by VaishnaviK23

portfolio

Calculate current stock holdings by analyzing trade history to show net shares for each symbol with positive balances.

Instructions

Show current portfolio holdings.

This tool calculates the net number of shares held for each stock symbol by summing all buy and sell trades in the trade history CSV.

Returns: A dictionary mapping stock symbols to their current number of held shares. Only symbols with a positive balance are included.

Example: portfolio() -> {"AAPL": 120, "GOOG": 60}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'portfolio' tool implementation. It uses the @mcp.tool() decorator for registration and calculates holdings from a global DataFrame 'df'.
    @mcp.tool()
    def portfolio() -> dict[str, int]:
        """Show current portfolio holdings.
    
        This tool calculates the net number of shares held for each stock symbol by
        summing all buy and sell trades in the trade history CSV.
    
        Returns:
            A dictionary mapping stock symbols to their current number of held shares.
            Only symbols with a positive balance are included.
    
        Example:
            portfolio() -> {"AAPL": 120, "GOOG": 60}
        """
        holdings = defaultdict(int)
        for _, row in df.iterrows():
            if row['type'] == 'Buy':
                holdings[row['symbol']] += row['shares']
            else:
                holdings[row['symbol']] -= row['shares']
        return {k: v for k, v in holdings.items() if v > 0}
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and effectively discloses key behaviors: it reads from a CSV trade history, performs net calculation logic, and filters out zero/negative balances ('Only symbols with a positive balance are included'). Missing minor details like error handling or caching behavior.

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

Conciseness5/5

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

Excellent structure with clear visual hierarchy: one-line summary, calculation explanation, return value specification, and concrete example. Every sentence provides unique value with no repetition of schema or annotation data.

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

Completeness5/5

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

For a simple state-retrieval tool with no parameters and an output schema present, the description is complete. It compensates for the unseen output schema by documenting the return format (dictionary mapping) and filtering behavior (positive balances only).

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 tool has zero parameters and the schema confirms this with 100% coverage. Per guidelines, zero-parameter tools receive a baseline of 4. The description reinforces this via the example call syntax 'portfolio()'.

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

Purpose5/5

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

The description opens with a clear verb-resource pair ('Show current portfolio holdings') and immediately distinguishes from sibling tools by explaining it calculates net positions from trade history data, contrasting with trade_history (raw transactions) and financial calculation tools like pnl.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains the calculation methodology (summing buy/sell trades from CSV), which implicitly signals when to use this versus viewing raw trade history. However, it lacks explicit 'when not to use' guidance or named alternatives.

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/VaishnaviK23/Trading-MCP-Server'

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