Skip to main content
Glama
xiaobenyang-com

CurrencyAndOil

calculate_barrels_for_rub

calculate_barrels_for_rub

Calculate barrels of Brent crude oil purchasable with Russian Rubles using real-time exchange rates and oil prices for financial analysis.

Instructions

Calculate how many barrels of Brent crude oil can be purchased for a given amount in Russian Rubles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYes

Implementation Reference

  • This is the core handler function `calcXiaoBenYangApi` that implements the logic for all dynamic tools, including 'calculate_barrels_for_rub'. It constructs and sends a POST request to the remote API endpoint 'https://mcp.xiaobenyang.com/api' using the tool name and arguments, and formats the response as MCP content.
    const calcXiaoBenYangApi = async function (fullArgs: Record<string, any>) {
        // 发起 POST 请求
        let response = await fetch('https://mcp.xiaobenyang.com/api', {
            method: 'POST',
            headers: {
                'XBY-APIKEY': apiKey,
                'func': fullArgs.toolName,
                'mcpid': mcpID
            },
            body: new URLSearchParams(fullArgs)
        });
        const apiResult = await response.text();
    
        return {
            content: [
                {
                    type: "text",
                    text: apiResult // 将字符串结果放入 content 中
                }
            ]
        } as { [x: string]: unknown; content: [{ type: "text"; text: string }] };
    };
  • Wrapper function `handleXiaoBenYangApi` that prepares the arguments by adding the tool name and calls the core proxy handler. This is invoked by the registered tool handlers.
    const handleXiaoBenYangApi = async (args: Record<string, any>, toolName: string) => {
        // 校验aid是否存在
        if (toolName === undefined || toolName === null) {
            throw new Error("缺少必要参数 'aid'");
        }
        // 合并参数
        const fullArgs = {...args, toolName: toolName};
        // 调用API
        return calcXiaoBenYangApi(fullArgs);
    };
  • src/mcp.ts:50-65 (registration)
    Utility function `addToolXiaoBenYangApi` that registers each tool on the MCP server using the generic proxy handler, dynamic input schema, and description fetched from the remote API.
    const addToolXiaoBenYangApi = function (
        name: string,
        desc: string,
        params: Record<string, ZodType>
    ) {
        server.registerTool(
            name,
            {
                title: name,
                description: desc,
                inputSchema: params,
            }
            ,
            async (args: Record<string, any>) => handleXiaoBenYangApi(args, name)
        )
    };
  • src/mcp.ts:89-132 (registration)
    Dynamic registration loop that fetches tool descriptions from 'https://mcp.xiaobenyang.com/getMcpDesc?mcpId=1777316659852291', parses schemas into Zod validators, and registers all tools (including 'calculate_barrels_for_rub') using `addToolXiaoBenYangApi`.
    for (const apiDesc of apiDescList) {
        let inputSchema = JSON.parse(apiDesc.inputSchema);
        const zodDict: Record<string, z.ZodTypeAny> = {};
    
        Object.entries(inputSchema.properties).forEach(([name, propConfig]) => {
            let zodType;
            let pt = (propConfig as { type: string }).type;
            switch (pt) {
                case 'string':
                    zodType = z.string();
                    break;
                case 'number':
                    zodType = z.number();
                    break;
                case 'boolean':
                    zodType = z.boolean();
                    break;
                case 'integer':
                    zodType = z.int32();
                    break;
                case 'array':
                    zodType = z.array(z.any());
                    break;
                case 'object':
                    zodType = z.object(z.any());
                    break;
                default:
                    zodType = z.any();
            }
    
            if (inputSchema.required?.includes(name)) {
                zodDict[name] = zodType;
            } else {
                zodDict[name] = zodType.optional();
            }
        });
    
    
        addToolXiaoBenYangApi(
            apiDesc.name,
            apiDesc.description ? apiDesc.description : apiDesc.name,
            zodDict);
    }
  • Dynamic schema construction: Parses JSON schema from remote API description and converts it to a Zod object for input validation of tools like 'calculate_barrels_for_rub'.
    const zodDict: Record<string, z.ZodTypeAny> = {};
    
    Object.entries(inputSchema.properties).forEach(([name, propConfig]) => {
        let zodType;
        let pt = (propConfig as { type: string }).type;
        switch (pt) {
            case 'string':
                zodType = z.string();
                break;
            case 'number':
                zodType = z.number();
                break;
            case 'boolean':
                zodType = z.boolean();
                break;
            case 'integer':
                zodType = z.int32();
                break;
            case 'array':
                zodType = z.array(z.any());
                break;
            case 'object':
                zodType = z.object(z.any());
                break;
            default:
                zodType = z.any();
        }
    
        if (inputSchema.required?.includes(name)) {
            zodDict[name] = zodType;
        } else {
            zodDict[name] = zodType.optional();
        }
    });
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the calculation purpose but lacks behavioral details such as whether it uses real-time or cached rates, any rate limits, error handling for invalid amounts, or output format. This is a significant gap for a financial calculation tool.

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, clear sentence with zero waste—front-loaded with the verb and resource, efficiently conveying the tool's purpose without unnecessary words.

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 no annotations, 0% schema coverage, and no output schema, the description is incomplete. It doesn't explain the calculation method, return values (e.g., barrels as a number), or error cases, leaving critical gaps for agent usage in a context with multiple sibling tools.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions 'a given amount in Russian Rubles' which clarifies the 'amount' parameter's purpose, but doesn't add details like units (e.g., Rubles as a number), constraints (e.g., positive values), or examples. This partial compensation is insufficient for full clarity.

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

Purpose5/5

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

The description clearly states the specific verb 'calculate' and the resource 'barrels of Brent crude oil' that can be purchased, with explicit mention of the input currency 'Russian Rubles'. It distinguishes from siblings by specifying the currency input, unlike calculate_barrels_for_eur and calculate_barrels_for_usd.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'for a given amount in Russian Rubles', indicating this tool is for converting Rubles to barrels. However, it doesn't explicitly state when to use this versus alternatives like get_brent_rub_rate for just the rate, or when not to use it for other currencies.

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/xiaobenyang-com/CurrencyAndOil'

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