create_pull_request
Create a new pull request in a GitHub repository to propose and review code changes before merging into the main branch.
Instructions
Create a new pull request in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| body | No | ||
| head | Yes | ||
| base | Yes | ||
| draft | No |
Implementation Reference
- The core handler function that creates a pull request using GitHub's Octokit REST API. This is the exact implementation of the tool logic.async createPullRequest(data: { title: string; body?: string; head: string; base: string; draft?: boolean; }): Promise<{ number: number; id: number; title: string; state: string; url: string }> { try { const octokit = this.factory.getOctokit(); const config = this.factory.getConfig(); const response = await octokit.rest.pulls.create({ owner: config.owner, repo: config.repo, title: data.title, body: data.body || '', head: data.head, base: data.base, draft: data.draft || false }); return { number: response.data.number, id: response.data.id, title: response.data.title, state: response.data.state, url: response.data.html_url }; } catch (error) { throw this.mapErrorToMCPError(error); } }
- ToolDefinition object defining the tool name, description, input schema (createPullRequestSchema), and examples.export const createPullRequestTool: ToolDefinition<CreatePullRequestArgs> = { name: "create_pull_request", description: "Create a new pull request in a GitHub repository", schema: createPullRequestSchema as unknown as ToolSchema<CreatePullRequestArgs>, examples: [ { name: "Create feature PR", description: "Create a pull request for a new feature", args: { title: "Add user authentication", body: "Implements OAuth 2.0 authentication with Auth0", head: "feature/auth", base: "main" } } ] };
- src/infrastructure/tools/ToolRegistry.ts:225-225 (registration)Registration of the createPullRequestTool in the central ToolRegistry singleton.this.registerTool(createPullRequestTool);
- src/index.ts:343-344 (handler)Dispatch handler in main MCP server that routes tool calls to ProjectManagementService.createPullRequest.case "create_pull_request": return await this.service.createPullRequest(args);