Skip to main content
Glama

mql5-docs-mcp

CI

An MCP server that gives coding agents (Claude Code, Cursor, Claude Desktop) the real MQL5 function signatures and error-code meanings, so they stop writing MQL4 syntax or inventing functions when they build MetaTrader 5 EAs.

It runs locally over stdio with a prebuilt index. It makes no network calls at runtime and needs no API key.

Tools

Tool

What it does

Example

search_reference

Search built-in functions by name or section, up to 10 results

Copy, Trade Functions

get_signature

Exact signature(s), section and doc link for one function

CopyBuffer

explain_code

Trade server return codes and runtime errors, by number or constant

10016, 4014, TRADE_RETCODE_DONE

Example get_signature("CopyBuffer"):

CopyBuffer (Timeseries and Indicators Access)
int CopyBuffer(int indicator_handle, int buffer_num, int start_pos, int count, double buffer[])
int CopyBuffer(int indicator_handle, int buffer_num, datetime start_time, int count, double buffer[])
int CopyBuffer(int indicator_handle, int buffer_num, datetime start_time, datetime stop_time, double buffer[])
https://www.mql5.com/en/docs/series/copybuffer

Related MCP server: mt5-mcp

Status (v0.1)

The index covers all 517 functions in the official function index (name, section and doc link) and all 296 trade return codes and runtime errors. Exact signatures are indexed for 203 functions so far, because mql5.com rate-limited the indexer partway through. For the rest, get_signature returns the doc link. Running npm run build:index again resumes from .cache/ and fills in the gaps.

Install

Claude Code:

claude mcp add mql5-docs -- npx -y github:zafmy/mql5-docs-mcp

Any other MCP client (mcpServers config):

{ "mql5-docs": { "command": "npx", "args": ["-y", "github:zafmy/mql5-docs-mcp"] } }

Scope

Covered: MQL5 built-in functions from the official function index, trade server return codes and runtime error codes.

Not covered: Standard Library classes (CTrade and friends), backtesting, broker connections and compiling. The index stores names, signatures, sections and links only. For the full explanation, follow the link to mql5.com.

Develop

npm install
npm test               # builds and runs the tests against the bundled index
npx -y github:zafmy/mcp-smoke -- node dist/index.js   # smoke-tests the built server with mcp-smoke.json
npm run build:index    # re-scrapes the reference slowly (4 s/page), resumable via .cache/
npm run build:index:offline  # rebuilds data/ from .cache/ only, no network

License

MIT for the code. MQL5 and MetaTrader are trademarks of MetaQuotes Ltd.; this project is not affiliated with them. Signatures and code descriptions come from the official MQL5 reference.

Available Tools

3 tools
explain_codeA

Explain an MQL5 trade server return code (MqlTradeResult.retcode, e.g. 10016) or runtime error (GetLastError(), e.g. 4014) by number or constant name.

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYes

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It does disclose the input domain and the two accepted forms (number or constant name), which implies a read-only lookup with no side effects, but it never explicitly states that this is a non-mutating lookup nor describes the shape of the explanation returned. Adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that front-loads the action and the resource, then packs the accepted input forms and examples into the parenthetical. No filler or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter, no-output-schema lookup tool this is nearly complete: it defines the input domain, both accepted forms, and examples. The only omission is any statement about what the returned explanation contains, which the absence of an output schema leaves unstated.

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?

Schema coverage is 0%: the single 'code' parameter is only typed as integer-or-string with no description. The description compensates by explaining that the value is a return code or runtime error, that it can be given as a number (10016, 4014) or a constant name, which directly clarifies the anyOf integer/string union in the schema.

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

Purpose5/5

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

States a specific verb ('Explain') and a precisely bounded resource (MQL5 trade server return codes from MqlTradeResult.retcode and runtime errors from GetLastError()), with concrete example values. This is clearly distinguishable from the sibling tools search_reference and get_signature, which retrieve documentation or signatures rather than interpreting a code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the usage context well by naming the two sources of codes (MqlTradeResult.retcode, GetLastError()), so an agent can infer it should call this when it holds such a code. However, it gives no explicit when-to-use versus alternatives and no exclusions, so the guidance remains implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_signatureA

