Skip to main content
Glama
SuxyEE
by SuxyEE

list_projects

Discover available Alibaba Cloud SLS projects across specified regions to identify log sources before querying logs. Supports single or multiple region queries with environment variable defaults.

Instructions

List all SLS projects in one or more Alibaba Cloud regions. Pass a single region string or an array of region IDs. If omitted, queries all regions configured in SLS_REGIONS / SLS_REGION env variables. Use this to discover available projects before querying logs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionsNoOne or more Alibaba Cloud region IDs to query. Accepts a single string (e.g. "cn-hangzhou") or an array (e.g. ["cn-hangzhou","cn-shenzhen"]). Defaults to all regions configured in SLS_REGIONS / SLS_REGION env variables.

Implementation Reference

  • The handler function that executes the logic for listing SLS projects.
    export async function handleListProjects(input: ListProjectsInput): Promise<string> {
      // Resolve target regions
      let targetRegions: string[];
      if (!input.regions || (Array.isArray(input.regions) && input.regions.length === 0)) {
        targetRegions = getConfiguredRegions();
      } else if (typeof input.regions === 'string') {
        targetRegions = [input.regions];
      } else {
        targetRegions = input.regions;
      }
    
      // Query all regions in parallel
      const results = await Promise.allSettled(
        targetRegions.map((region) => listProjects(region))
      );
    
      const allProjects: { projectName: string; description: string; region: string }[] = [];
      const errors: string[] = [];
    
      for (let i = 0; i < results.length; i++) {
        const result = results[i];
        if (result.status === 'fulfilled') {
          allProjects.push(...result.value);
        } else {
          errors.push(`${targetRegions[i]}: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}`);
        }
      }
    
      const lines: string[] = [];
    
      if (allProjects.length > 0) {
        // Group by region
        const byRegion = new Map<string, typeof allProjects>();
        for (const p of allProjects) {
          if (!byRegion.has(p.region)) byRegion.set(p.region, []);
          byRegion.get(p.region)!.push(p);
        }
    
        lines.push(`Found **${allProjects.length}** SLS projects across **${byRegion.size}** region(s):\n`);
    
        for (const [region, projects] of byRegion) {
          lines.push(`### ${region} (${projects.length} projects)`);
          for (const p of projects) {
            lines.push(`- **${p.projectName}**${p.description ? `  \n  ${p.description}` : ''}`);
          }
          lines.push('');
        }
      } else {
        lines.push('No SLS projects found.');
      }
    
      if (errors.length > 0) {
        lines.push(`\n**Errors in some regions:**`);
        for (const e of errors) {
          lines.push(`- ${e}`);
        }
      }
    
      lines.push('\nUse `list_logstores` to see logstores within a project.');
    
      return lines.join('\n');
    }
  • Zod schema defining the input for the list_projects tool.
    export const listProjectsSchema = z.object({
      regions: z
        .union([z.string(), z.array(z.string())])
        .optional()
        .describe(
          'One or more Alibaba Cloud region IDs to query. Accepts a single string (e.g. "cn-hangzhou") or an array (e.g. ["cn-hangzhou","cn-shenzhen"]). Defaults to all regions configured in SLS_REGIONS / SLS_REGION env variables.'
        ),
    });
  • src/index.ts:19-24 (registration)
    Registration of the list_projects tool in the main TOOLS array.
    {
      name: 'list_projects',
      description:
        'List all SLS projects in one or more Alibaba Cloud regions. Pass a single region string or an array of region IDs. If omitted, queries all regions configured in SLS_REGIONS / SLS_REGION env variables. Use this to discover available projects before querying logs.',
      inputSchema: zodToJsonSchema(listProjectsSchema) as Tool['inputSchema'],
    },

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/SuxyEE/aliyun-sls-mcp'

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