Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

create_file

Create and commit new files to Codeup repositories for managing code changes in Alibaba Cloud DevOps workflows.

Instructions

[Code Management] Create a new file in 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)
filePathYesFile path, needs to be URL encoded, for example: /src/main/java/com/aliyun/test.java
contentYesFile content
commitMessageYesCommit message, not empty, no more than 102400 characters
branchYesBranch name
encodingNoEncoding rule, options {text, base64}, default is text

Implementation Reference

  • Core handler function createFileFunc that implements the logic to create a file in Codeup repository via API call, including path encoding, request body preparation, and response parsing.
    export async function createFileFunc(
      organizationId: string,
      repositoryId: string,
      filePath: string,
      content: string,
      commitMessage: string,
      branch: string,
      encoding?: string
    ): Promise<z.infer<typeof CreateFileResponseSchema>> {
      let encodedRepoId = repositoryId;
      let encodedFilePath = filePath;
    
      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}`;
        }
      }
    
      // 确保filePath已被URL编码
      if (filePath.includes("/")) {
        encodedFilePath = pathEscape(filePath);
      }
    
      const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/files`;
    
      const body = {
        branch: branch,
        filePath: encodedFilePath,
        content: content,
        commitMessage: commitMessage,
        encoding: encoding || "text"  // 默认使用text编码
      };
    
      const response = await yunxiaoRequest(url, {
        method: "POST",
        body: body
      });
    
      return CreateFileResponseSchema.parse(response);
    }
  • Registers the 'create_file' tool with its name, description, and input schema in the getCodeManagementTools array.
    name: "create_file",
    description: "[Code Management] Create a new file in a Codeup repository",
    inputSchema: zodToJsonSchema(types.CreateFileSchema),
  • Zod schema definition for CreateFileSchema used as input validation for the create_file tool.
    export const CreateFileSchema = 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)"),
      filePath: z.string().describe("File path, needs to be URL encoded, for example: /src/main/java/com/aliyun/test.java"),
      content: z.string().describe("File content"),
      commitMessage: z.string().describe("Commit message, not empty, no more than 102400 characters"),
      branch: z.string().describe("Branch name"),
      encoding: z.string().optional().describe("Encoding rule, options {text, base64}, default is text"),
    });
  • Zod schema for CreateFileResponseSchema used to parse the API response.
    export const CreateFileResponseSchema = z.object({
      filePath: z.string().optional().describe("File path"),
      branch: z.string().optional().describe("Branch name"),
      newOid: z.string().optional().describe("Git Object ID"),
    });
  • Dispatch handler in handleCodeManagementTools that parses input arguments and delegates to createFileFunc, formats response for MCP.
    case "create_file": {
      const args = types.CreateFileSchema.parse(request.params.arguments);
      const result = await files.createFileFunc(
        args.organizationId,
        args.repositoryId,
        args.filePath,
        args.content,
        args.commitMessage,
        args.branch,
        args.encoding
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions creation but doesn't specify whether this requires specific permissions, if it overwrites existing files, what happens on failure, or any rate limits. For a mutation tool with zero annotation coverage, this is a significant gap in describing behavioral traits beyond the basic action.

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 that front-loads the core action ('Create a new file') and resource context. There's no wasted verbiage, and the '[Code Management]' prefix, while not essential, is brief. Every word earns its place, making it highly concise and well-structured.

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

Completeness2/5

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

Given the tool's complexity (7 parameters, 6 required, mutation operation) and lack of annotations or output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, error handling, or return values, which are critical for a file creation tool. The high schema coverage helps with parameters, but overall context for safe and effective use is lacking.

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 fully documents all 7 parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain relationships between parameters like 'filePath' and 'content'). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't need to.

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 action ('Create a new file') and resource ('in a Codeup repository'), providing specific verb+resource pairing. However, it doesn't explicitly distinguish this tool from sibling tools like 'update_file' or 'delete_file', though the action is distinct. The '[Code Management]' prefix adds context but isn't essential for purpose clarity.

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?

The description provides no guidance on when to use this tool versus alternatives like 'update_file' or 'delete_file', nor does it mention prerequisites (e.g., needing repository access) or contextual constraints. It states what the tool does but offers no usage context, leaving the agent to infer when this operation is appropriate.

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