Get the exact MQL5 signature(s), section and official doc link for one function, e.g. CopyBuffer or OrderSend.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYes

TDQS

A3.5/5.0
Behavior3/5

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

No annotations exist, so the description carries the full burden. It discloses the return payload (signature, section, doc link), which is useful, but says nothing about behavior when a name is ambiguous, missing, or has multiple overloads/signatures despite the parenthetical '(s)' hinting at multiplicity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence, front-loaded with the core action and outcome, with the examples placed at the end where they add clarity without delaying comprehension. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-param read-only lookup with no output schema, the core is covered, but gaps remain around ambiguous lookups, multiple signatures, and not-found behavior — details an agent would want before invoking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% and the single 'name' parameter has no description, so the description is the only source of meaning — it compensates partially by giving examples ('CopyBuffer', 'OrderSend') that show the expected input form, but does not state whether the name must be exact, case-sensitive, or a full path.

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?

Clear specific verb ('Get') plus resource ('the exact MQL5 signature(s)') and even names the return payload (section and official doc link). It is distinguishable from sibling search_reference and explain_code by promising the exact signature rather than search results or narrative explanation, though it does not state that distinction explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the concrete examples ('CopyBuffer or OrderSend'), which signal this is a per-function lookup tool, but there is no explicit guidance on when to prefer this over search_reference or explain_code, or what to do for undocumented functions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_referenceA

Search the official MQL5 (MetaTrader 5) function reference by name or section. Returns up to 10 matches with signatures and doc links. Use before writing MQL5 calls to avoid MQL4 syntax or invented functions.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It does usefully disclose the result shape (up to 10 matches with signatures and doc links), but says nothing about read-only nature, auth/network requirements, or freshness of the reference data. Adequate but with clear gaps for a tool with zero annotation coverage.

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?

Three short sentences with no padding, and the core purpose is front-loaded before the return format and the usage cue. Efficient and easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and no annotations, the description steps in to describe the return values (matches, signatures, doc links) and the intended use case. It is nearly complete for a simple 2-parameter search tool, missing only the 'limit' parameter's explanation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It clarifies the 'query' parameter semantics ('by name or section') and implies the result cap ('up to 10 matches'), but never explains the 'limit' parameter's role or acceptable range beyond what the schema's min/max already enforce.

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?

States a specific verb+resource (search the official MQL5 function reference) and scopes it to lookup 'by name or section.' It does not explicitly distinguish itself from sibling tools like get_signature or explain_code, but the search-and-return-matches framing is clear enough for an agent to differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete when-to-use: 'Use before writing MQL5 calls to avoid MQL4 syntax or invented functions.' That's a clear triggering context, though it names no alternative tools or when-not-to-use conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observedexplain_code
    • First observedget_signature
    • First observedsearch_reference

TDQS

A3.7/5.0

Scored across 3 tools

Disambiguation4/5

search_reference and get_signature both target function lookups and could be confused at the margins, but the multi-match search vs. single exact-signature semantics are described clearly. explain_code is entirely distinct, targeting return codes and runtime errors.

Naming Consistency5/5

All three tools use a consistent snake_case verb_noun pattern (search_reference, get_signature, explain_code) with clear, predictable action verbs. No mixing of conventions or styles.

Tool Count4/5

Three focused tools is on the lean side but each earns its place covering search, lookup, and error decoding. Slightly thin for a documentation server that could also expose browsing or content retrieval.

Completeness3/5

Search, signature lookup, and error explanation are covered, but there is no way to retrieve full documentation text, code examples, or enumerate functions within a section. These gaps force agents to rely only on signatures and external links.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A local-first MCP server that bridges AI coding agents with MetaTrader 5 for inspection, market data, MQL5 development, compiling, Strategy Tester review, workspace sync, logs, audit trails, demo trading, and carefully gated live trading.
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    Enables LLM agents to compile, deploy, backtest, and analyze MetaTrader 4/5 MQL sources without touching the MetaTrader UI, leveraging the build pipeline.
    41
    MIT