MT5 build 6296 — Built-in MCP server returns HTTP 401 with Bearer authentication

Hello MetaQuotes team and MQL5 community,

I am experiencing persistent HTTP 401 Unauthorized responses from the built-in MetaTrader 5 MCP server.

Environment

  • MetaTrader 5 build: 6296
  • Operating system: Windows
  • Endpoint: http://127.0.0.1:22346/mcp
  • Intended MCP client: OpenAI Codex
  • Authentication: MT5-generated Bearer token

Verified observations

  • The internal MCP server is enabled and responds at the configured endpoint.
  • Codex configuration follows the documented http_headers format.
  • Updating the API key and restarting Codex did not resolve the issue.
  • Independent PowerShell/.NET MCP initialize requests also receive HTTP 401, with proxies and automatic redirects disabled.
  • A separate local loopback test confirmed that the HTTP client transmits the Authorization header exactly as configured.
  • Responses identify Server: MetaTrader5-MCP and include WWW-Authenticate: Bearer realm="MetaTrader5-MCP" .

These independent HTTP results indicate that the authentication failure is reproducible outside Codex. Similar symptoms were reported for earlier builds in this MQL5 forum discussion.

Could you confirm whether build 6296 has a known authentication issue involving generated MCP keys? Does the local server require anything beyond the documented Bearer header? Please advise on a verified remedy that preserves the existing terminal configuration.

No trading operations or security-lock changes were performed during diagnosis. Sanitized results can be provided; API keys and account credentials will not be shared.

Kind regards

Mehmet Cakar

MetaTrader 5 build 6140 - MCP internal server returns 401 Unauthorized with generated API key
MetaTrader 5 build 6140 - MCP internal server returns 401 Unauthorized with generated API key
  • 2026.08.24
  • www.mql5.com
Hello, I am seeing a reproducible MCP authentication issue in MetaTrader 5 build 6140...

Did you try (for the MCP) ?

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 build 6140 - MCP internal server returns 401 Unauthorized with generated API key

Alain Verleyen, 2026.10.19 14:16

  1. Delete the key (let it empty).
  2. Save (Ok button).
  3. Restart the terminal.
  4. Wait for the MQL5 account to be authorized
  5. The new API key will be downloaded automatically.