Skip to content

Conversation

@phuihock
Copy link

Purpose

Add HTTP (Streamable) transport capability to the MetaTrader MCP server, enabling integration with HTTP-based MCP clients and tools (e.g., Open WebUI) alongside the existing stdio transport.

What's Changed

Main Feature: HTTP Transport

  • Added --transport http option to CLI for running the MCP server as an HTTP endpoint
  • Uses FastMCP's built-in Streamable HTTP support (MCP 2025-06-18 standard)
  • Configurable host and port (defaults: 127.0.0.1:8000)
  • Endpoint: POST /mcp for request/response handling
  • Maintains backward compatibility with --transport stdio (default)

Supporting Changes

Environment Variable Consolidation (side effect of adding transport option):

  • Unified all three interfaces to use consistent MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, MT5_PATH variables
  • Removed redundant environment variable assignments from CLI code
  • Simplified server.py by removing unused imports and main block

Testing

All three interfaces verified working with real MT5 credentials:

  • metatrader-mcp-server (stdio transport)
  • metatrader-mcp-server --transport http (HTTP transport)
  • metatrader-http-server (OpenAPI REST)

Breaking Changes

Environment variables renamed:

  • LOGINMT5_LOGIN
  • PASSWORDMT5_PASSWORD
  • SERVERMT5_SERVER
  • PATHMT5_PATH

Update your .env file or shell environment accordingly.

- Update app_lifespan to read from MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, MT5_PATH
- Consolidate on single source of truth for environment variables
- Remove unused imports (argparse, logging, load_dotenv)
- Remove __main__ block (replaced by cli.py)
- Remove redundant os.environ assignments (already handled by Click's envvar)
- Remove unused os import
- Click's envvar parameter reads from environment, no need to rewrite
- Environment variables available during server lifespan execution
…e CLI

- Update lifespan to read from MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, MT5_PATH
- Fix argparse usage (remove invalid envvar parameter)
- Add CLI arg precedence: CLI args override environment variables
- Fall back to environment variables when CLI args not provided
- Set resolved values to environment for lifespan handler access
- Change 'Option B: HTTP/SSE Transport' to 'Option B: HTTP Transport'
- Update command from --transport sse to --transport http
- Update endpoint from /sse to /mcp (Streamable HTTP standard)
- Remove deprecated SSE transport references
- Update security guidelines to focus on reverse proxy approach
- Remove duplicate/conflicting variable definitions
- Use MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, MT5_PATH as canonical variables
- Remove MCP_TRANSPORT and other unrelated variables
- Add clear comments for optional vs required settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant