Skip to main content
Glama
sammcj

Bybit MCP Server

by sammcj

get_instrument_info

Retrieve detailed information for a specific trading pair on Bybit, including symbol and instrument category, to facilitate informed trading decisions.

Instructions

Get detailed instrument information for a specific trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoCategory of the instrument (spot, linear, inverse)
symbolYesTrading pair symbol (e.g., 'BTCUSDT')

Implementation Reference

  • The main handler function that parses arguments, calls Bybit API's getInstrumentsInfo, formats the response based on category (spot/linear/inverse), and handles errors.
    async toolCall(request: z.infer<typeof CallToolRequestSchema>) {
      try {
        const args = request.params.arguments as unknown
        if (!args || typeof args !== 'object') {
          throw new Error("Invalid arguments")
        }
    
        const typedArgs = args as Record<string, unknown>
    
        if (!typedArgs.symbol || typeof typedArgs.symbol !== 'string') {
          throw new Error("Missing or invalid symbol parameter")
        }
    
        const symbol = typedArgs.symbol
        const category = (
          typedArgs.category &&
          typeof typedArgs.category === 'string' &&
          ["spot", "linear", "inverse"].includes(typedArgs.category)
        ) ? typedArgs.category as SupportedCategory
          : CONSTANTS.DEFAULT_CATEGORY as SupportedCategory
    
        const params: GetInstrumentsInfoParamsV5 = {
          category,
          symbol,
        }
    
        const response = await this.client.getInstrumentsInfo(params)
    
        if (response.retCode !== 0) {
          throw new Error(`Bybit API error: ${response.retMsg}`)
        }
    
        if (!response.result.list || response.result.list.length === 0) {
          throw new Error(`No instrument info found for symbol: ${symbol}`)
        }
    
        const info = response.result.list[0]
        let formattedInfo: any
    
        if (category === 'spot') {
          const spotInfo = info as SpotInstrumentInfoV5
          formattedInfo = {
            symbol: spotInfo.symbol,
            status: spotInfo.status,
            baseCoin: spotInfo.baseCoin,
            quoteCoin: spotInfo.quoteCoin,
            innovation: spotInfo.innovation === "1",
            marginTrading: spotInfo.marginTrading,
            lotSizeFilter: {
              basePrecision: spotInfo.lotSizeFilter.basePrecision,
              quotePrecision: spotInfo.lotSizeFilter.quotePrecision,
              minOrderQty: spotInfo.lotSizeFilter.minOrderQty,
              maxOrderQty: spotInfo.lotSizeFilter.maxOrderQty,
              minOrderAmt: spotInfo.lotSizeFilter.minOrderAmt,
              maxOrderAmt: spotInfo.lotSizeFilter.maxOrderAmt,
            },
            priceFilter: {
              tickSize: spotInfo.priceFilter.tickSize,
            },
          }
        } else {
          const futuresInfo = info as LinearInverseInstrumentInfoV5
          formattedInfo = {
            symbol: futuresInfo.symbol,
            status: futuresInfo.status,
            baseCoin: futuresInfo.baseCoin,
            quoteCoin: futuresInfo.quoteCoin,
            settleCoin: futuresInfo.settleCoin,
            contractType: futuresInfo.contractType,
            launchTime: futuresInfo.launchTime,
            deliveryTime: futuresInfo.deliveryTime,
            deliveryFeeRate: futuresInfo.deliveryFeeRate,
            priceFilter: {
              tickSize: futuresInfo.priceFilter.tickSize,
            },
            lotSizeFilter: {
              qtyStep: futuresInfo.lotSizeFilter.qtyStep,
              minOrderQty: futuresInfo.lotSizeFilter.minOrderQty,
              maxOrderQty: futuresInfo.lotSizeFilter.maxOrderQty,
            },
            leverageFilter: {
              minLeverage: futuresInfo.leverageFilter.minLeverage,
              maxLeverage: futuresInfo.leverageFilter.maxLeverage,
              leverageStep: futuresInfo.leverageFilter.leverageStep,
            },
            fundingInterval: futuresInfo.fundingInterval,
          }
        }
    
        // Add category and timestamp to the root level
        formattedInfo.category = category
        formattedInfo.retrievedAt = new Date().toISOString()
    
        return this.formatResponse(formattedInfo)
      } catch (error) {
        return this.handleError(error)
      }
    }
  • Tool definition including name, description, and input schema specifying required 'symbol' and optional 'category' enum.
    toolDefinition: Tool = {
      name: this.name,
      description: "Get detailed instrument information for a specific trading pair",
      inputSchema: {
        type: "object",
        properties: {
          symbol: {
            type: "string",
            description: "Trading pair symbol (e.g., 'BTCUSDT')",
          },
          category: {
            type: "string",
            description: "Category of the instrument (spot, linear, inverse)",
            enum: ["spot", "linear", "inverse"],
          },
        },
        required: ["symbol"],
      },
    };
  • Dynamically discovers, imports, instantiates, and validates tool classes (including GetInstrumentInfo) from the src/tools directory.
    export async function loadTools(): Promise<BaseToolImplementation[]> {
      try {
        const toolsPath = await findToolsPath()
        const files = await fs.readdir(toolsPath)
        const tools: BaseToolImplementation[] = []
    
        for (const file of files) {
          if (!isToolFile(file)) {
            continue
          }
    
          try {
            const modulePath = `file://${join(toolsPath, file)}`
            const { default: ToolClass } = await import(modulePath)
    
            if (!ToolClass || typeof ToolClass !== 'function') {
              console.warn(JSON.stringify({
                type: "warning",
                message: `Invalid tool class in ${file}`
              }))
              continue
            }
    
            const tool = new ToolClass()
    
            if (
              tool instanceof BaseToolImplementation &&
              tool.name &&
              tool.toolDefinition &&
              typeof tool.toolCall === "function"
            ) {
              tools.push(tool)
              console.info(JSON.stringify({
                type: "info",
                message: `Loaded tool: ${tool.name}`
              }))
            } else {
              console.warn(JSON.stringify({
                type: "warning",
                message: `Invalid tool implementation in ${file}`
              }))
            }
          } catch (error) {
            console.error(JSON.stringify({
              type: "error",
              message: `Error loading tool from ${file}: ${error instanceof Error ? error.message : String(error)}`
            }))
          }
        }
    
        return tools
      } catch (error) {
        console.error(JSON.stringify({
          type: "error",
          message: `Failed to load tools: ${error instanceof Error ? error.message : String(error)}`
        }))
        return []
      }
    }
  • src/index.ts:134-147 (registration)
    Initializes the toolsMap by loading all tools via toolLoader and logs the loaded tools including 'get_instrument_info', used by MCP ListTools and CallTool handlers.
    const tools = await loadTools()
    toolsMap = createToolsMap(tools)
    
    if (tools.length === 0) {
      console.log(JSON.stringify(formatJsonRpcMessage(
        "warning",
        "No tools were loaded. Server will start but may have limited functionality."
      )))
    } else {
      console.log(JSON.stringify(formatJsonRpcMessage(
        "info",
        `Loaded ${tools.length} tools: ${tools.map(t => t.name).join(", ")}`
      )))
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'gets' information, implying a read-only operation, but does not address critical aspects like authentication requirements, rate limits, error handling, or the format and depth of the returned information. This leaves significant gaps in understanding how the tool behaves in practice.

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 a single, focused sentence that directly states the tool's purpose without unnecessary words or fluff. It is front-loaded with the core action and resource, making it efficient and easy to parse, which is ideal for quick comprehension by an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficient for a tool that retrieves 'detailed instrument information'. It does not specify what details are included (e.g., specifications, fees, limits), how the information is structured, or any behavioral constraints. For a read operation with potential complexity, more context is needed to ensure the agent can use it effectively.

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?

The input schema has 100% description coverage, clearly documenting both parameters ('category' and 'symbol') with details like enum values for 'category'. The description does not add any meaningful semantic context beyond what the schema provides, such as explaining how 'symbol' relates to 'category' or providing usage examples. Thus, it meets the baseline for high schema coverage without enhancing parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get detailed instrument information') and the target resource ('for a specific trading pair'), which is specific and unambiguous. However, it does not explicitly differentiate from sibling tools like 'get_market_info' or 'get_ticker', which might also provide instrument-related data, leaving some ambiguity about its unique scope.

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?

The description provides no guidance on when to use this tool versus alternatives, such as sibling tools like 'get_market_info' or 'get_ticker'. It lacks context about prerequisites, exclusions, or specific use cases, offering only a basic statement of purpose without comparative or situational advice.

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

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/sammcj/bybit-mcp'

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