Skip to main content
Glama

创建 Pull Request

gitea_pr_create

Create pull requests in Gitea repositories with AI-assisted content generation for titles, descriptions, and branch management.

Instructions

Create a new pull request. Use this tool for AI-assisted PR creation with smart content generation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoRepository owner. Uses context if not provided
repoNoRepository name. Uses context if not provided
titleYesPR title
bodyNoPR body/description
headYesBranch name to merge from
baseYesBranch name to merge into
assigneesNoUsernames to assign
labelsNoLabel IDs to attach
milestoneNoMilestone ID
tokenNoOptional API token to override default authentication

Implementation Reference

  • Main handler function that executes the PR creation logic: resolves repo context, constructs options, calls Gitea API POST /pulls, formats and returns PR details.
    /**
     * 创建 Pull Request
     */
    export async function createPullRequest(
      ctx: PullRequestToolsContext,
      args: {
        owner?: string;
        repo?: string;
        title: string;
        head: string;
        base: string;
        body?: string;
        assignee?: string;
        assignees?: string[];
        milestone?: number;
        labels?: number[];
        due_date?: string;
        token?: string;
      }
    ) {
      logger.debug({ args }, 'Creating pull request');
    
      const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo);
    
      const createOptions: CreatePullRequestOptions = {
        title: args.title,
        head: args.head,
        base: args.base,
        body: args.body,
        assignee: args.assignee,
        assignees: args.assignees,
        milestone: args.milestone,
        labels: args.labels,
        due_date: args.due_date,
      };
    
      const pr = await ctx.client.post<GiteaPullRequest>(
        `/repos/${owner}/${repo}/pulls`,
        createOptions,
        args.token
      );
    
      logger.info({ owner, repo, pr: pr.number }, 'Pull request created successfully');
    
      return {
        success: true,
        pull_request: {
          id: pr.id,
          number: pr.number,
          title: pr.title,
          body: pr.body,
          state: pr.state,
          user: {
            id: pr.user.id,
            login: pr.user.login,
          },
          head: {
            ref: pr.head.ref,
            sha: pr.head.sha,
          },
          base: {
            ref: pr.base.ref,
            sha: pr.base.sha,
          },
          mergeable: pr.mergeable,
          merged: pr.merged,
          labels: pr.labels.map((l) => ({ id: l.id, name: l.name, color: l.color })),
          assignees: pr.assignees?.map((a) => ({ id: a.id, login: a.login })),
          milestone: pr.milestone
            ? { id: pr.milestone.id, title: pr.milestone.title }
            : null,
          html_url: pr.html_url,
          diff_url: pr.diff_url,
          patch_url: pr.patch_url,
          created_at: pr.created_at,
          updated_at: pr.updated_at,
        },
      };
    }
  • MCP tool registration for 'gitea_pr_create': defines tool metadata, Zod inputSchema, and thin handler wrapper that calls the core createPullRequest function.
    // gitea_pr_create - 创建 PR (智能内容生成)
    mcpServer.registerTool(
      'gitea_pr_create',
      {
        title: '创建 Pull Request',
        description: 'Create a new pull request. Use this tool for AI-assisted PR creation with smart content generation.',
        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'),
          title: z.string().min(1).describe('PR title'),
          body: z.string().optional().describe('PR body/description'),
          head: z.string().min(1).describe('Branch name to merge from'),
          base: z.string().min(1).describe('Branch name to merge into'),
          assignees: z.array(z.string()).optional().describe('Usernames to assign'),
          labels: z.array(z.number()).optional().describe('Label IDs to attach'),
          milestone: z.number().optional().describe('Milestone ID'),
          token: tokenSchema,
        }),
      },
      async (args) => {
        try {
          const result = await PullRequestTools.createPullRequest(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 schema for input validation of gitea_pr_create tool parameters.
    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'),
      title: z.string().min(1).describe('PR title'),
      body: z.string().optional().describe('PR body/description'),
      head: z.string().min(1).describe('Branch name to merge from'),
      base: z.string().min(1).describe('Branch name to merge into'),
      assignees: z.array(z.string()).optional().describe('Usernames to assign'),
      labels: z.array(z.number()).optional().describe('Label IDs to attach'),
      milestone: z.number().optional().describe('Milestone ID'),
      token: tokenSchema,
    }),
  • src/index.ts:121-121 (registration)
    Top-level call to register PR tools (including gitea_pr_create) during server initialization.
    registerPullRequestTools(mcpServer, toolContext);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only mentions 'AI-assisted PR creation with smart content generation' without explaining what this means operationally. It doesn't disclose authentication requirements, rate limits, error conditions, or what happens when a PR is created (e.g., notifications, status changes). The description adds minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief (two sentences) and front-loaded with the core purpose. However, the second sentence about 'AI-assisted PR creation' is somewhat vague and doesn't clearly earn its place by providing concrete guidance or differentiation.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 10 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the return value, error handling, authentication needs, or how the 'AI-assisted' aspect works. Given the complexity and lack of structured data, the description should provide more complete operational context.

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 10 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema, maintaining the baseline score of 3 for adequate but not enhanced parameter documentation.

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 tool's purpose as 'Create a new pull request' which is a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'gitea_issue_create' beyond mentioning 'AI-assisted PR creation' which is somewhat vague rather than explicit differentiation.

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

Usage Guidelines2/5

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

The description provides minimal guidance with 'Use this tool for AI-assisted PR creation with smart content generation' but doesn't specify when to use this versus alternatives like 'gitea_issue_create' or other workflow tools. No explicit when-not-to-use scenarios or prerequisites are mentioned.

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