Skip to main content
Glama
aliyun

Alibaba Cloud Observability MCP Server

Official
by aliyun

sls_list_logstores

List all log stores in a specified SLS project, enabling search by name and filtering for metric stores. Use it to retrieve log store details efficiently.

Instructions

列出SLS项目中的日志库。

## 功能概述 该工具可以列出指定SLS项目中的所有日志库,如果不选,则默认为日志库类型 支持通过日志库名称进行模糊搜索。如果不提供日志库名称,则返回项目中的所有日志库。 ## 使用场景 - 当需要查找特定项目下是否存在某个日志库时 - 当需要获取项目中所有可用的日志库列表时 - 当需要根据日志库名称的部分内容查找相关日志库时 ## 是否指标库 如果需要查找指标或者时序相关的库,请将is_metric_store参数设置为True ## 查询示例 - "我想查询有没有 XXX 的日志库" - "某个 project 有哪些 log store" Args: ctx: MCP上下文,用于访问SLS客户端 project: SLS项目名称,必须精确匹配 log_store: 日志库名称,支持模糊搜索 limit: 返回结果的最大数量,范围1-100,默认10 is_metric_store: 是否指标库,可选值为True或False,默认为False region_id: 阿里云区域ID Returns: 日志库名称的字符串列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
is_metric_storeNois metric store,default is False,only use want to find metric store
limitNolimit,max is 100
log_storeNolog store name,fuzzy search
log_store_typeNolog store type,default is logs,should be logs,metrics
projectYessls project name,must exact match
region_idYesaliyun region id,region id format like 'xx-xxx',like 'cn-hangzhou'

Implementation Reference

  • Full implementation of the sls_list_logstores tool handler, including decorators for registration (@server.tool()), retry logic, error handling, input schema via Pydantic Fields, comprehensive docstring, and the core logic using Alibaba Cloud SLS client to list log stores in a project with optional fuzzy search and metric store filtering.
    @retry( stop=stop_after_attempt(Config.get_retry_attempts()), wait=wait_fixed(Config.RETRY_WAIT_SECONDS), retry=retry_if_exception_type(Exception), reraise=True, ) @handle_tea_exception def sls_list_logstores( ctx: Context, project: str = Field( ..., description="sls project name,must exact match,should not contain chinese characters", ), logStore: Optional[str] = Field( None, description="log store name,fuzzy search" ), limit: int = Field(10, description="limit,max is 100", ge=1, le=100), isMetricStore: bool = Field( False, description="is metric store,default is False,only use want to find metric store", ), regionId: str = Field( default=..., description="aliyun region id,region id format like 'xx-xxx',like 'cn-hangzhou'", ), ) -> Dict[str, Any]: """列出SLS项目中的日志库。 ## 功能概述 该工具可以列出指定SLS项目中的所有日志库,如果不选,则默认为日志库类型 支持通过日志库名称进行模糊搜索。如果不提供日志库名称,则返回项目中的所有日志库。 ## 使用场景 - 当需要查找特定项目下是否存在某个日志库时 - 当需要获取项目中所有可用的日志库列表时 - 当需要根据日志库名称的部分内容查找相关日志库时 - 如果从上下文未指定 project参数,除非用户说了遍历,则可使用 iaas_sls_list_projects 工具获取项目列表 ## 是否指标库 如果需要查找指标或者时序相关的库,请将isMetricStore参数设置为True ## 查询示例 - "我想查询有没有 XXX 的日志库" - "某个 project 有哪些 log store" Args: ctx: MCP上下文,用于访问SLS客户端 project: SLS项目名称,必须精确匹配 logStore: 日志库名称,支持模糊搜索 limit: 返回结果的最大数量,范围1-100,默认10 isMetricStore: 是否指标库,可选值为True或False,默认为False regionId: 阿里云区域ID Returns: 日志库名称的字符串列表 """ if project == "": return { "total": 0, "logstores": [], "message": "Please specify the project name,if you want to list all projects,please use iaas_sls_list_projects tool", } sls_client: SLSClient = ctx.request_context.lifespan_context[ "sls_client" ].with_region(regionId) logStoreType = "Metrics" if isMetricStore else None request: ListLogStoresRequest = ListLogStoresRequest( logstore_name=logStore, size=limit, telemetry_type=logStoreType, ) response: ListLogStoresResponse = sls_client.list_log_stores( project, request ) log_store_count = response.body.total log_store_list = response.body.logstores return { "total": log_store_count, "logstores": log_store_list, "message": ( "Sorry not found logstore,please make sure your project and region or logstore name is correct, if you want to find metric store,please check isMetricStore parameter" if log_store_count == 0 else f"当前最多支持查询{limit}个日志库,未防止返回数据过长,如果需要查询更多日志库,您可以提供 logstore 的关键词来模糊查询" ), }
  • The registration entry point for the IaaS toolkit, which instantiates IaaSToolkit and triggers the registration of all IaaS tools including sls_list_logstores via _register_tools() method.
    def register_iaas_tools(server: FastMCP): """Register IaaS toolkit tools with the FastMCP server Args: server: FastMCP server instance """ IaaSToolkit(server)
  • Tool description in the IaaSToolkit class docstring, listing sls_list_logstores among available tools.
    - sls_list_projects: List SLS projects in a region - sls_list_logstores: List log stores in an SLS project """

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

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