freqtrade-gateway-agent
Facilitate interaction between intelligent automation agents and live cryptocurrency trading infrastructure via the Freqtrade bot's exposed HTTP interface. Automate execution workflows and retrieve instantaneous market statistics.
Author

kukapay
Quick Info
Actions
Tags
Freqtrade-Gateway-Agent
An intermediary service layer that interfaces with the Freqtrade trading application utilizing its built-in Representational State Transfer (REST) Application Programming Interface (API), thereby facilitating smooth integration for sophisticated automated trading operations managed by AI entities.
Setup Procedure
Prerequisites
- Runtime Environment (Python 3.13 or newer): Mandatory installation of a compatible Python interpreter.
- Freqtrade Instance: A persistently operating Freqtrade deployment where the web service (REST API) functionality has been explicitly activated (refer to the official Freqtrade Documentation).
- Version Control (Git): Necessary for cloning the source repository structure.
Deployment Steps
-
Repository Acquisition: bash git clone https://github.com/kukapay/freqtrade-mcp.git cd freqtrade-mcp
-
Dependency Resolution: Using the standard package installer (
pip): bash pip install freqtrade-client mcp[cli]
Alternatively, employing the uv utility (optional optimization):
bash
uv add freqtrade-client "mcp[cli]"
-
Client Configuration File Modification:
In the relevant configuration scope, incorporate the following structure:
"mcpServers": { "freqtrade-mcp": { "command": "uv", "args": [ "--directory", "/your/path/to/freqtrade-mcp", "run", "main.py" ], "env": { "FREQTRADE_API_URL": "http://127.0.0.1:8080", "FREQTRADE_USERNAME": "your_username", "FREQTRADE_PASSWORD": "your_password" } } }
-
Freqtrade Service Configuration Adjustment:
Ensure the REST API endpoint is activated by modifying the primary Freqtrade configuration file, specifically enabling the
api_serverblock and setting its activation flag to true.Exemplary configuration snippet:
"api_server": { "enabled": true, "listen_ip_address": "127.0.0.1", "listen_port": 8080, "verbosity": "error", "enable_openapi": false, "jwt_secret_key": "somethingrandom", "CORS_origins": [], "username": "Freqtrader", "password": "SuperSecret1!", "ws_token": "sercet_Ws_t0ken"},
Consult the Freqtrade documentation for detailed API settings here.
Operational Use Cases
Exposed Functionalities (Tools)
The gateway exposes the following capabilities, mapped directly to Freqtrade's web interface endpoints, available as MCP operational units:
| Tool Name | Purpose | Input Arguments Required |
|---|---|---|
fetch_market_data |
Retrieve historical candlestick data for a symbol | pair: str, timeframe: str |
fetch_bot_status |
Query current open trade positions | None |
fetch_profit |
Obtain overall return summary | None |
fetch_balance |
Access current asset holdings | None |
fetch_performance |
Retrieve analytical trading metrics | None |
fetch_whitelist |
List permitted trading instruments | None |
fetch_blacklist |
List prohibited trading instruments | None |
fetch_trades |
Access finalized transaction records | None |
fetch_config |
View active system settings | None |
fetch_locks |
Retrieve active trade restrictions | None |
place_trade |
Submit a directional market order | pair: str, side: str, stake_amount: float |
start_bot |
Initiate the automated trading engine | None |
stop_bot |
Halt the automated trading engine | None |
reload_config |
Force an update to the running configuration | None |
add_blacklist |
Add a symbol to the exclusion list | pair: str |
delete_blacklist |
Remove a symbol from the exclusion list | pair: str |
delete_lock |
Clear a specific trade restriction | lock_id: int |
Sample Agent Directives
- Market Data Retrieval:
- "Provide the hourly Open, High, Low, Close, Volume data for BTC/USDT."
- "Examine the 5-minute chart series for ETH paired against BTC."
-
"Furnish the most recent OHLCV sequence for XRP/USDT across the sixty-minute interval."
-
Bot State Inquiry:
- "Report on the standing positions currently held by the system."
- "Are there any trades actively being managed at this moment?"
-
"Summarize the execution activity of the bot presently."
-
Financial Outcome Review:
- "What is the cumulative realized profit to date?"
- "Display the aggregated profit statistics for all operations."
-
"Show me the trading gains realized thus far."
-
Account Liquidity Check:
- "What are the current holdings in the associated account?"
- "How much deployable capital resides in the exchange wallet?"
-
"Detail the current balance status for the Freqtrade participant."
-
Performance Assessment:
- "How effective has the bot's performance been over the tracked period?"
- "What are the quantitative performance indicators for executed trades?"
-
"Present the statistical trading outcomes."
-
Permitted Pairs Listing:
- "Which trading instruments are currently designated as whitelisted?"
- "What assets is the trading mechanism authorized to interact with?"
-
"Enumerate the currently whitelisted asset pairings."
-
Restricted Pairs Listing:
- "Which trading pairs are currently subject to restriction?"
- "Identify all assets that are currently blocked from trading."
-
"Provide a catalog of blacklisted instruments."
-
Trade History Retrieval:
- "Display the chronological record of concluded transactions."
- "List every trade operation that has reached closure."
-
"Can you furnish an archive of historical trade events?"
-
System Settings Inspection:
- "What is the present configuration governing the bot's behavior?"
- "Display the operational parameters currently loaded."
-
"Detail the current setup parameters of the Freqtrade instance."
-
Trade Restriction Review:
- "Are there any extant trade reservation mechanisms active?"
- "What specific trading constraints are presently enforced?"
- "Output the inventory of active trading constraints."
-
Order Placement Command:
- "Execute a purchase order for 0.01 units of BTC/USDT immediately."
- "Submit a sell instruction for 0.05 units of ETH/USDT at the current market rate."
- "Initiate a buy transaction request targeting 0.1 XRP/USDT."
-
Engine Activation:
- "Initiate the trading automaton."
- "Commence operations for the Freqtrade component."
- "Set the bot into an active, trading state forthwith."
-
Engine Deactivation:
- "Halt the processes of the trading automaton."
- "Execute a controlled shutdown of the Freqtrade service."
- "Temporarily suspend all automated trading activities."
-
Configuration Refresh:
- "Apply the latest configuration file changes to the running service."
- "Update the bot's internal operational parameters."
- "Re-read and implement the Freqtrade operational settings."
-
Blacklist Addition:
- "Prohibit trading activity for the ETH/USDT pair."
- "Incorporate BTC/ETH into the list of prohibited assets."
- "Enforce a trading block on XRP/USDT."
-
Blacklist Removal:
- "Remove the ETH/USDT pairing from the restriction roster."
- "Lift the trading prohibition currently placed on BTC/ETH."
- "Deregister XRP/USDT from the list of blocked instruments."
-
Lock Elimination:
- "Disengage the trade lock identified by identifier 123."
- "Expunge the constraint associated with lock reference 45."
- "Release the trading constraint labeled as ID 7."
Licensing Information
This software project is distributed under the terms of the MIT License. Comprehensive details are available in the accompanying LICENSE file.
