Skip to main content
Glama
kwonsw812

kiwoom-mcp

by kwonsw812

cancel_order

Destructive

Cancel pending stock orders in Kiwoom Securities accounts using original order numbers. Specify quantity or cancel all remaining shares by setting quantity to zero.

Instructions

원주문번호로 미체결 주문을 취소합니다. 수량을 0으로 입력하면 잔량 전부 취소

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
original_order_noYes취소할 원주문번호
stock_codeYes종목코드 (예: 005930)
quantityYes취소 수량 (0 입력시 잔량 전부 취소)
account_noNo계좌번호 (미입력시 기본 계좌 사용)

Implementation Reference

  • The MCP tool handler for 'cancel_order', which extracts input parameters and calls the client's cancelOrder method.
    async ({ original_order_no, stock_code, quantity, account_no }) => {
      try {
        const acct = resolveAccountNo(account_no);
        const data = await client.cancelOrder(acct, original_order_no, stock_code, quantity);
        let text = `## 주문 취소 완료\n\n`;
        text += `- 취소 주문번호: ${data.ord_no ?? "N/A"}\n`;
        text += `- 원주문번호: ${original_order_no}\n`;
        text += `- 종목코드: ${stock_code}\n`;
        text += `- 취소수량: ${data.cncl_qty ?? quantity}주\n`;
        return textContent(text);
      } catch (error) {
        return errorContent(formatError(error));
      }
    }
  • src/index.ts:732-741 (registration)
    Registration of the 'cancel_order' MCP tool with its schema definition.
    server.tool(
      "cancel_order",
      "원주문번호로 미체결 주문을 취소합니다. 수량을 0으로 입력하면 잔량 전부 취소",
      {
        original_order_no: z.string().describe("취소할 원주문번호"),
        stock_code: stockCodeSchema,
        quantity: z.number().int().min(0).describe("취소 수량 (0 입력시 잔량 전부 취소)"),
        account_no: accountNoSchema,
      },
      { readOnlyHint: false, idempotentHint: false, destructiveHint: true },
  • The underlying API client method that performs the network request for cancelling an order.
    async cancelOrder(accountNo: string, origOrdNo: string, stockCode: string, quantity: number) {
      return this.request("/api/dostk/ordr", "kt10003", {
        acc_no: accountNo,
        dmst_stex_tp: "KRX",
        orig_ord_no: origOrdNo,
        stk_cd: stockCode,
        cncl_qty: String(quantity),
      });
    }
Behavior4/5

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

The description adds valuable behavioral context beyond what annotations provide. While annotations already indicate this is a destructive, non-idempotent write operation, the description explains the special case for quantity parameter ('수량을 0으로 입력하면 잔량 전부 취소' - entering 0 cancels all remaining quantity), which is crucial operational knowledge not captured in the structured annotations.

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?

The description is extremely concise with just two sentences that both earn their place. The first sentence states the core purpose, and the second provides crucial behavioral nuance about the quantity parameter. There's zero wasted language 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 destructive order cancellation tool with good annotations but no output schema, the description provides adequate context. It explains the core operation and the special quantity behavior. However, it doesn't mention potential side effects, error conditions, or what happens after successful cancellation, which would be helpful given the destructive nature.

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?

With 100% schema description coverage, the input schema already documents all parameters thoroughly. The description adds minimal additional semantics by reinforcing the quantity parameter's special behavior (0 = cancel all), but doesn't provide meaningful context beyond what's already in the schema descriptions.

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 description clearly states the specific action ('취소합니다' - cancels) and target resource ('미체결 주문' - unfilled orders) using the identifier '원주문번호' (original order number). It distinguishes itself from sibling tools like place_buy_order and place_sell_order by focusing on cancellation rather than order placement.

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?

The description provides clear context for when to use this tool ('미체결 주문을 취소합니다' - cancels unfilled orders), implying it should be used for pending orders rather than completed trades. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kwonsw812/kiwoom-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server