Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

list_files

Retrieve file structures from Alibaba Cloud Codeup repositories to navigate codebases, manage directories, and access project files using organization and repository identifiers.

Instructions

[Code Management] List file tree from a Codeup repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOrganization ID, can be found in the basic information page of the organization admin console
repositoryIdYesRepository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)
pathNoSpecific path to query, for example to query files in the src/main directory
refNoReference name, usually branch name, can be branch name, tag name or commit SHA. If not provided, the default branch of the repository will be used, such as master
typeNoFile tree retrieval method: DIRECT - only get the current directory, default method; RECURSIVE - recursively find all files under the current path; FLATTEN - flat display (if it is a directory, recursively find until the subdirectory contains files or multiple directories)RECURSIVE

Implementation Reference

  • Tool handler for 'list_files': parses arguments using ListFilesSchema and delegates to listFilesFunc, returns JSON stringified result.
    case "list_files": {
      const args = types.ListFilesSchema.parse(request.params.arguments);
      const fileList = await files.listFilesFunc(
        args.organizationId,
        args.repositoryId,
        args.path,
        args.ref,
        args.type
      );
      return {
        content: [{ type: "text", text: JSON.stringify(fileList, null, 2) }],
      };
    }
  • Registers the 'list_files' tool in the code-management registry with name, description, and input schema.
    {
      name: "list_files",
      description: "[Code Management] List file tree from a Codeup repository",
      inputSchema: zodToJsonSchema(types.ListFilesSchema),
    },
  • Defines the Zod input schema ListFilesSchema for the list_files tool parameters.
    export const ListFilesSchema = z.object({
      organizationId: z.string().describe("Organization ID, can be found in the basic information page of the organization admin console"),
      repositoryId: z.string().describe("Repository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)"),
      path: z.string().optional().describe("Specific path to query, for example to query files in the src/main directory"),
      ref: z.string().optional().describe("Reference name, usually branch name, can be branch name, tag name or commit SHA. If not provided, the default branch of the repository will be used, such as master"),
      type: z.string().default("RECURSIVE").optional().describe("File tree retrieval method: DIRECT - only get the current directory, default method; RECURSIVE - recursively find all files under the current path; FLATTEN - flat display (if it is a directory, recursively find until the subdirectory contains files or multiple directories)"),
    });
  • Core helper function listFilesFunc that performs the API request to Codeup to list files/tree, handles repo ID encoding, builds URL with params, fetches and parses response.
    export async function listFilesFunc(
      organizationId: string,
      repositoryId: string,
      path?: string,
      ref?: string,
      type?: string // Possible values: DIRECT, RECURSIVE, FLATTEN
    ): Promise<z.infer<typeof FileInfoSchema>[]> {
      // 自动处理repositoryId中未编码的斜杠
      let encodedRepoId = repositoryId;
      if (repositoryId.includes("/")) {
        // 发现未编码的斜杠,自动进行URL编码
        const parts = repositoryId.split("/", 2);
        if (parts.length === 2) {
          const encodedRepoName = encodeURIComponent(parts[1]);
          // 移除编码中的+号(空格被编码为+,但我们需要%20)
          const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
          encodedRepoId = `${parts[0]}%2F${formattedEncodedName}`;
        }
      }
    
      const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/files/tree`;
      
      // 构建查询参数
      const queryParams: Record<string, string | number | undefined> = {};
      
      if (path) {
        queryParams.path = path;
      }
      
      if (ref) {
        queryParams.ref = ref;
      }
      
      if (type) {
        queryParams.type = type;
      }
    
      // 使用buildUrl函数构建包含查询参数的URL
      const url = buildUrl(baseUrl, queryParams);
    
      const response = await yunxiaoRequest(url, {
        method: "GET",
      });
    
      // 确保响应是数组
      if (!Array.isArray(response)) {
        return [];
      }
    
      // 解析每个文件信息对象
      return response.map(fileInfo => FileInfoSchema.parse(fileInfo));
    } 
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'List file tree' which implies a read-only operation, but doesn't specify permissions required, rate limits, pagination behavior, or what the output format looks like. For a tool with 5 parameters and no output schema, this is insufficient.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. The '[Code Management]' prefix is front-loaded for context, and the core functionality is stated clearly.

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

Completeness3/5

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

For a read-only listing tool with comprehensive parameter documentation in the schema, the description is minimally adequate. However, with no output schema and no annotations, the description should ideally provide more context about what the tool returns and any behavioral constraints.

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 5 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, meeting the baseline 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('file tree from a Codeup repository'), and the '[Code Management]' prefix provides domain context. However, it doesn't explicitly differentiate from sibling tools like 'list_branches' or 'list_repositories', which would require a 5.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'get_file_blobs' or 'list_repositories'. The description only states what it does, not when it's appropriate or what prerequisites might exist.

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

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

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