Skip to main content
Glama
aliyun

AlibabaCloud MCP Server

Official
by aliyun

ListBuckets

Retrieve a list of all Alibaba Cloud OSS buckets in a specified region, optionally filtered by a bucket name prefix, using the AlibabaCloud MCP Server API.

Instructions

列出指定区域的所有OSS存储空间。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
PrefixNoAlibabaCloud OSS Bucket Name prefix
RegionIdNoAlibabaCloud region IDcn-hangzhou

Implementation Reference

  • Handler function for the OSS_ListBuckets tool (likely 'ListBuckets'), lists all OSS buckets in the specified region with optional prefix using paginator.
    @tools.append def OSS_ListBuckets( RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), Prefix: str = Field(description='AlibabaCloud OSS Bucket Name prefix', default=None) ): """列出指定区域的所有OSS存储空间。""" client = create_client(region_id=RegionId) paginator = client.list_buckets_paginator() results = [] for page in paginator.iter_page(oss.ListBucketsRequest(prefix=Prefix)): for bucket in page.buckets: results.append(bucket.__str__()) return results
  • Registers the OSS tools, including the ListBuckets handler, with the MCP server.
    for tool in oss_tools.tools: mcp.tool(tool)
  • Helper function to create the OSS client configured with credentials and region.
    def create_client(region_id: str) -> oss.Client: credentials_provider = CredentialsProvider() cfg = oss.config.load_default() cfg.user_agent = 'alibaba-cloud-ops-mcp-server' cfg.credentials_provider = credentials_provider cfg.region = region_id return oss.Client(cfg)
  • Custom credentials provider for OSS client using header or credential client.
    class CredentialsProvider(EnvironmentVariableCredentialsProvider): def __init__(self) -> None: credentials = get_credentials_from_header() if credentials: access_key_id = credentials.get('AccessKeyId', None) access_key_secret = credentials.get('AccessKeySecret', None) session_token = credentials.get('SecurityToken', None) else: credentialsClient = CredClient() access_key_id = credentialsClient.get_credential().access_key_id access_key_secret = credentialsClient.get_credential().access_key_secret session_token = credentialsClient.get_credential().security_token self._credentials = Credentials( access_key_id, access_key_secret, session_token) def get_credentials(self) -> Credentials: return self._credentials

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-core-mcp-server'

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