Skip to main content
Glama
mbarinov

OKX MCP Server

by mbarinov

get_account_summary

Read-onlyIdempotent

Retrieve aggregated portfolio metrics from your OKX trading account to monitor performance and analyze holdings.

Instructions

Get aggregated portfolio metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_account_summary' tool. It invokes the OKX API client to fetch the account summary and returns it as formatted JSON text content, with error handling.
    export default async function get_account_summary({}: InferSchema<typeof schema>) {
      try {
        const accountSummary = await okxApiClient.getAccountSummary();
        return {
          content: [{ type: 'text', text: JSON.stringify(accountSummary, null, 2) }],
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : 'An unknown error occurred';
        return {
          content: [{ type: 'text', text: JSON.stringify({ error: message }, null, 2) }],
        };
      }
    }
  • The input schema for the tool, which is empty (no parameters expected).
    export const schema = {};
  • Metadata object defining the tool's name, description, and annotations, used for registration in the MCP server.
    export const metadata = {
      name: 'get_account_summary',
      description: 'Get aggregated portfolio metrics',
      annotations: {
        title: 'Get Account Summary',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
      },
    };
  • Helper method in OkxApiClient that aggregates portfolio value, allocation, open orders, and positions to compute the account summary.
    async getAccountSummary() {
      try {
        const portfolio = await this.getPortfolio();
        const openOrders = await this.getOpenOrders();
        const positions = await this.getPositions();
    
        const totalValueUsdt = portfolio.reduce(
          (acc, item) => acc + item.usdtValue,
          0
        );
        const allocation = portfolio.map((item) => ({
          currency: item.currency,
          allocation: item.usdtValue / totalValueUsdt,
        }));
    
        return {
          totalPortfolioValueUSDT: totalValueUsdt,
          allocationByAsset: allocation,
          numberOfOpenOrders: openOrders.length,
          numberOfOpenPositions: positions.length,
        };
      } catch (error) {
        console.error("Error fetching account summary:", error);
        throw error;
      }
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the agent knows this is a safe, repeatable read operation. The description adds the concept of 'aggregated' metrics, which provides some behavioral context beyond annotations, but it doesn't detail what aggregation entails or other traits like rate limits or auth needs.

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, efficient sentence with no wasted words. It's front-loaded with the core purpose and appropriately sized for a tool with no parameters, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's complexity (simple read with no parameters), annotations cover safety and idempotency, but there's no output schema to explain return values. The description mentions 'aggregated portfolio metrics' but doesn't specify what metrics are included or the format, leaving gaps in completeness for agent usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% description coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here, earning a baseline score of 4 for not introducing unnecessary information.

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

Purpose3/5

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

The description states the tool 'Get aggregated portfolio metrics' which specifies the action (get) and resource (portfolio metrics), but it's vague about what 'aggregated' means and doesn't distinguish it from sibling tools like get_portfolio or get_positions. It provides a basic purpose but lacks specificity and differentiation.

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?

No guidance is provided on when to use this tool versus alternatives such as get_portfolio or get_positions. The description implies usage for aggregated metrics but doesn't specify contexts, exclusions, or comparisons with siblings, leaving the agent without clear usage direction.

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/mbarinov/okx-mcp'

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