Skip to main content
Glama
VaishnaviK23

Trading MCP Server

by VaishnaviK23

validate_trades

Check trade history to ensure sell transactions do not exceed purchased share quantities, identifying any violations with specific error messages.

Instructions

Validate that no trades sell more shares than have been bought.

Parses the trade history sequentially to ensure all sell transactions occur only after a corresponding quantity of shares has been bought.

Returns: A list of error messages for invalid trades, if any.

Example: validate_trades() -> ["Invalid sell on 2024-02-10: 20 shares of AAPL (owned: 10)"]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The validate_trades function iterates through the trade history dataframe and checks if sell orders exceed the currently owned shares, returning a list of violations.
    def validate_trades() -> list[str]:
        """Validate that no trades sell more shares than have been bought.
    
        Parses the trade history sequentially to ensure all sell transactions
        occur only after a corresponding quantity of shares has been bought.
    
        Returns:
            A list of error messages for invalid trades, if any.
    
        Example:
            validate_trades() -> ["Invalid sell on 2024-02-10: 20 shares of AAPL (owned: 10)"]
        """
        errors = []
        balances = defaultdict(int)
        for idx, row in df.iterrows():
            if row['type'] == 'Buy':
                balances[row['symbol']] += row['shares']
            else:
                if balances[row['symbol']] < row['shares']:
                    errors.append(f"Invalid sell on {row['date']}: {row['shares']} shares of {row['symbol']} (owned: {balances[row['symbol']]})")
                balances[row['symbol']] -= row['shares']
        return errors
Behavior4/5

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

No annotations provided, so description carries full burden. It successfully discloses the sequential parsing behavior, the specific validation rule (sells only after corresponding buys), and the return format via both 'Returns:' section and concrete example. Could improve by stating it's read-only/safe.

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 front-loaded purpose statement followed by implementation details, explicit Returns section, and concrete example. No redundancy; every sentence adds value despite the multi-line format.

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 parameter-less validation tool, description is comprehensive. It explains the validation logic, output format (list of error messages), and provides an example return value, fully preparing the agent to interpret results despite the existence of an output schema.

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?

Zero parameters per schema (empty properties object). Per rubric, zero-parameter tools baseline at 4. Description correctly requires no parameter clarification.

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?

Description opens with specific verb ('Validate') and clear scope (preventing overselling). Explicitly distinguishes from sibling 'trade_history' by emphasizing it 'parses the trade history sequentially' to perform validation logic rather than just retrieving data.

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

Usage Guidelines3/5

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

Provides implied usage through explanation of the validation logic (checking sell-before-buy violations), but lacks explicit guidance on when to invoke versus alternatives like 'portfolio' or 'trade_history'. No 'when-not' or prerequisites mentioned.

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