Skip to main content
Glama

gitea_compliance_check_all

Run comprehensive compliance checks on branches, commits, and pull requests to identify policy violations and generate detailed reports for Gitea repositories.

Instructions

Run comprehensive compliance check on branch, commits, and/or PR. Returns detailed report.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoRepository owner. Uses context if not provided
repoNoRepository name. Uses context if not provided
branchNoBranch name to check
pr_numberNoPR number to check (also checks its commits)
commit_countNoMax number of commits to check (default: 10)
config_pathNoPath to compliance config file
tokenNoOptional API token to override default authentication

Implementation Reference

  • The primary handler function `checkAll` that performs comprehensive compliance checks for branches, commits, and pull requests in Gitea repositories.
    export async function checkAll( ctx: ComplianceToolsContext, params: CheckAllParams ): Promise<AllCheckResult> { const owner = ctx.contextManager.resolveOwner(params.owner); const repo = ctx.contextManager.resolveRepo(params.repo); logger.info({ owner, repo }, 'Running comprehensive compliance check'); const result: AllCheckResult = { summary: { total_checks: 0, passed: 0, failed: 0, compliant: true, }, }; // 1. 检查分支(如果提供) if (params.branch) { result.branch = await checkBranch(ctx, { branch: params.branch, config_path: params.config_path, }); result.summary.total_checks++; if (result.branch.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } } // 2. 检查 PR(如果提供) if (params.pr_number) { result.pr = await checkPR(ctx, { owner, repo, pr_number: params.pr_number, config_path: params.config_path, token: params.token, }); result.summary.total_checks++; if (result.pr.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } // 如果有 PR,检查其关联的提交 try { const commitsResponse = await ctx.client.request({ method: 'GET', path: `/repos/${owner}/${repo}/pulls/${params.pr_number}/commits`, token: params.token, }); const commits = (commitsResponse.data as any[]) || []; const commitCount = params.commit_count || 10; const commitsToCheck = commits.slice(0, commitCount); result.commits = []; for (const commit of commitsToCheck) { const commitResult = await checkCommit(ctx, { owner, repo, sha: commit.sha, message: commit.commit?.message, config_path: params.config_path, token: params.token, }); result.commits.push(commitResult); result.summary.total_checks++; if (commitResult.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } } } catch (err) { logger.warn({ pr: params.pr_number, error: err }, 'Failed to fetch PR commits'); } } return result; }
  • Registers the 'gitea_compliance_check_all' tool with MCP server, including input schema and wrapper handler that delegates to ComplianceTools.checkAll.
    mcpServer.registerTool( 'gitea_compliance_check_all', { title: '综合规范检查', description: 'Run comprehensive compliance check on branch, commits, and/or PR. Returns detailed report.', inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), branch: z.string().optional().describe('Branch name to check'), pr_number: z.number().int().positive().optional().describe('PR number to check (also checks its commits)'), commit_count: z.number().int().positive().optional().describe('Max number of commits to check (default: 10)'), config_path: z.string().optional().describe('Path to compliance config file'), token: tokenSchema, }), }, async (args) => { try { const result = await ComplianceTools.checkAll(toolsContext, args as any); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text' as const, text: `Error: ${errorMessage}` }], isError: true }; } } );
  • Zod input schema defining parameters for the gitea_compliance_check_all tool: owner, repo, branch, pr_number, commit_count, config_path, token.
    inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), branch: z.string().optional().describe('Branch name to check'), pr_number: z.number().int().positive().optional().describe('PR number to check (also checks its commits)'), commit_count: z.number().int().positive().optional().describe('Max number of commits to check (default: 10)'), config_path: z.string().optional().describe('Path to compliance config file'), token: tokenSchema,
  • TypeScript interface CheckAllParams defining the input parameters for the checkAll handler function.
    export interface CheckAllParams extends ComplianceParams { branch?: string; pr_number?: number; commit_count?: number; config_path?: string; }
  • TypeScript interface AllCheckResult defining the structured output of the checkAll function.
    export interface AllCheckResult { branch?: BranchCheckResult; commits?: CommitCheckResult[]; pr?: PRCheckResult; summary: { total_checks: number; passed: number; failed: number; compliant: boolean; }; }

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/SupenBysz/gitea-mcp-tool'

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