Skip to main content
Glama

fetch_balance

Retrieve current cryptocurrency trading account balance from the Freqtrade bot to monitor available funds and track portfolio value.

Instructions

Fetch the account balance.

Parameters: ctx (Context): MCP context object for logging and client access.

Returns: str: Stringified JSON response with account balance, or None if failed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'fetch_balance' MCP tool. Retrieves the Freqtrade REST client from the context and calls client.balance() to fetch account balance, returning the result as a stringified JSON response.
    @mcp.tool()
    def fetch_balance(ctx: Context) -> str:
        """
        Fetch the account balance.
        
        Parameters:
            ctx (Context): MCP context object for logging and client access.
        
        Returns:
            str: Stringified JSON response with account balance, or None if failed.
        """
        client: FtRestClient = ctx.request_context.lifespan_context["client"]
        return str(client.balance())
  • __main__.py:104-104 (registration)
    Registration decorator that registers the fetch_balance function as an MCP tool with the FastMCP server instance 'mcp'.
    @mcp.tool()
  • Helper utility function that provides version compatibility for the Freqtrade client by attempting to call methods from a list of possible method names, supporting multiple freqtrade-client library versions.
    def _call_client_method(client: FtRestClient, method_names: List[str], *args, **kwargs):
        """Call first matching client method to support multiple freqtrade-client versions."""
        for method_name in method_names:
            method = getattr(client, method_name, None)
            if callable(method):
                return method(*args, **kwargs)
        raise AttributeError(f"No supported method found in {method_names}")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'or None if failed' which is useful error behavior disclosure, but doesn't describe authentication requirements, rate limits, whether this is real-time or cached data, what format the balance is returned in, or what might cause failure. For a financial data tool with zero annotation coverage, this leaves significant behavioral gaps.

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 appropriately concise with clear sections for purpose, parameters, and returns. The 'Fetch the account balance.' opening sentence is front-loaded and direct. The parameter and return documentation is organized but could be slightly more efficient by not documenting the implicit context parameter that's standard in MCP tools.

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?

For a financial balance tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'account balance' means in this context (trading balance, available balance, total equity?), doesn't specify currency or format, and provides minimal error handling information. The return format mention ('Stringified JSON response') is helpful but vague about the actual data structure.

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 the schema already fully documents the parameter situation. The description mentions 'ctx (Context): MCP context object for logging and client access' which adds some semantic context about the implicit context parameter, but this is somewhat redundant since MCP tools inherently have context. Baseline for 0 parameters with full schema coverage would be 4.

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

Purpose4/5

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

The description clearly states the verb 'fetch' and resource 'account balance', making the purpose immediately understandable. However, it doesn't differentiate this tool from its many siblings (like fetch_profit, fetch_performance, fetch_trades) that also fetch financial data, leaving some ambiguity about what specifically distinguishes this balance fetch operation.

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 about when to use this tool versus alternatives. With multiple fetch-related siblings (fetch_profit, fetch_performance, fetch_trades, etc.), there's no indication whether this should be used for general account status, real-time balances, or specific balance types. No prerequisites, timing, or exclusion criteria are 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/worlddebugger/freqtrade-mcp'

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