Skip to main content
Glama
Public.com MCP Server

Public.com MCP Server

Official
by PublicDotCom

cancel_and_replace_order

Destructive

Atomically cancel an existing equity, option, or crypto order and replace it with new parameters; the replacement is validated first and refused requests leave the original order intact.

Instructions

Atomically cancel an existing order and replace it with new parameters.

⚠️ This modifies an existing order. Before submitting, the server looks up the original order, preflights the replacement and refuses it if the preflight fails or breaks a configured limit; when the client supports it, the user is asked to confirm. A refused request comes back with "submitted": false and the original order is left as it was.

Supported for equity, option, and crypto quantity orders.

Args: order_id: UUID of the existing order to cancel and replace. order_type: MARKET, LIMIT, STOP, STOP_LIMIT, MARKET_ON_CLOSE or LIMIT_ON_CLOSE for the replacement. time_in_force: DAY or GTD. Default is DAY. quantity: New quantity for the replacement order. Mutually exclusive with amount. amount: New notional dollar amount for the replacement order. Mutually exclusive with quantity. limit_price: New limit price. Required for LIMIT, STOP_LIMIT and LIMIT_ON_CLOSE replacements. stop_price: New stop price (for STOP/STOP_LIMIT orders). expiration_time: Required when time_in_force is GTD. ISO 8601 format. account_id: Account ID. Optional if PUBLIC_COM_ACCOUNT_ID is set.

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": {
      "order_id": "<order_id>",
      "order_type": "<order_type>"
    },
    "name": "cancel_and_replace_order"
  }
}

Input Schema

NameRequiredDescriptionDefault
amountNo
order_idYes
quantityNo
account_idNo
order_typeYes
stop_priceNo
limit_priceNo
time_in_forceNoDAY
expiration_timeNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.1
    • addedInput schema / properties / amount
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Amount"
      +}
  2. First observedv0.3.1

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare destructive=true, not idempotent, open world, so the safety profile is known; the description adds genuinely new behavior: the server looks up the original order, preflights the replacement, refuses on limit breach, asks for user confirmation where supported, and leaves the original order untouched with "submitted": false on refusal. That is precisely the information an agent needs before firing a destructive replacement.

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?

The warning and refusal semantics are front-loaded, followed by a clean Args block. The Args list is long but every entry adds semantics missing from the schema; a sentence or two could still be tightened, but there is little waste.

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 nine-parameter destructive mutation with zero schema descriptions, the definition supplies everything the agent needs to call it correctly: preflight/refusal outcomes, asset-class scope, and per-parameter constraints. Return values need not be explained because an output schema exists.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden and does: it enumerates the order_type values (MARKET, LIMIT, STOP, STOP_LIMIT, MARKET_ON_CLOSE, LIMIT_ON_CLOSE), the time_in_force values and default, the quantity/amount exclusivity, which order types require limit_price or stop_price, ISO 8601 for expiration_time, and that account_id is optional when an env var is set. None of this appears in the bare 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?

The opening sentence states a specific compound verb and resource — atomically cancel an order and replace it with new parameters — which is exactly what distinguishes it from the plain cancel_order and place_order siblings. The scope line ('Supported for equity, option, and crypto quantity orders') further narrows the tool's domain.

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?

It gives clear context for when this tool applies (replacing rather than merely cancelling) and discloses the preflight/refusal flow the caller must anticipate, plus the mutual exclusivity of quantity vs amount and conditional requirements on limit_price and expiration_time. It stops short of explicitly naming alternatives, e.g. telling the agent to use cancel_order when no replacement is wanted or preflight_order to test beforehand.

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