Skip to main content
Glama
kongyo2

eve-online-mcp

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

TableJSON Schema
NameRequiredDescriptionDefault
order_typeNoType of orders to retrieveall
region_idYesRegion ID to get market orders from
type_idNoItem type ID to filter orders

Implementation Reference

  • 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),
            },
          ],
        };
      }
    );
  • 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),
            },
          ],
        };
      }
    );
  • 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;
    }
  • 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>;
    }
Install Server

Other Tools

Related 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/kongyo2/eve-online-mcp'

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