Skip to main content
Glama
demwick

polymarket-trader-mcp

config.history

Retrieve past copy trades from the database with optional filters by trader address or status. Get trade details including entry price, P&L, and market info. Pro feature.

Instructions

Retrieve past copy trades from the database with optional filters by trader address or status. Returns trade details including entry price, P&L, and market info. Pro feature.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of trades to return
traderNoFilter by trader wallet address (0x...)
statusNoFilter by trade status: open, closed, or won

Implementation Reference

  • Main handler function for the config.history tool. Checks for Pro license, calls getTradeHistory DB query with optional filters (limit, trader, status), and formats results as a markdown table.
    export async function handleGetTradeHistory(db: Database.Database, input: TradeHistoryInput): Promise<string> {
      const isPro = await checkLicense();
      if (!isPro) {
        return requirePro("get_trade_history");
      }
    
      const trades = getTradeHistory(db, {
        limit: input.limit,
        trader: input.trader,
        status: input.status,
      });
    
      if (trades.length === 0) {
        return "No trades found.";
      }
    
      let output = `## Trade History (${trades.length})\n\n`;
      output += `| # | Time | Trader | Market | Price | Amount | Mode | Status |\n|---|------|--------|--------|-------|--------|------|--------|\n`;
    
      for (let i = 0; i < trades.length; i++) {
        const t = trades[i];
        const time = t.created_at?.split("T")[1]?.slice(0, 5) ?? "-";
        const addr = t.trader_address.slice(0, 6) + "..";
        output += `| ${i + 1} | ${time} | ${addr} | ${t.market_slug ?? "-"} | $${t.price.toFixed(2)} | $${t.amount.toFixed(2)} | ${t.mode} | ${t.status} |\n`;
      }
    
      return output;
    }
  • Zod schema for config.history input validation. Accepts optional limit (1-100, default 20), trader (wallet address), and status (open/closed/won) filters.
    export const tradeHistorySchema = z.object({
      limit: z.number().int().min(1).max(100).optional().default(20).describe("Maximum number of trades to return"),
      trader: z.string().optional().describe("Filter by trader wallet address (0x...)"),
      status: z.string().optional().describe("Filter by trade status: open, closed, or won"),
    });
  • src/index.ts:197-202 (registration)
    Registration of the 'config.history' tool on the MCP server with description, schema, and handler wired to safe('trades.history', ...).
    server.tool(
      "config.history",
      "Retrieve past copy trades from the database with optional filters by trader address or status. Returns trade details including entry price, P&L, and market info. Pro feature.",
      tradeHistorySchema.shape,
      safe("trades.history", async (input) => ({ content: [{ type: "text" as const, text: await handleGetTradeHistory(db, tradeHistorySchema.parse(input)) }] }))
    );
  • Database query helper that builds a parameterized SQL query to fetch trades with optional filters by trader address and status, ordered by creation time descending.
    export function getTradeHistory(db: Database.Database, opts: { limit?: number; trader?: string; status?: string }): TradeRecord[] {
      let sql = "SELECT * FROM trades WHERE 1=1";
      const params: Record<string, unknown> = {};
    
      if (opts.trader) {
        sql += " AND trader_address = @trader";
        params.trader = opts.trader;
      }
      if (opts.status) {
        sql += " AND status = @status";
        params.status = opts.status;
      }
      sql += " ORDER BY created_at DESC LIMIT @limit";
      params.limit = opts.limit ?? 50;
    
      return db.prepare(sql).all(params) as TradeRecord[];
    }
Behavior2/5

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

With no annotations, the description carries full burden. It implies a read operation but does not disclose authentication needs, rate limits, or any special behaviors like data staleness. The mention 'Pro feature' hints at access control but no details.

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 two concise sentences: first defines purpose and filters, second lists return details and feature note. No redundant or irrelevant 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?

Given no output schema, the description adequately informs about return content. It also notes the Pro feature. However, it lacks details on pagination or ordering, which could be expected for a history list.

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 100%, so baseline is 3. The description adds value by listing return fields (entry price, P&L, market info) beyond the schema's parameter descriptions, but does not compensate for missing output 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 description clearly states the verb 'retrieve', the resource 'past copy trades', and specifies optional filters and return details (entry price, P&L, market info). It is distinct from sibling tools like 'markets.price_history'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives, nor any conditions for not using it. The description only mentions optional filters without context on selection criteria.

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/demwick/polymarket-trader-mcp'

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