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.

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

  • Core handler function implementing the comprehensive compliance check for branches, commits, and PRs. Orchestrates individual check functions and aggregates results.
    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 the MCP server, including input schema definition and thin wrapper handler that delegates to the core checkAll implementation.
    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 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 defining input parameters for checkAll, matching the Zod schema.
    export interface CheckAllParams extends ComplianceParams { branch?: string; pr_number?: number; commit_count?: number; config_path?: string; }
  • Helper function to load compliance configuration from YAML file (.gitea/compliance.yaml), merging with defaults.
    export function loadComplianceConfig(configPath?: string): ComplianceConfig { const searchPaths = [ configPath, path.join(process.cwd(), '.gitea', 'compliance.yaml'), path.join(process.cwd(), '.gitea', 'compliance.yml'), ].filter(Boolean) as string[]; for (const p of searchPaths) { if (fs.existsSync(p)) { try { const content = fs.readFileSync(p, 'utf-8'); const parsed = yaml.parse(content); logger.info({ path: p }, 'Loaded compliance config'); return mergeConfig(DEFAULT_CONFIG, parsed); } catch (err) { logger.warn({ path: p, error: err }, 'Failed to parse compliance config'); } } } logger.info('Using default compliance config'); return DEFAULT_CONFIG; }

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