sls_list_projects
List all SLS projects in a specified Alibaba Cloud region, with optional fuzzy search by project name. Retrieve project details including name, description, and region ID for quick identification and management.
Instructions
列出阿里云日志服务中的所有项目。
## 功能概述
该工具可以列出指定区域中的所有SLS项目,支持通过项目名进行模糊搜索。如果不提供项目名称,则返回该区域的所有项目。
## 使用场景
- 当需要查找特定项目是否存在时
- 当需要获取某个区域下所有可用的SLS项目列表时
- 当需要根据项目名称的部分内容查找相关项目时
## 返回数据结构
返回的项目信息包含:
- project_name: 项目名称
- description: 项目描述
- region_id: 项目所在区域
## 查询示例
- "有没有叫 XXX 的 project"
- "列出所有SLS项目"
Args:
ctx: MCP上下文,用于访问SLS客户端
project_name_query: 项目名称查询字符串,支持模糊搜索
limit: 返回结果的最大数量,范围1-100,默认10
region_id: 阿里云区域ID,region id format like "xx-xxx",like "cn-hangzhou"
Returns:
包含项目信息的字典列表,每个字典包含project_name、description和region_id
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | limit,max is 100 | |
| project_name_query | No | project name,fuzzy search | |
| region_id | Yes | aliyun region id |
Implementation Reference
- The sls_list_projects tool handler: lists SLS projects in the specified region using Alibaba Cloud SLS ListProject API, with optional fuzzy search by project name and limit. Includes retry and error handling decorators, and comprehensive docstring describing usage.@self.server.tool() @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_projects( ctx: Context, projectName: Optional[str] = Field( None, description="project name,fuzzy search" ), limit: int = Field( default=50, description="limit,max is 100", ge=1, le=100 ), regionId: str = Field(default=..., description="aliyun region id"), ) -> Dict[str, Any]: """列出阿里云日志服务中的所有项目。 ## 功能概述 该工具可以列出指定区域中的所有SLS项目,支持通过项目名进行模糊搜索。如果不提供项目名称,则返回该区域的所有项目。 ## 使用场景 - 当需要查找特定项目是否存在时 - 当需要获取某个区域下所有可用的SLS项目列表时 - 当需要根据项目名称的部分内容查找相关项目时 ## 返回数据结构 返回的项目信息包含: - project_name: 项目名称 - description: 项目描述 - region_id: 项目所在区域 ## 查询示例 - "有没有叫 XXX 的 project" - "列出所有SLS项目" Args: ctx: MCP上下文,用于访问SLS客户端 projectName: 项目名称查询字符串,支持模糊搜索 limit: 返回结果的最大数量,范围1-100,默认50 regionId: 阿里云区域ID,region id format like "xx-xxx",like "cn-hangzhou" Returns: 包含项目信息的字典列表,每个字典包含project_name、description和region_id """ sls_client: SLSClient = ctx.request_context.lifespan_context[ "sls_client" ].with_region(regionId) request: ListProjectRequest = ListProjectRequest( project_name=projectName, size=limit, ) response: ListProjectResponse = sls_client.list_project(request) return { "projects": [ { "project_name": project.project_name, "description": project.description, "region_id": project.region, } for project in response.body.projects ], "message": f"当前最多支持查询{limit}个项目,未防止返回数据过长,如果需要查询更多项目,您可以提供 project 的关键词来模糊查询", }
- Input schema definition using Pydantic Field for parameters: projectName (optional fuzzy search), limit (1-100, default 50), regionId (required).ctx: Context, projectName: Optional[str] = Field( None, description="project name,fuzzy search" ), limit: int = Field( default=50, description="limit,max is 100", ge=1, le=100 ), regionId: str = Field(default=..., description="aliyun region id"), ) -> Dict[str, Any]:
- Registers the IaaSToolkit on the FastMCP server, which in turn registers all IaaS tools including sls_list_projects via _register_tools().def register_iaas_tools(server: FastMCP): """Register IaaS toolkit tools with the FastMCP server Args: server: FastMCP server instance """ IaaSToolkit(server)
- src/mcp_server_aliyun_observability/server.py:51-53 (registration)Top-level registration call to register_iaas_tools when iaas scope is enabled, invoked during MCP server initialization.if scope == "all" or scope == "iaas": register_iaas_tools(mcp_server) registered_scopes.append("IaaS")