get-market-orders
Retrieve market orders for specific items or regions in EVE Online. Filter by buy, sell, or all orders to access real-time market data through the ESI API.
Instructions
Get market orders from a specific region
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_type | No | Type of orders to retrieve | all |
| region_id | Yes | Region ID to get market orders from | |
| type_id | No | Item type ID to filter orders |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"order_type": {
"default": "all",
"description": "Type of orders to retrieve",
"enum": [
"buy",
"sell",
"all"
],
"type": "string"
},
"region_id": {
"description": "Region ID to get market orders from",
"type": "number"
},
"type_id": {
"description": "Item type ID to filter orders",
"type": "number"
}
},
"required": [
"region_id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:298-321 (handler)The main handler function for the 'get-market-orders' tool. It constructs the ESI API endpoint for market orders in the specified region, optionally appends type_id filter, fetches the orders using makeESIRequest, filters by order_type (buy/sell/all), and returns the result as JSON text content.async ({ region_id, type_id, order_type }) => { let endpoint = `/markets/${region_id}/orders/`; if (type_id) { endpoint += `?type_id=${type_id}`; } const orders = await makeESIRequest<Array<MarketOrder>>(endpoint); const filteredOrders = orders.filter((order) => { if (order_type === "buy") return order.is_buy_order; if (order_type === "sell") return !order.is_buy_order; return true; }); return { content: [ { type: "text", text: JSON.stringify(filteredOrders, null, 2), }, ], }; } );
- src/index.ts:290-297 (schema)Zod input schema defining parameters for the tool: region_id (required number), type_id (optional number), order_type (enum ["buy","sell","all"] with default "all".{ region_id: z.number().describe("Region ID to get market orders from"), type_id: z.number().optional().describe("Item type ID to filter orders"), order_type: z .enum(["buy", "sell", "all"]) .default("all") .describe("Type of orders to retrieve"), },
- src/index.ts:287-321 (registration)Registration of the 'get-market-orders' tool on the MCP server, including name, description, input schema, and inline handler function.server.tool( "get-market-orders", "Get market orders from a specific region", { region_id: z.number().describe("Region ID to get market orders from"), type_id: z.number().optional().describe("Item type ID to filter orders"), order_type: z .enum(["buy", "sell", "all"]) .default("all") .describe("Type of orders to retrieve"), }, async ({ region_id, type_id, order_type }) => { let endpoint = `/markets/${region_id}/orders/`; if (type_id) { endpoint += `?type_id=${type_id}`; } const orders = await makeESIRequest<Array<MarketOrder>>(endpoint); const filteredOrders = orders.filter((order) => { if (order_type === "buy") return order.is_buy_order; if (order_type === "sell") return !order.is_buy_order; return true; }); return { content: [ { type: "text", text: JSON.stringify(filteredOrders, null, 2), }, ], }; } );
- src/index.ts:29-42 (schema)TypeScript interface defining the MarketOrder type used by the handler for typing the API response.interface MarketOrder { duration: number; is_buy_order: boolean; issued: string; location_id: number; min_volume: number; order_id: number; price: number; range: string; system_id: number; type_id: number; volume_remain: number; volume_total: number; }
- src/index.ts:222-256 (helper)Helper function used by the handler to make authenticated and rate-limited requests to the EVE ESI API.async function makeESIRequest<T>(endpoint: string, token?: string): Promise<T> { if (!checkRateLimit(endpoint)) { throw new Error("Rate limit exceeded. Please try again later."); } const headers: Record<string, string> = { "User-Agent": USER_AGENT, "Accept": "application/json", }; if (token) { headers["Authorization"] = `Bearer ${token}`; } const response = await fetch(`${ESI_BASE_URL}${endpoint}`, { headers }); updateRateLimit(endpoint, response.headers); if (!response.ok) { let errorMessage = `HTTP error! status: ${response.status}`; try { const errorData = await response.json() as ESIError; if (errorData.error) { errorMessage = `ESI Error: ${errorData.error}`; if (errorData.error_description) { errorMessage += ` - ${errorData.error_description}`; } } } catch { // エラーJSONのパースに失敗した場合は、デフォルトのエラーメッセージを使用 } throw new Error(errorMessage); } return response.json() as Promise<T>; }