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;
    }
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. It mentions the tool 'Returns detailed report', which adds some behavioral context about output. However, it lacks details on permissions needed, rate limits, whether it's read-only or mutative, or any side effects, which are critical for a compliance check tool.

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 and scope, with no wasted words. It clearly communicates the tool's purpose and output in a compact form.

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

Completeness3/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, no annotations, no output schema), the description is minimal but adequate for basic understanding. It covers the action and output type, but lacks details on authentication, error handling, or report format, which would be helpful for a comprehensive tool.

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 already documents all 7 parameters thoroughly. The description adds no additional parameter semantics beyond implying checks on 'branch, commits, and/or PR', which loosely relates to 'branch', 'pr_number', and 'commit_count' parameters but doesn't provide extra syntax or usage details.

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 ('Run comprehensive compliance check') and targets ('branch, commits, and/or PR'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'gitea_compliance_check_branch' or 'gitea_compliance_check_pr' beyond mentioning it's 'comprehensive' and covers multiple targets.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning it checks 'branch, commits, and/or PR', suggesting it can handle multiple targets, but it doesn't explicitly state when to use this tool versus the more specific sibling tools (e.g., 'gitea_compliance_check_branch' for branch-only checks). No exclusions or prerequisites are provided.

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

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