Skip to main content
Glama

Close MT5 position / cancel pending order

close_mt5_order
Destructive

Close an open position (fully, or partially with volume) or cancel a pending order on the user's live MT5 account, by ticket. REAL MONEY: only call this after the user explicitly approved closing/cancelling the exact ticket. The tool auto-detects position vs pending order from the latest snapshot (CLOSE_POSITION / PARTIAL_CLOSE / CANCEL_ORDER). Confirm the result with get_my_mt5_account. Requires a personal SocialForex API token. Create one at /mt5 (section "Connect an AI assistant (MCP)") and add it to the MCP client as header Authorization: Bearer sfmcp_....

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "ticket": "<ticket>"
    },
    "name": "close_mt5_order"
  }
}

Input Schema

NameRequiredDescriptionDefault
ticketYesTicket of the position or pending order (from get_my_mt5_account)
volumeNoLots to close for a partial close; omit to close the whole position. Ignored for pending orders.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the destructive/openWorld annotations it discloses that this moves real money, that the operation type is auto-detected from the latest snapshot, the possible result codes (CLOSE_POSITION / PARTIAL_CLOSE / CANCEL_ORDER), and the exact auth requirement including header format and where to mint the token. That is substantial context the annotations cannot convey.

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?

Front-loaded with the action and scope, then the real-money caution, then detection/verification behavior, then auth setup. Dense but each clause carries operational weight; the auth setup sentence is the only part that could be moved to documentation.

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

Completeness5/5

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

For a 2-parameter destructive mutation with no output schema, the description covers preconditions, mutation semantics, result codes, and required credentials. Nothing an agent needs before calling it is missing.

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 100%, so the baseline is 3; the description earns a bump by adding that ticket type is inferred automatically and that partial closing is driven by `volume`. The parameter-level details themselves largely restate 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 and resource — close a position (fully or partially) or cancel a pending order on the live MT5 account, by ticket. It cleanly delimits itself from siblings like place_mt5_order and modify_mt5_order by covering only termination of an existing ticket.

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 hard precondition (only after the user explicitly approved closing/cancelling the exact ticket), explains auto-detection of position vs pending order, and points to get_my_mt5_account for verification. It stops short of naming a sibling to use instead when the user wants to change SL/TP rather than close.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.