Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

get_file_blobs

Retrieve file content from Alibaba Cloud Codeup repositories using organization ID, repository ID, file path, and branch reference for code management workflows.

Instructions

[Code Management] Get file content 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)
filePathYesFile path, needs to be URL encoded, for example: /src/main/java/com/aliyun/test.java
refYesReference 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

Implementation Reference

  • Handler case in handleCodeManagementTools function that validates input with GetFileBlobsSchema and invokes files.getFileBlobsFunc to retrieve file contents, then returns JSON stringified response.
    case "get_file_blobs": { const args = types.GetFileBlobsSchema.parse(request.params.arguments); const fileContent = await files.getFileBlobsFunc( args.organizationId, args.repositoryId, args.filePath, args.ref ); return { content: [{ type: "text", text: JSON.stringify(fileContent, null, 2) }], }; }
  • Core implementation function getFileBlobsFunc that encodes paths, constructs API URL, makes GET request to Codeup API for file content, and parses response with FileContentSchema.
    export async function getFileBlobsFunc( organizationId: string, repositoryId: string, filePath: string, ref: string ): Promise<z.infer<typeof FileContentSchema>> { // const { encodedRepoId, encodedFilePath } = handlePathEncoding(repositoryId, filePath); let encodedRepoId = repositoryId; let encodedFilePath = filePath; // 自动处理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}`; } } // 确保filePath已被URL编码 if (filePath.includes("/")) { encodedFilePath = encodeURIComponent(filePath); } const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/files/${encodedFilePath}`; // 构建查询参数 const queryParams: Record<string, string | number | undefined> = { ref: ref }; // 使用buildUrl函数构建包含查询参数的URL const url = buildUrl(baseUrl, queryParams); const response = await yunxiaoRequest(url, { method: "GET", }); return FileContentSchema.parse(response); }
  • Tool registration entry in getCodeManagementTools array, specifying name, description, and input schema derived from GetFileBlobsSchema.
    { name: "get_file_blobs", description: "[Code Management] Get file content from a Codeup repository", inputSchema: zodToJsonSchema(types.GetFileBlobsSchema), },
  • Zod input schema definition for get_file_blobs tool parameters: organizationId, repositoryId, filePath, ref.
    export const GetFileBlobsSchema = 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"), ref: z.string().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"), });

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