Skip to main content
Glama
alpaca-mcp-server

alpaca-mcp-server

Official
by alpacahq

close_all_positions

Closes all open long and short positions by placing a closing order for each, optionally canceling open orders first. Use it to flatten a portfolio and review each result for errors.

Instructions

Closes all open long and short positions by placing a closing order for each. Returns one result per position: check every result's status, because a position that could not be closed is reported as an error even when the call as a whole succeeds. If the market is closed, the closing orders remain queued and execute at the next market open.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "close_all_positions"
  }
}

Input Schema

NameRequiredDescriptionDefault
cancel_ordersNoIf true is specified, cancel all open orders before liquidating all positions.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.0.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does substantial work: it discloses partial-failure semantics (per-position results, individual errors even when the overall call succeeds), and off-hours queuing behavior at next market open. It does not address authorization scope, irreversibility, or whether crypto positions are included — the main remaining gaps for a destructive bulk operation.

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?

Three tight sentences, zero waste, and the core action is front-loaded before the failure-mode and market-hours caveats. Each sentence adds distinct operational information.

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?

An output schema exists, so return-value detail is not required, yet the description usefully explains the per-position result shape and that errors can be embedded in a successful call. For a destructive bulk tool with no annotations, slightly more on asset-class coverage and irreversibility would complete the picture.

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 100% and the single cancel_orders boolean is fully documented in-schema, so the baseline of 3 applies. The description adds nothing about the parameter, notably omitting when the cancel-then-liquidate ordering matters.

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 with explicit scope: 'Closes all open long and short positions by placing a closing order for each.' The word 'all' plus the long/short qualifier immediately distinguishes it from the singular sibling close_position, so an agent can route correctly without opening either schema.

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 only implied by the 'all' scope; the description never says when to prefer this over close_position, cancel_all_orders, or do_not_exercise_options_position, nor does it state preconditions such as having open positions. An agent must infer the mass-liquidation scenario rather than being told.

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

Deploy Server

Other Tools