Skip to main content
Glama
aliyun

Alibaba Cloud RDS OpenAPI MCP Server

Official
by aliyun

describe_bills

Query consumption summaries for Alibaba Cloud RDS instances or billing items within specified billing periods to analyze database costs.

Instructions

Query the consumption summary of all product instances or billing items for a user within a specific billing period. Args: billing_cycles: bill cycle YYYY-MM, e.g. 2020-03 db_instance_id: DB instance id (e.g., "rm-xxx") is_billing_item: Whether to pull data according to the billing item dimension. Returns: str: billing information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
billing_cyclesYes
db_instance_idNo
is_billing_itemNo

Implementation Reference

  • The core handler function implementing the 'describe_bills' MCP tool. It queries Alibaba Cloud billing data for RDS instances using the BSS OpenAPI DescribeInstanceBill API, handling pagination and filtering by DB instance ID if provided. Returns billing details in CSV format per billing cycle.
    @mcp.tool(annotations=READ_ONLY_TOOL) async def describe_bills( billing_cycles: list[str], db_instance_id: str = None, is_billing_item: bool = False ) -> dict[str, Any]: """ Query the consumption summary of all product instances or billing items for a user within a specific billing period. Args: billing_cycles: bill cycle YYYY-MM, e.g. 2020-03 db_instance_id: DB instance id (e.g., "rm-xxx") is_billing_item: Whether to pull data according to the billing item dimension. Returns: str: billing information. """ try: client = get_bill_client("cn-hangzhou") res = {} for billing_cycle in billing_cycles: has_next_token = True next_token = None items = [] while has_next_token: describe_instance_bill_request = bss_open_api_20171214_models.DescribeInstanceBillRequest( billing_cycle=billing_cycle, product_code='rds', is_billing_item=is_billing_item, next_token=next_token ) if db_instance_id: describe_instance_bill_request.db_instance_id = db_instance_id response = client.describe_instance_bill(describe_instance_bill_request) if not response.body.data: break next_token = response.body.data.next_token has_next_token = next_token is not None and next_token.strip() != "" items.extend(response.body.data.items) item_filters = [] for item in items: if db_instance_id is None or db_instance_id in item.instance_id.split(";"): item_filters.append( { "Item": item.item, "AfterDiscountAmount": item.after_discount_amount, "InstanceID": item.instance_id, "BillingDate": item.billing_date, "InvoiceDiscount": item.invoice_discount, "SubscriptionType": item.subscription_type, "PretaxGrossAmount": item.pretax_gross_amount, "Currency": item.currency, "CommodityCode": item.commodity_code, "CostUnit": item.cost_unit, "NickName": item.nick_name, "PretaxAmount": item.pretax_amount, "BillingItem": item.billing_item, "BillingItemPriceUnit": item.list_price_unit, "BillingItemUsage": item.usage, } ) res[billing_cycle] = json_array_to_csv(item_filters) return res except Exception as e: raise e @mcp.tool()
  • Helper function to create and return a BssOpenApi20171214Client instance (billing client) used by the describe_bills tool.
    def get_bill_client(region_id: str): ak, sk, sts = get_aksk() config = Config( access_key_id=ak, access_key_secret=sk, security_token=sts, region_id=region_id, protocol="https", connect_timeout=10 * 1000, read_timeout=300 * 1000 ) client = BssOpenApi20171214Client(config) return client
  • The @mcp.tool decorator registers the describe_bills function as an MCP tool with read-only hint.
    @mcp.tool(annotations=READ_ONLY_TOOL)

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/aliyun/alibabacloud-rds-openapi-mcp-server'

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