Skip to main content
Glama
demwick

polymarket-trader-mcp

config.log_cycle

Record AI agent trading cycle metrics to database for tracking and analysis. Logs PnL, win rate, positions, budget usage, and notes after each automated cycle.

Instructions

Record an AI agent's trading cycle metrics to the database for dashboard tracking and performance analysis. Stores PnL, win rate, positions, budget usage, and notes. Call this after each automated trading cycle.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_nameYesName of the AI agent logging this cycle
strategyYesTrading strategy used in this cycle (e.g. 'copy_top_traders', 'stink_bids')
statusNoCycle outcome: ok=normal, warning=minor issue, risk_alert=needs attention, error=failedok
positions_openNoNumber of currently open positions
positions_closedNoNumber of positions closed this cycle
realized_pnlNoRealized profit/loss in USDC from closed positions
unrealized_pnlNoUnrealized profit/loss in USDC from open positions
win_rateNoWin rate as a decimal (0.0-1.0)
budget_usedNoAmount of daily budget spent in USDC
budget_limitNoTotal daily budget limit in USDC
actions_takenNoComma-separated list of actions taken (e.g. 'bought YES on Bitcoin market')
notesNoFree-text notes about this cycle

Implementation Reference

  • The handler function that executes the tool logic: inserts a cycle log into the agent_cycles table and returns a confirmation string.
    export function handleLogCycle(db: Database.Database, input: LogCycleInput): string {
      db.prepare(`
        INSERT INTO agent_cycles (agent_name, strategy, status, positions_open, positions_closed, realized_pnl, unrealized_pnl, win_rate, budget_used, budget_limit, actions_taken, notes)
        VALUES (@agent_name, @strategy, @status, @positions_open, @positions_closed, @realized_pnl, @unrealized_pnl, @win_rate, @budget_used, @budget_limit, @actions_taken, @notes)
      `).run(input);
    
      return `Cycle logged for ${input.agent_name}`;
    }
  • Zod schema defining the input validation for config.log_cycle: agent_name, strategy, status, positions_open, positions_closed, realized_pnl, unrealized_pnl, win_rate, budget_used, budget_limit, actions_taken, notes.
    export const logCycleSchema = z.object({
      agent_name: z.string().describe("Name of the AI agent logging this cycle"),
      strategy: z.string().describe("Trading strategy used in this cycle (e.g. 'copy_top_traders', 'stink_bids')"),
      status: z.enum(["ok", "warning", "risk_alert", "error"]).default("ok").describe("Cycle outcome: ok=normal, warning=minor issue, risk_alert=needs attention, error=failed"),
      positions_open: z.number().int().default(0).describe("Number of currently open positions"),
      positions_closed: z.number().int().default(0).describe("Number of positions closed this cycle"),
      realized_pnl: z.number().default(0).describe("Realized profit/loss in USDC from closed positions"),
      unrealized_pnl: z.number().default(0).describe("Unrealized profit/loss in USDC from open positions"),
      win_rate: z.number().default(0).describe("Win rate as a decimal (0.0-1.0)"),
      budget_used: z.number().default(0).describe("Amount of daily budget spent in USDC"),
      budget_limit: z.number().default(0).describe("Total daily budget limit in USDC"),
      actions_taken: z.string().optional().describe("Comma-separated list of actions taken (e.g. 'bought YES on Bitcoin market')"),
      notes: z.string().optional().describe("Free-text notes about this cycle"),
    });
  • src/index.ts:288-293 (registration)
    Registration of the tool via server.tool() with name 'config.log_cycle', description, schema, and handler wrapping handleLogCycle.
    server.tool(
      "config.log_cycle",
      "Record an AI agent's trading cycle metrics to the database for dashboard tracking and performance analysis. Stores PnL, win rate, positions, budget usage, and notes. Call this after each automated trading cycle.",
      logCycleSchema.shape,
      safe("agent.log_cycle", (input) => ({ content: [{ type: "text" as const, text: handleLogCycle(db, logCycleSchema.parse(input)) }] }))
    );
  • Database schema definition for the agent_cycles table that stores the logged cycle data.
    `CREATE TABLE IF NOT EXISTS agent_cycles (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      agent_name TEXT NOT NULL,
      strategy TEXT NOT NULL,
      status TEXT NOT NULL DEFAULT 'ok',
      positions_open INTEGER DEFAULT 0,
      positions_closed INTEGER DEFAULT 0,
      realized_pnl REAL DEFAULT 0,
      unrealized_pnl REAL DEFAULT 0,
      win_rate REAL DEFAULT 0,
      budget_used REAL DEFAULT 0,
      budget_limit REAL DEFAULT 0,
      actions_taken TEXT,
      notes TEXT,
      created_at TEXT DEFAULT (datetime('now'))
    )`,
Behavior3/5

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

With no annotations provided, the description must communicate behavioral traits. It states the tool records data to a database, implying a side effect. It does not detail whether it overwrites or appends, required permissions, or error handling. The instruction to call after each cycle suggests idempotency but isn't explicit. Adequate but not comprehensive.

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 sentences long with no unnecessary words. The first sentence states the purpose and data stored; the second provides usage timing. Every sentence adds value, making it highly efficient.

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 simple logging tool with no output schema, the description adequately covers purpose, when to use, and data stored. It lacks details on return values or side effects beyond recording, but given the tool's straightforward nature, this is sufficient.

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%, so baseline is 3. The description summarizes parameters as 'PnL, win rate, positions, budget usage, and notes', providing a high-level overview that complements the detailed schema. It does not add significant new meaning beyond the schema, but it helps identify the most important parameters.

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 'Record', the resource 'an AI agent's trading cycle metrics to the database', and the purpose 'for dashboard tracking and performance analysis'. It also lists key data stored (PnL, win rate, positions, etc.), effectively distinguishing it from sibling tools like config.dashboard or config.set which focus on configuration rather than logging.

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 explicitly states when to call the tool: 'Call this after each automated trading cycle.' This provides clear usage context. However, it does not mention when not to use it or suggest alternatives, which would improve the score further.

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