Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

compare

Compare code changes between commits, branches, or tags in Alibaba Cloud DevOps repositories to review differences and track modifications.

Instructions

[Code Management] Query code to compare content

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)
fromYesCan be CommitSHA, branch name or tag name
toYesCan be CommitSHA, branch name or tag name
sourceTypeNoOptions: branch, tag; if it's a commit comparison, you can omit this; if it's a branch comparison, you need to provide: branch, or you can omit it but ensure there are no branch or tag name conflicts; if it's a tag comparison, you need to provide: tag; if there are branches and tags with the same name, you need to strictly provide branch or tag
targetTypeNoOptions: branch, tag; if it's a commit comparison, you can omit this; if it's a branch comparison, you need to provide: branch, or you can omit it but ensure there are no branch or tag name conflicts; if it's a tag comparison, you need to provide: tag; if there are branches and tags with the same name, you need to strictly provide branch or tag
straightNoWhether to use Merge-Base: straight=false means using Merge-Base; straight=true means not using Merge-Base; default is false, meaning using Merge-Base

Implementation Reference

  • Handler for the 'compare' tool: parses input using GetCompareSchema and invokes getCompareFunc from operations/codeup/compare.js, returning the result as JSON.
    case "compare": { const args = types.GetCompareSchema.parse(request.params.arguments); const compareResult = await compare.getCompareFunc( args.organizationId, args.repositoryId, args.from, args.to, args.sourceType ?? undefined, args.targetType ?? undefined, args.straight ?? undefined ); return { content: [{ type: "text", text: JSON.stringify(compareResult, null, 2) }], }; }
  • Input schema (GetCompareSchema) for the 'compare' tool, defining parameters like organizationId, repositoryId, from, to, etc.
    export const GetCompareSchema = 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)"), from: z.string().describe("Can be CommitSHA, branch name or tag name"), to: z.string().describe("Can be CommitSHA, branch name or tag name"), sourceType: z.string().nullable().optional().describe("Options: branch, tag; if it's a commit comparison, you can omit this; if it's a branch comparison, you need to provide: branch, or you can omit it but ensure there are no branch or tag name conflicts; if it's a tag comparison, you need to provide: tag; if there are branches and tags with the same name, you need to strictly provide branch or tag"), targetType: z.string().nullable().optional().describe("Options: branch, tag; if it's a commit comparison, you can omit this; if it's a branch comparison, you need to provide: branch, or you can omit it but ensure there are no branch or tag name conflicts; if it's a tag comparison, you need to provide: tag; if there are branches and tags with the same name, you need to strictly provide branch or tag"), straight: z.string().default("false").nullable().optional().describe("Whether to use Merge-Base: straight=false means using Merge-Base; straight=true means not using Merge-Base; default is false, meaning using Merge-Base"), });
  • Registration of the 'compare' tool in getCodeManagementTools array, specifying name, description, and inputSchema.
    { name: "compare", description: "[Code Management] Query code to compare content", inputSchema: zodToJsonSchema(types.GetCompareSchema), },
  • Core helper function getCompareFunc that performs the API call to Codeup compare endpoint and parses response with CompareSchema.
    export async function getCompareFunc( organizationId: string, repositoryId: string, from: string, to: string, sourceType?: string, // Possible values: branch, tag targetType?: string, // Possible values: branch, tag straight?: string ): Promise<z.infer<typeof CompareSchema>> { const encodedRepoId = handleRepositoryIdEncoding(repositoryId); const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/compares`; const queryParams: Record<string, string | undefined> = { from, to }; if (sourceType !== undefined) { queryParams.sourceType = sourceType; } if (targetType !== undefined) { queryParams.targetType = targetType; } if (straight !== undefined) { queryParams.straight = straight; } const url = buildUrl(baseUrl, queryParams); const response = await yunxiaoRequest(url, { method: "GET", }); return CompareSchema.parse(response); }
  • Output schema (CompareSchema) used to parse the response from the compare API in getCompareFunc.
    export const CompareSchema = z.object({ base_commit_sha: z.string().optional(), commits: z.array(z.unknown()).optional(), commits_count: z.number().optional(), diffs: z.array(z.unknown()).optional(), files_count: z.number().optional(), from: z.string().optional(), to: z.string().optional(), });

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