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
    """
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the tool lists log stores with fuzzy search capabilities, defaults to log store type if unspecified, supports pagination via limit (range 1-100), and distinguishes between log and metric stores. It doesn't mention rate limits, authentication needs, or error handling, but covers core operational traits well.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (功能概述, 使用场景, etc.), but it includes redundant information. The Args and Returns sections repeat what's in the schema, and the query examples add little practical value. While not overly verbose, some content doesn't earn its place, reducing efficiency.

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

Completeness4/5

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

For a tool with 6 parameters, no annotations, and no output schema, the description does a good job. It explains the tool's purpose, usage, and key behaviors, and the schema covers parameter details. The main gap is the lack of output format explanation beyond '日志库名称的字符串列表' (list of log store names), but given the tool's simplicity, this is sufficient.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema: it mentions fuzzy search for log_store and clarifies is_metric_store usage in a dedicated section. However, it doesn't provide additional context like examples for region_id format or interactions between parameters. Baseline 3 is appropriate given the schema does most of the work.

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 tool's purpose: '列出SLS项目中的日志库' (list log stores in SLS projects). It specifies the exact action (list) and resource (log stores), and distinguishes it from siblings like sls_describe_logstore (which describes a single log store) and sls_list_projects (which lists projects). The functional overview reinforces this with details about fuzzy search and default behavior.

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

Usage Guidelines5/5

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

The description provides explicit usage scenarios: finding if a specific log store exists, getting all available log stores, or searching by partial name. It also includes a dedicated section '是否指标库' (Is it a metric store) that explicitly guides when to set is_metric_store to True versus False, offering clear alternatives for different data types.

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

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