Skip to main content
Glama

create_pull_request

Create a new pull request in Bitbucket by specifying repository, title, source branch, and optional destination branch and description to facilitate code review and merging.

Instructions

Create a new pull request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoThe description of the pull request.
destination_branchNoThe destination branch of the pull request.
repository_nameYesName of the repository (repo slug)
source_branchYesThe source branch of the pull request.
titleYesThe title of the pull request.

Implementation Reference

  • The main handler function that executes the tool logic: validates inputs, makes POST request to Bitbucket API to create PR, formats success/error response.
    export async function createPullRequest( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const { repository_name, title, source_branch, destination_branch, description, } = args; if (!repository_name || !title || !source_branch) { throw new Error( 'Repository name, title, and source branch are required' ); } console.error(`Creating pull request in repository: ${repository_name}`); const response = await axiosInstance.post<PullRequest>( `/repositories/${config.BITBUCKET_WORKSPACE}/${repository_name}/pullrequests`, { title: title, source: { branch: { name: source_branch, }, }, destination: { branch: { name: destination_branch, }, }, description: description, } ); const pr = response.data; const prDetails = `**Successfully created PR #${pr.id}: ${pr.title}** - State: ${pr.state} - Author: ${pr.author.display_name} - Source: ${pr.source.branch.name} - Destination: ${pr.destination.branch.name} - URL: ${pr.links.html.href}`; return { content: [ { type: 'text', text: prDetails, }, ], }; } catch (error) { console.error('Error creating pull request:', error); return { content: [ { type: 'text', text: `Error creating pull request: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
  • Defines the tool metadata: name 'create_pull_request', description, and inputSchema with properties and required fields.
    export const createPullRequestTool = { name: 'create_pull_request', description: 'Create a new pull request.', inputSchema: { type: 'object', properties: { repository_name: { type: 'string', description: 'Name of the repository (repo slug)', }, title: { type: 'string', description: 'The title of the pull request.', }, source_branch: { type: 'string', description: 'The source branch of the pull request.', }, destination_branch: { type: 'string', description: 'The destination branch of the pull request.', }, description: { type: 'string', description: 'The description of the pull request.', }, }, required: ['repository_name', 'title', 'source_branch'], }, };
  • src/index.ts:149-173 (registration)
    Maps tool name 'create_pull_request' to its handler function in the CallToolRequest handler.
    > = { // Repositories list_repositories: listRepositories, get_repository_details: getRepositoryDetails, // Commits list_commits: listCommits, get_commit: getCommit, // Branching Model update_repository_branching_model_settings: updateRepositoryBranchingModelSettings, update_project_branching_model_settings: updateProjectBranchingModelSettings, list_branch_restrictions: listBranchRestrictions, get_branch_restriction: getBranchRestriction, // Projects get_project: getProject, list_default_reviewers: listDefaultReviewers, // Pull Requests list_pull_requests: listPullRequests, get_pull_request: getPullRequest, create_pull_request: createPullRequest, update_pull_request: updatePullRequest, // Workspaces list_workspaces: listWorkspaces, };
  • src/index.ts:112-134 (registration)
    Registers createPullRequestTool in the list of tools returned by ListToolsRequest.
    tools: [ // Repositories listRepositoriesTool, getRepositoryDetailsTool, // Commits listCommitsTool, getCommitTool, // Branching Model updateRepositoryBranchingModelSettingsTool, updateProjectBranchingModelSettingsTool, listBranchRestrictionsTool, getBranchRestrictionTool, // Projects getProjectTool, listDefaultReviewersTool, // Pull Requests listPullRequestsTool, getPullRequestTool, createPullRequestTool, updatePullRequestTool, // Workspaces listWorkspacesTool, ],
  • src/index.ts:62-64 (registration)
    Imports the handler and tool definition from the implementation file.
    createPullRequest, createPullRequestTool, } from './tools/pull-requests/createPullRequest.js';

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/Korfu/mcp-bitbucket'

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