Skip to main content
Glama

abort_backtest

Stop a running backtest in the Freqtrade trading bot to halt simulation and free resources for other tasks.

Instructions

Abort currently running backtest task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the abort_backtest tool. It retrieves the Freqtrade REST client from the context and calls the backtest/abort endpoint to abort a running backtest task.
    @mcp.tool()
    def abort_backtest(ctx: Context) -> str:
        """Abort currently running backtest task."""
        client: FtRestClient = ctx.request_context.lifespan_context["client"]
        return str(_client_get(client, "backtest/abort"))
  • __main__.py:385-389 (registration)
    The @mcp.tool() decorator registers the abort_backtest function as an MCP tool with the FastMCP server instance.
    @mcp.tool()
    def abort_backtest(ctx: Context) -> str:
        """Abort currently running backtest task."""
        client: FtRestClient = ctx.request_context.lifespan_context["client"]
        return str(_client_get(client, "backtest/abort"))
  • Helper utilities for calling Freqtrade REST client methods. _call_client_method provides version compatibility by trying multiple method names, and _client_get wraps it for HTTP GET requests.
    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}")
    
    
    def _client_get(client: FtRestClient, path: str, params: Dict[str, Any] | None = None):
        return _call_client_method(client, ["_get"], path, params=params)
  • Import of Context type from MCP FastMCP library, used for type annotation in the abort_backtest function signature to provide access to request context and lifespan-managed client.
    from mcp.server.fastmcp import FastMCP, Context

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