Skip to main content
Glama

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

  • The main handler function `createPullRequest` that implements the logic for creating a Gitea pull request via API, using context-resolved owner/repo and various options.
    /** * 创建 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, }, }; }
  • Registers the 'gitea_pr_create' MCP tool, including title, description, Zod input schema, and a thin wrapper handler that delegates to the core createPullRequest function with error handling.
    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, }; } } );
  • src/index.ts:119-121 (registration)
    Top-level invocation of the PR tools registry during MCP server initialization, which registers gitea_pr_create among others.
    // 智能内容生成 (2个): gitea_issue_create, gitea_pr_create registerIssueTools(mcpServer, toolContext); registerPullRequestTools(mcpServer, toolContext);

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