fix(tools): updated kalshi and polymarket tools to accurately reflect outputs (#2274)

This commit is contained in:
Waleed
2025-12-09 15:35:36 -08:00
committed by GitHub
parent cc66aa5a3e
commit 569598b39e
43 changed files with 351 additions and 801 deletions

View File

@@ -52,8 +52,8 @@ Retrieve a list of prediction markets from Kalshi with optional filtering
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Markets data and metadata |
| `markets` | array | Array of market objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_market`
@@ -69,8 +69,7 @@ Retrieve details of a specific prediction market by ticker
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Market data and metadata |
| `market` | object | Market object with details |
### `kalshi_get_events`
@@ -90,8 +89,8 @@ Retrieve a list of events from Kalshi with optional filtering
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Events data and metadata |
| `events` | array | Array of event objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_event`
@@ -108,8 +107,7 @@ Retrieve details of a specific event by ticker
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Event data and metadata |
| `event` | object | Event object with details |
### `kalshi_get_balance`
@@ -126,8 +124,10 @@ Retrieve your account balance and portfolio value from Kalshi
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Balance data and metadata |
| `balance` | number | Account balance in cents |
| `portfolioValue` | number | Portfolio value in cents |
| `balanceDollars` | number | Account balance in dollars |
| `portfolioValueDollars` | number | Portfolio value in dollars |
### `kalshi_get_positions`
@@ -149,8 +149,8 @@ Retrieve your open positions from Kalshi
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Positions data and metadata |
| `positions` | array | Array of position objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_orders`
@@ -172,8 +172,8 @@ Retrieve your orders from Kalshi with optional filtering
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Orders data and metadata |
| `orders` | array | Array of order objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_order`
@@ -191,8 +191,7 @@ Retrieve details of a specific order by ID from Kalshi
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Order data |
| `order` | object | Order object with details |
### `kalshi_get_orderbook`
@@ -208,8 +207,7 @@ Retrieve the orderbook (yes and no bids) for a specific market
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Orderbook data and metadata |
| `orderbook` | object | Orderbook with yes/no bids and asks |
### `kalshi_get_trades`
@@ -226,8 +224,8 @@ Retrieve recent trades across all markets
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Trades data and metadata |
| `trades` | array | Array of trade objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_candlesticks`
@@ -247,8 +245,7 @@ Retrieve OHLC candlestick data for a specific market
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Candlestick data and metadata |
| `candlesticks` | array | Array of OHLC candlestick data |
### `kalshi_get_fills`
@@ -271,8 +268,8 @@ Retrieve your portfolio
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Fills data and metadata |
| `fills` | array | Array of fill/trade objects |
| `paging` | object | Pagination cursor for fetching more results |
### `kalshi_get_series_by_ticker`
@@ -288,8 +285,7 @@ Retrieve details of a specific market series by ticker
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Series data and metadata |
| `series` | object | Series object with details |
### `kalshi_get_exchange_status`
@@ -304,8 +300,7 @@ Retrieve the current status of the Kalshi exchange (trading and exchange activit
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Exchange status data and metadata |
| `status` | object | Exchange status with trading_active and exchange_active flags |
### `kalshi_create_order`
@@ -339,8 +334,7 @@ Create a new order on a Kalshi prediction market
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Created order data |
| `order` | object | The created order object |
### `kalshi_cancel_order`
@@ -358,8 +352,8 @@ Cancel an existing order on Kalshi
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Canceled order data |
| `order` | object | The canceled order object |
| `reducedBy` | number | Number of contracts canceled |
### `kalshi_amend_order`
@@ -387,8 +381,7 @@ Modify the price or quantity of an existing order on Kalshi
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Amended order data |
| `order` | object | The amended order object |

View File

@@ -47,15 +47,14 @@ Retrieve a list of prediction markets from Polymarket with optional filtering
| `order` | string | No | Sort field \(e.g., volumeNum, liquidityNum, startDate, endDate, createdAt\) |
| `ascending` | string | No | Sort direction \(true for ascending, false for descending\) |
| `tagId` | string | No | Filter by tag ID |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Markets data and metadata |
| `markets` | array | Array of market objects |
### `polymarket_get_market`
@@ -72,8 +71,7 @@ Retrieve details of a specific prediction market by ID or slug
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Market data and metadata |
| `market` | object | Market object with details |
### `polymarket_get_events`
@@ -87,15 +85,14 @@ Retrieve a list of events from Polymarket with optional filtering
| `order` | string | No | Sort field \(e.g., volume, liquidity, startDate, endDate, createdAt\) |
| `ascending` | string | No | Sort direction \(true for ascending, false for descending\) |
| `tagId` | string | No | Filter by tag ID |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Events data and metadata |
| `events` | array | Array of event objects |
### `polymarket_get_event`
@@ -112,8 +109,7 @@ Retrieve details of a specific event by ID or slug
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Event data and metadata |
| `event` | object | Event object with details |
### `polymarket_get_tags`
@@ -123,15 +119,14 @@ Retrieve available tags for filtering markets from Polymarket
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Tags data and metadata |
| `tags` | array | Array of tag objects with id, label, and slug |
### `polymarket_search`
@@ -142,15 +137,14 @@ Search for markets, events, and profiles on Polymarket
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `query` | string | Yes | Search query term |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Search results and metadata |
| `results` | object | Search results containing markets, events, and profiles arrays |
### `polymarket_get_series`
@@ -160,15 +154,14 @@ Retrieve series (related market groups) from Polymarket
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Series data and metadata |
| `series` | array | Array of series objects |
### `polymarket_get_series_by_id`
@@ -184,8 +177,7 @@ Retrieve a specific series (related market group) by ID from Polymarket
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Series data and metadata |
| `series` | object | Series object with details |
### `polymarket_get_orderbook`
@@ -201,8 +193,7 @@ Retrieve the order book summary for a specific token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Orderbook data and metadata |
| `orderbook` | object | Order book with bids and asks arrays |
### `polymarket_get_price`
@@ -219,8 +210,7 @@ Retrieve the market price for a specific token and side
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Price data and metadata |
| `price` | string | Market price |
### `polymarket_get_midpoint`
@@ -236,8 +226,7 @@ Retrieve the midpoint price for a specific token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Midpoint price data and metadata |
| `midpoint` | string | Midpoint price |
### `polymarket_get_price_history`
@@ -257,8 +246,7 @@ Retrieve historical price data for a specific market token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Price history data and metadata |
| `history` | array | Array of price history entries with timestamp \(t\) and price \(p\) |
### `polymarket_get_last_trade_price`
@@ -274,8 +262,7 @@ Retrieve the last trade price for a specific token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Last trade price and metadata |
| `price` | string | Last trade price |
### `polymarket_get_spread`
@@ -291,8 +278,7 @@ Retrieve the bid-ask spread for a specific token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Spread data and metadata |
| `spread` | object | Bid-ask spread with bid and ask prices |
### `polymarket_get_tick_size`
@@ -308,8 +294,7 @@ Retrieve the minimum tick size for a specific token
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Tick size and metadata |
| `tickSize` | string | Minimum tick size |
### `polymarket_get_positions`
@@ -326,8 +311,7 @@ Retrieve user positions from Polymarket
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Positions data and metadata |
| `positions` | array | Array of position objects |
### `polymarket_get_trades`
@@ -339,15 +323,14 @@ Retrieve trade history from Polymarket
| --------- | ---- | -------- | ----------- |
| `user` | string | No | User wallet address to filter trades |
| `market` | string | No | Market ID to filter trades |
| `limit` | string | No | Number of results per page \(recommended: 25-50\) |
| `limit` | string | No | Number of results per page \(max 50\) |
| `offset` | string | No | Pagination offset \(skip this many results\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `output` | object | Trades data and metadata |
| `trades` | array | Array of trade objects |

View File

@@ -345,19 +345,30 @@ Delete an email template from SendGrid
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Operation success status |
| `message` | string | Status or success message |
| `messageId` | string | Email message ID \(send_mail\) |
| `to` | string | Recipient email address \(send_mail\) |
| `subject` | string | Email subject \(send_mail, create_template_version\) |
| `id` | string | Resource ID |
| `jobId` | string | Job ID for async operations |
| `email` | string | Email address |
| `firstName` | string | First name |
| `lastName` | string | Last name |
| `email` | string | Contact email address |
| `firstName` | string | Contact first name |
| `lastName` | string | Contact last name |
| `createdAt` | string | Creation timestamp |
| `updatedAt` | string | Last update timestamp |
| `listIds` | json | Array of list IDs the contact belongs to |
| `customFields` | json | Custom field values |
| `contacts` | json | Array of contacts |
| `contactCount` | number | Number of contacts |
| `lists` | json | Array of lists |
| `templates` | json | Array of templates |
| `message` | string | Status or success message |
| `name` | string | Resource name |
| `templates` | json | Array of templates |
| `generation` | string | Template generation |
| `versions` | json | Array of template versions |
| `templateId` | string | Template ID |
| `active` | boolean | Whether template version is active |
| `htmlContent` | string | HTML content |
| `plainContent` | string | Plain text content |
### `sendgrid_create_template_version`

View File

@@ -583,7 +583,29 @@ export const KalshiBlock: BlockConfig = {
status: { type: 'string', description: 'Filter by status' },
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: { type: 'json', description: 'Operation result data' },
// List operations
markets: { type: 'json', description: 'Array of market objects (get_markets)' },
events: { type: 'json', description: 'Array of event objects (get_events)' },
orders: { type: 'json', description: 'Array of order objects (get_orders)' },
positions: { type: 'json', description: 'Array of position objects (get_positions)' },
fills: { type: 'json', description: 'Array of fill objects (get_fills)' },
trades: { type: 'json', description: 'Array of trade objects (get_trades)' },
candlesticks: { type: 'json', description: 'Array of candlestick data (get_candlesticks)' },
// Single item operations
market: { type: 'json', description: 'Single market object (get_market)' },
event: { type: 'json', description: 'Single event object (get_event)' },
order: {
type: 'json',
description: 'Single order object (get_order, create_order, amend_order, cancel_order)',
},
series: { type: 'json', description: 'Series object (get_series_by_ticker)' },
// Account operations
balance: { type: 'number', description: 'Account balance in cents (get_balance)' },
// Orderbook
orderbook: { type: 'json', description: 'Orderbook data with bids/asks (get_orderbook)' },
// Exchange status
status: { type: 'json', description: 'Exchange status (get_exchange_status)' },
// Pagination
paging: { type: 'json', description: 'Pagination cursor for fetching more results' },
},
}

View File

@@ -242,7 +242,7 @@ export const PolymarketBlock: BlockConfig = {
id: 'limit',
title: 'Limit',
type: 'short-input',
placeholder: 'Number of results (recommended: 25-50)',
placeholder: 'Number of results (max 50)',
condition: {
field: 'operation',
value: ['get_markets', 'get_events', 'get_tags', 'search', 'get_series', 'get_trades'],
@@ -379,7 +379,30 @@ export const PolymarketBlock: BlockConfig = {
endTs: { type: 'number', description: 'End timestamp (Unix)' },
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: { type: 'json', description: 'Operation result data' },
// List operations
markets: { type: 'json', description: 'Array of market objects (get_markets)' },
events: { type: 'json', description: 'Array of event objects (get_events)' },
tags: { type: 'json', description: 'Array of tag objects (get_tags)' },
series: {
type: 'json',
description: 'Array or single series object (get_series, get_series_by_id)',
},
positions: { type: 'json', description: 'Array of position objects (get_positions)' },
trades: { type: 'json', description: 'Array of trade objects (get_trades)' },
// Single item operations
market: { type: 'json', description: 'Single market object (get_market)' },
event: { type: 'json', description: 'Single event object (get_event)' },
// Search
results: {
type: 'json',
description: 'Search results with markets, events, profiles (search)',
},
// CLOB operations
orderbook: { type: 'json', description: 'Order book with bids and asks (get_orderbook)' },
price: { type: 'string', description: 'Market price (get_price, get_last_trade_price)' },
midpoint: { type: 'string', description: 'Midpoint price (get_midpoint)' },
history: { type: 'json', description: 'Price history entries (get_price_history)' },
spread: { type: 'json', description: 'Bid-ask spread (get_spread)' },
tickSize: { type: 'string', description: 'Minimum tick size (get_tick_size)' },
},
}

View File

@@ -460,19 +460,36 @@ export const SendGridBlock: BlockConfig<SendMailResult> = {
},
outputs: {
// Common
success: { type: 'boolean', description: 'Operation success status' },
message: { type: 'string', description: 'Status or success message' },
// Send mail outputs
messageId: { type: 'string', description: 'Email message ID (send_mail)' },
to: { type: 'string', description: 'Recipient email address (send_mail)' },
subject: { type: 'string', description: 'Email subject (send_mail, create_template_version)' },
// Contact outputs
id: { type: 'string', description: 'Resource ID' },
jobId: { type: 'string', description: 'Job ID for async operations' },
email: { type: 'string', description: 'Email address' },
firstName: { type: 'string', description: 'First name' },
lastName: { type: 'string', description: 'Last name' },
email: { type: 'string', description: 'Contact email address' },
firstName: { type: 'string', description: 'Contact first name' },
lastName: { type: 'string', description: 'Contact last name' },
createdAt: { type: 'string', description: 'Creation timestamp' },
updatedAt: { type: 'string', description: 'Last update timestamp' },
listIds: { type: 'json', description: 'Array of list IDs the contact belongs to' },
customFields: { type: 'json', description: 'Custom field values' },
contacts: { type: 'json', description: 'Array of contacts' },
contactCount: { type: 'number', description: 'Number of contacts' },
// List outputs
lists: { type: 'json', description: 'Array of lists' },
templates: { type: 'json', description: 'Array of templates' },
message: { type: 'string', description: 'Status or success message' },
name: { type: 'string', description: 'Resource name' },
// Template outputs
templates: { type: 'json', description: 'Array of templates' },
generation: { type: 'string', description: 'Template generation' },
versions: { type: 'json', description: 'Array of template versions' },
// Template version outputs
templateId: { type: 'string', description: 'Template ID' },
active: { type: 'boolean', description: 'Whether template version is active' },
htmlContent: { type: 'string', description: 'HTML content' },
plainContent: { type: 'string', description: 'Plain text content' },
},
}

View File

@@ -945,6 +945,7 @@ export const WordPressBlock: BlockConfig<WordPressResponse> = {
categories: { type: 'json', description: 'List of categories' },
// Tag outputs
tag: { type: 'json', description: 'Tag data' },
tags: { type: 'json', description: 'List of tags' },
// User outputs
user: { type: 'json', description: 'User data' },
users: { type: 'json', description: 'List of users' },

View File

@@ -540,33 +540,19 @@ export const ZoomBlock: BlockConfig<ZoomResponse> = {
deleteAction: { type: 'string', description: 'Delete action (trash or delete)' },
},
outputs: {
// Meeting outputs
meeting: { type: 'json', description: 'Meeting data' },
meetings: { type: 'json', description: 'List of meetings' },
// Specific meeting fields
id: { type: 'number', description: 'Meeting ID' },
uuid: { type: 'string', description: 'Meeting UUID' },
topic: { type: 'string', description: 'Meeting topic' },
join_url: { type: 'string', description: 'Join URL for participants' },
start_url: { type: 'string', description: 'Start URL for host' },
start_time: { type: 'string', description: 'Start time' },
duration: { type: 'number', description: 'Duration in minutes' },
timezone: { type: 'string', description: 'Timezone' },
password: { type: 'string', description: 'Meeting password' },
agenda: { type: 'string', description: 'Meeting agenda' },
settings: { type: 'json', description: 'Meeting settings' },
// Invitation
invitation: { type: 'string', description: 'Meeting invitation text' },
// Recording outputs
recording: { type: 'json', description: 'Recording data' },
recordings: { type: 'json', description: 'List of recordings' },
recording_files: { type: 'json', description: 'Recording files' },
share_url: { type: 'string', description: 'Share URL for recording' },
// Participant outputs
participants: { type: 'json', description: 'List of participants' },
// Pagination
pageInfo: { type: 'json', description: 'Pagination information' },
// Success indicator
success: { type: 'boolean', description: 'Operation success status' },
// Meeting outputs
meeting: { type: 'json', description: 'Meeting data (create_meeting, get_meeting)' },
meetings: { type: 'json', description: 'List of meetings (list_meetings)' },
// Invitation
invitation: { type: 'string', description: 'Meeting invitation text (get_meeting_invitation)' },
// Recording outputs
recording: { type: 'json', description: 'Recording data (get_meeting_recordings)' },
recordings: { type: 'json', description: 'List of recordings (list_recordings)' },
// Participant outputs
participants: { type: 'json', description: 'List of participants (list_past_participants)' },
// Pagination
pageInfo: { type: 'json', description: 'Pagination information' },
},
}

View File

@@ -20,10 +20,6 @@ export interface KalshiAmendOrderResponse {
success: boolean
output: {
order: KalshiOrder
metadata: {
operation: 'amend_order'
}
success: boolean
}
}
@@ -140,24 +136,14 @@ export const kalshiAmendOrderTool: ToolConfig<KalshiAmendOrderParams, KalshiAmen
success: true,
output: {
order: data.order,
metadata: {
operation: 'amend_order' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
order: {
type: 'object',
description: 'Amended order data',
properties: {
order: { type: 'object', description: 'The amended order object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'The amended order object',
},
},
}

View File

@@ -11,10 +11,6 @@ export interface KalshiCancelOrderResponse {
output: {
order: KalshiOrder
reducedBy: number
metadata: {
operation: 'cancel_order'
}
success: boolean
}
}
@@ -66,25 +62,18 @@ export const kalshiCancelOrderTool: ToolConfig<KalshiCancelOrderParams, KalshiCa
output: {
order: data.order,
reducedBy: data.reduced_by || 0,
metadata: {
operation: 'cancel_order' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
order: {
type: 'object',
description: 'Canceled order data',
properties: {
order: { type: 'object', description: 'The canceled order object' },
reducedBy: { type: 'number', description: 'Number of contracts canceled' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'The canceled order object',
},
reducedBy: {
type: 'number',
description: 'Number of contracts canceled',
},
},
}

View File

@@ -26,10 +26,6 @@ export interface KalshiCreateOrderResponse {
success: boolean
output: {
order: KalshiOrder
metadata: {
operation: 'create_order'
}
success: boolean
}
}
@@ -185,24 +181,14 @@ export const kalshiCreateOrderTool: ToolConfig<KalshiCreateOrderParams, KalshiCr
success: true,
output: {
order: data.order,
metadata: {
operation: 'create_order' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
order: {
type: 'object',
description: 'Created order data',
properties: {
order: { type: 'object', description: 'The created order object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'The created order object',
},
},
}

View File

@@ -11,10 +11,6 @@ export interface KalshiGetBalanceResponse {
portfolioValue?: number // In cents
balanceDollars: number // Converted to dollars
portfolioValueDollars?: number // Converted to dollars
metadata: {
operation: 'get_balance'
}
success: boolean
}
}
@@ -65,27 +61,14 @@ export const kalshiGetBalanceTool: ToolConfig<KalshiGetBalanceParams, KalshiGetB
portfolioValue,
balanceDollars: balance / 100,
portfolioValueDollars: portfolioValue ? portfolioValue / 100 : undefined,
metadata: {
operation: 'get_balance' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Balance data and metadata',
properties: {
balance: { type: 'number', description: 'Account balance in cents' },
portfolioValue: { type: 'number', description: 'Portfolio value in cents' },
balanceDollars: { type: 'number', description: 'Account balance in dollars' },
portfolioValueDollars: { type: 'number', description: 'Portfolio value in dollars' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
},
balance: { type: 'number', description: 'Account balance in cents' },
portfolioValue: { type: 'number', description: 'Portfolio value in cents' },
balanceDollars: { type: 'number', description: 'Account balance in dollars' },
portfolioValueDollars: { type: 'number', description: 'Portfolio value in dollars' },
},
}

View File

@@ -14,13 +14,6 @@ export interface KalshiGetCandlesticksResponse {
success: boolean
output: {
candlesticks: KalshiCandlestick[]
metadata: {
operation: 'get_candlesticks'
seriesTicker: string
ticker: string
totalReturned: number
}
success: boolean
}
}
@@ -93,27 +86,14 @@ export const kalshiGetCandlesticksTool: ToolConfig<
success: true,
output: {
candlesticks,
metadata: {
operation: 'get_candlesticks' as const,
seriesTicker: data.series_ticker || '',
ticker: data.ticker || '',
totalReturned: candlesticks.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Candlestick data and metadata',
properties: {
candlesticks: { type: 'array', description: 'Array of OHLC candlestick objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
candlesticks: {
type: 'array',
description: 'Array of OHLC candlestick data',
},
},
}

View File

@@ -11,10 +11,6 @@ export interface KalshiGetEventResponse {
success: boolean
output: {
event: KalshiEvent
metadata: {
operation: 'get_event'
}
success: boolean
}
}
@@ -64,24 +60,14 @@ export const kalshiGetEventTool: ToolConfig<KalshiGetEventParams, KalshiGetEvent
success: true,
output: {
event: data.event,
metadata: {
operation: 'get_event' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
event: {
type: 'object',
description: 'Event data and metadata',
properties: {
event: { type: 'object', description: 'Event object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Event object with details',
},
},
}

View File

@@ -13,11 +13,6 @@ export interface KalshiGetEventsResponse {
output: {
events: KalshiEvent[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_events'
totalReturned: number
}
success: boolean
}
}
@@ -91,26 +86,18 @@ export const kalshiGetEventsTool: ToolConfig<KalshiGetEventsParams, KalshiGetEve
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_events' as const,
totalReturned: events.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
events: {
type: 'array',
description: 'Array of event objects',
},
paging: {
type: 'object',
description: 'Events data and metadata',
properties: {
events: { type: 'array', description: 'Array of event objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -7,11 +7,7 @@ export type KalshiGetExchangeStatusParams = Record<string, never>
export interface KalshiGetExchangeStatusResponse {
success: boolean
output: {
exchangeStatus: KalshiExchangeStatus
metadata: {
operation: 'get_exchange_status'
}
success: boolean
status: KalshiExchangeStatus
}
}
@@ -43,7 +39,7 @@ export const kalshiGetExchangeStatusTool: ToolConfig<
handleKalshiError(data, response.status, 'get_exchange_status')
}
const exchangeStatus = {
const status = {
trading_active: data.trading_active ?? false,
exchange_active: data.exchange_active ?? false,
}
@@ -51,25 +47,15 @@ export const kalshiGetExchangeStatusTool: ToolConfig<
return {
success: true,
output: {
exchangeStatus,
metadata: {
operation: 'get_exchange_status' as const,
},
success: true,
status,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
status: {
type: 'object',
description: 'Exchange status data and metadata',
properties: {
exchangeStatus: { type: 'object', description: 'Exchange status object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Exchange status with trading_active and exchange_active flags',
},
},
}

View File

@@ -19,11 +19,6 @@ export interface KalshiGetFillsResponse {
output: {
fills: KalshiFill[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_fills'
totalReturned: number
}
success: boolean
}
}
@@ -115,26 +110,18 @@ export const kalshiGetFillsTool: ToolConfig<KalshiGetFillsParams, KalshiGetFills
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_fills' as const,
totalReturned: fills.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
fills: {
type: 'array',
description: 'Array of fill/trade objects',
},
paging: {
type: 'object',
description: 'Fills data and metadata',
properties: {
fills: { type: 'array', description: 'Array of fill/trade objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -10,10 +10,6 @@ export interface KalshiGetMarketResponse {
success: boolean
output: {
market: KalshiMarket
metadata: {
operation: 'get_market'
}
success: boolean
}
}
@@ -50,24 +46,14 @@ export const kalshiGetMarketTool: ToolConfig<KalshiGetMarketParams, KalshiGetMar
success: true,
output: {
market: data.market,
metadata: {
operation: 'get_market' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
market: {
type: 'object',
description: 'Market data and metadata',
properties: {
market: { type: 'object', description: 'Market object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Market object with details',
},
},
}

View File

@@ -13,11 +13,6 @@ export interface KalshiGetMarketsResponse {
output: {
markets: KalshiMarket[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_markets'
totalReturned: number
}
success: boolean
}
}
@@ -90,26 +85,18 @@ export const kalshiGetMarketsTool: ToolConfig<KalshiGetMarketsParams, KalshiGetM
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_markets' as const,
totalReturned: markets.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
markets: {
type: 'array',
description: 'Array of market objects',
},
paging: {
type: 'object',
description: 'Markets data and metadata',
properties: {
markets: { type: 'array', description: 'Array of market objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -10,10 +10,6 @@ export interface KalshiGetOrderResponse {
success: boolean
output: {
order: KalshiOrder
metadata: {
operation: 'get_order'
}
success: boolean
}
}
@@ -63,24 +59,14 @@ export const kalshiGetOrderTool: ToolConfig<KalshiGetOrderParams, KalshiGetOrder
success: true,
output: {
order: data.order,
metadata: {
operation: 'get_order' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
order: {
type: 'object',
description: 'Order data',
properties: {
order: { type: 'object', description: 'The order object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Order object with details',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface KalshiGetOrderbookResponse {
success: boolean
output: {
orderbook: KalshiOrderbook
metadata: {
operation: 'get_orderbook'
ticker: string
}
success: boolean
}
}
@@ -56,25 +51,14 @@ export const kalshiGetOrderbookTool: ToolConfig<
success: true,
output: {
orderbook,
metadata: {
operation: 'get_orderbook' as const,
ticker: data.ticker || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
orderbook: {
type: 'object',
description: 'Orderbook data and metadata',
properties: {
orderbook: { type: 'object', description: 'Orderbook with yes/no bids and asks' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Orderbook with yes/no bids and asks',
},
},
}

View File

@@ -18,11 +18,6 @@ export interface KalshiGetOrdersResponse {
output: {
orders: KalshiOrder[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_orders'
totalReturned: number
}
success: boolean
}
}
@@ -108,26 +103,18 @@ export const kalshiGetOrdersTool: ToolConfig<KalshiGetOrdersParams, KalshiGetOrd
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_orders' as const,
totalReturned: orders.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
orders: {
type: 'array',
description: 'Array of order objects',
},
paging: {
type: 'object',
description: 'Orders data and metadata',
properties: {
orders: { type: 'array', description: 'Array of order objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -18,11 +18,6 @@ export interface KalshiGetPositionsResponse {
output: {
positions: KalshiPosition[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_positions'
totalReturned: number
}
success: boolean
}
}
@@ -111,26 +106,18 @@ export const kalshiGetPositionsTool: ToolConfig<
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_positions' as const,
totalReturned: positions.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
positions: {
type: 'array',
description: 'Array of position objects',
},
paging: {
type: 'object',
description: 'Positions data and metadata',
properties: {
positions: { type: 'array', description: 'Array of position objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface KalshiGetSeriesByTickerResponse {
success: boolean
output: {
series: KalshiSeries
metadata: {
operation: 'get_series_by_ticker'
ticker: string
}
success: boolean
}
}
@@ -58,25 +53,14 @@ export const kalshiGetSeriesByTickerTool: ToolConfig<
success: true,
output: {
series,
metadata: {
operation: 'get_series_by_ticker' as const,
ticker: series.ticker || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
series: {
type: 'object',
description: 'Series data and metadata',
properties: {
series: { type: 'object', description: 'Series object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Series object with details',
},
},
}

View File

@@ -9,11 +9,6 @@ export interface KalshiGetTradesResponse {
output: {
trades: KalshiTrade[]
paging?: KalshiPagingInfo
metadata: {
operation: 'get_trades'
totalReturned: number
}
success: boolean
}
}
@@ -68,26 +63,18 @@ export const kalshiGetTradesTool: ToolConfig<KalshiGetTradesParams, KalshiGetTra
paging: {
cursor: data.cursor || null,
},
metadata: {
operation: 'get_trades' as const,
totalReturned: trades.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
trades: {
type: 'array',
description: 'Array of trade objects',
},
paging: {
type: 'object',
description: 'Trades data and metadata',
properties: {
trades: { type: 'array', description: 'Array of trade objects' },
paging: { type: 'object', description: 'Pagination information' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Pagination cursor for fetching more results',
},
},
}

View File

@@ -11,10 +11,6 @@ export interface PolymarketGetEventResponse {
success: boolean
output: {
event: PolymarketEvent
metadata: {
operation: 'get_event'
}
success: boolean
}
}
@@ -65,24 +61,14 @@ export const polymarketGetEventTool: ToolConfig<
success: true,
output: {
event: data,
metadata: {
operation: 'get_event' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
event: {
type: 'object',
description: 'Event data and metadata',
properties: {
event: { type: 'object', description: 'Event object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Event object with details',
},
},
}

View File

@@ -13,11 +13,6 @@ export interface PolymarketGetEventsResponse {
success: boolean
output: {
events: PolymarketEvent[]
metadata: {
operation: 'get_events'
totalReturned: number
}
success: boolean
}
}
@@ -54,7 +49,7 @@ export const polymarketGetEventsTool: ToolConfig<
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
@@ -70,12 +65,13 @@ export const polymarketGetEventsTool: ToolConfig<
if (params.order) queryParams.append('order', params.order)
if (params.ascending) queryParams.append('ascending', params.ascending)
if (params.tagId) queryParams.append('tag_id', params.tagId)
if (params.limit) queryParams.append('limit', params.limit)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildGammaUrl('/events')
return query ? `${url}?${query}` : url
return `${url}?${query}`
},
method: 'GET',
headers: () => ({
@@ -97,25 +93,14 @@ export const polymarketGetEventsTool: ToolConfig<
success: true,
output: {
events,
metadata: {
operation: 'get_events' as const,
totalReturned: events.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Events data and metadata',
properties: {
events: { type: 'array', description: 'Array of event objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
events: {
type: 'array',
description: 'Array of event objects',
},
},
}

View File

@@ -9,11 +9,6 @@ export interface PolymarketGetLastTradePriceResponse {
success: boolean
output: {
price: string
metadata: {
operation: 'get_last_trade_price'
tokenId: string
}
success: boolean
}
}
@@ -46,7 +41,7 @@ export const polymarketGetLastTradePriceTool: ToolConfig<
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -57,25 +52,14 @@ export const polymarketGetLastTradePriceTool: ToolConfig<
success: true,
output: {
price: typeof data === 'string' ? data : data.price || '',
metadata: {
operation: 'get_last_trade_price' as const,
tokenId: params?.tokenId || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Last trade price and metadata',
properties: {
price: { type: 'string', description: 'Last trade price' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
price: {
type: 'string',
description: 'Last trade price',
},
},
}

View File

@@ -11,10 +11,6 @@ export interface PolymarketGetMarketResponse {
success: boolean
output: {
market: PolymarketMarket
metadata: {
operation: 'get_market'
}
success: boolean
}
}
@@ -65,24 +61,14 @@ export const polymarketGetMarketTool: ToolConfig<
success: true,
output: {
market: data,
metadata: {
operation: 'get_market' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
market: {
type: 'object',
description: 'Market data and metadata',
properties: {
market: { type: 'object', description: 'Market object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Market object with details',
},
},
}

View File

@@ -13,11 +13,6 @@ export interface PolymarketGetMarketsResponse {
success: boolean
output: {
markets: PolymarketMarket[]
metadata: {
operation: 'get_markets'
totalReturned: number
}
success: boolean
}
}
@@ -54,7 +49,7 @@ export const polymarketGetMarketsTool: ToolConfig<
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
@@ -70,12 +65,13 @@ export const polymarketGetMarketsTool: ToolConfig<
if (params.order) queryParams.append('order', params.order)
if (params.ascending) queryParams.append('ascending', params.ascending)
if (params.tagId) queryParams.append('tag_id', params.tagId)
if (params.limit) queryParams.append('limit', params.limit)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildGammaUrl('/markets')
return query ? `${url}?${query}` : url
return `${url}?${query}`
},
method: 'GET',
headers: () => ({
@@ -97,25 +93,14 @@ export const polymarketGetMarketsTool: ToolConfig<
success: true,
output: {
markets,
metadata: {
operation: 'get_markets' as const,
totalReturned: markets.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Markets data and metadata',
properties: {
markets: { type: 'array', description: 'Array of market objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
markets: {
type: 'array',
description: 'Array of market objects',
},
},
}

View File

@@ -9,10 +9,6 @@ export interface PolymarketGetMidpointResponse {
success: boolean
output: {
midpoint: string
metadata: {
operation: 'get_midpoint'
}
success: boolean
}
}
@@ -56,24 +52,14 @@ export const polymarketGetMidpointTool: ToolConfig<
success: true,
output: {
midpoint: data.mid || data.midpoint || data,
metadata: {
operation: 'get_midpoint' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Midpoint price data and metadata',
properties: {
midpoint: { type: 'string', description: 'Midpoint price' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
midpoint: {
type: 'string',
description: 'Midpoint price',
},
},
}

View File

@@ -10,10 +10,6 @@ export interface PolymarketGetOrderbookResponse {
success: boolean
output: {
orderbook: PolymarketOrderBook
metadata: {
operation: 'get_orderbook'
}
success: boolean
}
}
@@ -57,24 +53,14 @@ export const polymarketGetOrderbookTool: ToolConfig<
success: true,
output: {
orderbook: data,
metadata: {
operation: 'get_orderbook' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
orderbook: {
type: 'object',
description: 'Orderbook data and metadata',
properties: {
orderbook: { type: 'object', description: 'Order book with bids and asks' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Order book with bids and asks arrays',
},
},
}

View File

@@ -11,12 +11,6 @@ export interface PolymarketGetPositionsResponse {
success: boolean
output: {
positions: PolymarketPosition[]
metadata: {
operation: 'get_positions'
user: string
totalReturned: number
}
success: boolean
}
}
@@ -56,7 +50,7 @@ export const polymarketGetPositionsTool: ToolConfig<
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -70,26 +64,14 @@ export const polymarketGetPositionsTool: ToolConfig<
success: true,
output: {
positions,
metadata: {
operation: 'get_positions' as const,
user: params?.user || '',
totalReturned: positions.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Positions data and metadata',
properties: {
positions: { type: 'array', description: 'Array of position objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
positions: {
type: 'array',
description: 'Array of position objects',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface PolymarketGetPriceResponse {
success: boolean
output: {
price: string
side: string
metadata: {
operation: 'get_price'
}
success: boolean
}
}
@@ -64,26 +59,14 @@ export const polymarketGetPriceTool: ToolConfig<
success: true,
output: {
price: data.price || data,
side: data.side || '',
metadata: {
operation: 'get_price' as const,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Price data and metadata',
properties: {
price: { type: 'string', description: 'Market price' },
side: { type: 'string', description: 'Order side' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
price: {
type: 'string',
description: 'Market price',
},
},
}

View File

@@ -3,22 +3,17 @@ import type { PolymarketPriceHistoryEntry } from './types'
import { buildClobUrl, handlePolymarketError } from './types'
export interface PolymarketGetPriceHistoryParams {
tokenId: string // The token ID (CLOB token ID from market)
interval?: string // Duration: 1m, 1h, 6h, 1d, 1w, max (mutually exclusive with startTs/endTs)
fidelity?: number // Data resolution in minutes
startTs?: number // Start timestamp (Unix seconds UTC)
endTs?: number // End timestamp (Unix seconds UTC)
tokenId: string
interval?: string
fidelity?: number
startTs?: number
endTs?: number
}
export interface PolymarketGetPriceHistoryResponse {
success: boolean
output: {
history: PolymarketPriceHistoryEntry[]
metadata: {
operation: 'get_price_history'
totalReturned: number
}
success: boolean
}
}
@@ -65,9 +60,12 @@ export const polymarketGetPriceHistoryTool: ToolConfig<
const queryParams = new URLSearchParams()
queryParams.append('market', params.tokenId)
if (params.interval) queryParams.append('interval', params.interval)
if (params.fidelity !== undefined) queryParams.append('fidelity', String(params.fidelity))
if (params.startTs !== undefined) queryParams.append('startTs', String(params.startTs))
if (params.endTs !== undefined) queryParams.append('endTs', String(params.endTs))
if (params.fidelity != null && !Number.isNaN(params.fidelity))
queryParams.append('fidelity', String(params.fidelity))
if (params.startTs != null && !Number.isNaN(params.startTs))
queryParams.append('startTs', String(params.startTs))
if (params.endTs != null && !Number.isNaN(params.endTs))
queryParams.append('endTs', String(params.endTs))
return `${buildClobUrl('/prices-history')}?${queryParams.toString()}`
},
method: 'GET',
@@ -83,32 +81,20 @@ export const polymarketGetPriceHistoryTool: ToolConfig<
handlePolymarketError(data, response.status, 'get_price_history')
}
// Response is typically { history: [...] } or just an array
const history = data.history || (Array.isArray(data) ? data : [])
return {
success: true,
output: {
history,
metadata: {
operation: 'get_price_history' as const,
totalReturned: history.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Price history data and metadata',
properties: {
history: { type: 'array', description: 'Array of price history entries' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
history: {
type: 'array',
description: 'Array of price history entries with timestamp (t) and price (p)',
},
},
}

View File

@@ -8,11 +8,6 @@ export interface PolymarketGetSeriesResponse {
success: boolean
output: {
series: PolymarketSeries[]
metadata: {
operation: 'get_series'
totalReturned: number
}
success: boolean
}
}
@@ -29,7 +24,7 @@ export const polymarketGetSeriesTool: ToolConfig<
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
@@ -41,12 +36,13 @@ export const polymarketGetSeriesTool: ToolConfig<
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.limit) queryParams.append('limit', params.limit)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildGammaUrl('/series')
return query ? `${url}?${query}` : url
return `${url}?${query}`
},
method: 'GET',
headers: () => ({
@@ -61,32 +57,44 @@ export const polymarketGetSeriesTool: ToolConfig<
handlePolymarketError(data, response.status, 'get_series')
}
// Response is an array of series
const series = Array.isArray(data) ? data : []
// Response is an array of series - each series can contain thousands of nested events
// Strip the events array to prevent browser crashes (use get_events to fetch events separately)
const series = Array.isArray(data)
? data.map((s: any) => ({
id: s.id,
ticker: s.ticker,
slug: s.slug,
title: s.title,
seriesType: s.seriesType,
recurrence: s.recurrence,
image: s.image,
icon: s.icon,
active: s.active,
closed: s.closed,
archived: s.archived,
featured: s.featured,
restricted: s.restricted,
createdAt: s.createdAt,
updatedAt: s.updatedAt,
volume: s.volume,
liquidity: s.liquidity,
commentCount: s.commentCount,
eventCount: s.events?.length || 0, // Include count instead of full array
}))
: []
return {
success: true,
output: {
series,
metadata: {
operation: 'get_series' as const,
totalReturned: series.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Series data and metadata',
properties: {
series: { type: 'array', description: 'Array of series objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
series: {
type: 'array',
description: 'Array of series objects',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface PolymarketGetSeriesByIdResponse {
success: boolean
output: {
series: PolymarketSeries
metadata: {
operation: 'get_series_by_id'
seriesId: string
}
success: boolean
}
}
@@ -43,7 +38,7 @@ export const polymarketGetSeriesByIdTool: ToolConfig<
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -54,25 +49,14 @@ export const polymarketGetSeriesByIdTool: ToolConfig<
success: true,
output: {
series: data,
metadata: {
operation: 'get_series_by_id' as const,
seriesId: params?.seriesId || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
series: {
type: 'object',
description: 'Series data and metadata',
properties: {
series: { type: 'object', description: 'Series object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Series object with details',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface PolymarketGetSpreadResponse {
success: boolean
output: {
spread: PolymarketSpread
metadata: {
operation: 'get_spread'
tokenId: string
}
success: boolean
}
}
@@ -47,7 +42,7 @@ export const polymarketGetSpreadTool: ToolConfig<
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -58,25 +53,14 @@ export const polymarketGetSpreadTool: ToolConfig<
success: true,
output: {
spread: data,
metadata: {
operation: 'get_spread' as const,
tokenId: params?.tokenId || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
spread: {
type: 'object',
description: 'Spread data and metadata',
properties: {
spread: { type: 'object', description: 'Bid-ask spread object' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Bid-ask spread with bid and ask prices',
},
},
}

View File

@@ -8,11 +8,6 @@ export interface PolymarketGetTagsResponse {
success: boolean
output: {
tags: PolymarketTag[]
metadata: {
operation: 'get_tags'
totalReturned: number
}
success: boolean
}
}
@@ -27,7 +22,7 @@ export const polymarketGetTagsTool: ToolConfig<PolymarketGetTagsParams, Polymark
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
@@ -39,12 +34,13 @@ export const polymarketGetTagsTool: ToolConfig<PolymarketGetTagsParams, Polymark
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.limit) queryParams.append('limit', params.limit)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildGammaUrl('/tags')
return query ? `${url}?${query}` : url
return `${url}?${query}`
},
method: 'GET',
headers: () => ({
@@ -66,25 +62,14 @@ export const polymarketGetTagsTool: ToolConfig<PolymarketGetTagsParams, Polymark
success: true,
output: {
tags,
metadata: {
operation: 'get_tags' as const,
totalReturned: tags.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Tags data and metadata',
properties: {
tags: { type: 'array', description: 'Array of tag objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
tags: {
type: 'array',
description: 'Array of tag objects with id, label, and slug',
},
},
}

View File

@@ -9,11 +9,6 @@ export interface PolymarketGetTickSizeResponse {
success: boolean
output: {
tickSize: string
metadata: {
operation: 'get_tick_size'
tokenId: string
}
success: boolean
}
}
@@ -46,7 +41,7 @@ export const polymarketGetTickSizeTool: ToolConfig<
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -61,25 +56,14 @@ export const polymarketGetTickSizeTool: ToolConfig<
success: true,
output: {
tickSize: String(tickSize),
metadata: {
operation: 'get_tick_size' as const,
tokenId: params?.tokenId || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Tick size and metadata',
properties: {
tickSize: { type: 'string', description: 'Minimum tick size' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
tickSize: {
type: 'string',
description: 'Minimum tick size',
},
},
}

View File

@@ -11,11 +11,6 @@ export interface PolymarketGetTradesResponse {
success: boolean
output: {
trades: PolymarketTrade[]
metadata: {
operation: 'get_trades'
totalReturned: number
}
success: boolean
}
}
@@ -42,7 +37,7 @@ export const polymarketGetTradesTool: ToolConfig<
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
@@ -56,12 +51,13 @@ export const polymarketGetTradesTool: ToolConfig<
const queryParams = new URLSearchParams()
if (params.user) queryParams.append('user', params.user)
if (params.market) queryParams.append('market', params.market)
if (params.limit) queryParams.append('limit', params.limit)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildDataUrl('/trades')
return query ? `${url}?${query}` : url
return `${url}?${query}`
},
method: 'GET',
headers: () => ({
@@ -83,25 +79,14 @@ export const polymarketGetTradesTool: ToolConfig<
success: true,
output: {
trades,
metadata: {
operation: 'get_trades' as const,
totalReturned: trades.length,
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Trades data and metadata',
properties: {
trades: { type: 'array', description: 'Array of trade objects' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
trades: {
type: 'array',
description: 'Array of trade objects',
},
},
}

View File

@@ -10,11 +10,6 @@ export interface PolymarketSearchResponse {
success: boolean
output: {
results: PolymarketSearchResult
metadata: {
operation: 'search'
query: string
}
success: boolean
}
}
@@ -33,20 +28,21 @@ export const polymarketSearchTool: ToolConfig<PolymarketSearchParams, Polymarket
limit: {
type: 'string',
required: false,
description: 'Number of results per page (recommended: 25-50)',
description: 'Number of results per page (max 50)',
},
offset: {
type: 'string',
required: false,
description: 'Pagination offset (skip this many results)',
description: 'Pagination offset',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
queryParams.append('query', params.query)
if (params.limit) queryParams.append('limit', params.limit)
queryParams.append('q', params.query)
// Default limit to 50 to prevent browser crashes from large data sets
queryParams.append('limit', params.limit || '50')
if (params.offset) queryParams.append('offset', params.offset)
return `${buildGammaUrl('/public-search')}?${queryParams.toString()}`
@@ -57,7 +53,7 @@ export const polymarketSearchTool: ToolConfig<PolymarketSearchParams, Polymarket
}),
},
transformResponse: async (response: Response, params) => {
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
@@ -75,25 +71,14 @@ export const polymarketSearchTool: ToolConfig<PolymarketSearchParams, Polymarket
success: true,
output: {
results,
metadata: {
operation: 'search' as const,
query: params?.query || '',
},
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
results: {
type: 'object',
description: 'Search results and metadata',
properties: {
results: { type: 'object', description: 'Search results (markets, events, profiles)' },
metadata: { type: 'object', description: 'Operation metadata' },
success: { type: 'boolean', description: 'Operation success' },
},
description: 'Search results containing markets, events, and profiles arrays',
},
},
}

View File

@@ -1,39 +1,30 @@
// Polymarket API Types and Helpers
// Base URLs for different Polymarket APIs
export const POLYMARKET_GAMMA_URL = 'https://gamma-api.polymarket.com'
export const POLYMARKET_CLOB_URL = 'https://clob.polymarket.com'
export const POLYMARKET_DATA_URL = 'https://data-api.polymarket.com'
// Helper to build Gamma API URL
export function buildGammaUrl(path: string): string {
return `${POLYMARKET_GAMMA_URL}${path}`
}
// Helper to build CLOB API URL
export function buildClobUrl(path: string): string {
return `${POLYMARKET_CLOB_URL}${path}`
}
// Helper to build Data API URL
export function buildDataUrl(path: string): string {
return `${POLYMARKET_DATA_URL}${path}`
}
// Common pagination parameters
export interface PolymarketPaginationParams {
limit?: string
offset?: string
}
// Paging info in responses
export interface PolymarketPagingInfo {
limit: number
offset: number
count: number
}
// Market structure
export interface PolymarketMarket {
id: string
question: string
@@ -73,7 +64,6 @@ export interface PolymarketMarket {
negRisk: boolean
}
// Event structure
export interface PolymarketEvent {
id: string
ticker: string
@@ -98,20 +88,17 @@ export interface PolymarketEvent {
markets: PolymarketMarket[]
}
// Tag structure
export interface PolymarketTag {
id: string
label: string
slug: string
}
// Order book entry
export interface PolymarketOrderBookEntry {
price: string
size: string
}
// Order book structure
export interface PolymarketOrderBook {
market: string
asset_id: string
@@ -121,42 +108,49 @@ export interface PolymarketOrderBook {
asks: PolymarketOrderBookEntry[]
}
// Price structure
export interface PolymarketPrice {
price: string
side: string
}
// Price history entry
export interface PolymarketPriceHistoryEntry {
t: number // timestamp
p: number // price
t: number
p: number
}
// Series structure
export interface PolymarketSeries {
id: string
title: string
ticker: string
slug: string
description: string
title: string
seriesType: string
recurrence: string
image: string
markets: PolymarketMarket[]
icon: string
active: boolean
closed: boolean
archived: boolean
featured: boolean
restricted: boolean
createdAt: string
updatedAt: string
volume: number
liquidity: number
commentCount: number
eventCount: number
}
// Search result structure
export interface PolymarketSearchResult {
markets: PolymarketMarket[]
events: PolymarketEvent[]
profiles: any[] // Profile structure not fully documented
profiles: any[]
}
// Spread structure
export interface PolymarketSpread {
bid: string
ask: string
}
// Position structure
export interface PolymarketPosition {
market: string
asset_id: string
@@ -164,7 +158,6 @@ export interface PolymarketPosition {
value: string
}
// Trade structure
export interface PolymarketTrade {
id: string
market: string
@@ -177,7 +170,6 @@ export interface PolymarketTrade {
taker: string
}
// Error handler for Polymarket API responses
export function handlePolymarketError(data: any, status: number, operation: string): never {
const errorMessage = data?.message || data?.error || `Unknown error during ${operation}`
throw new Error(`Polymarket API error (${status}): ${errorMessage}`)