Bitbucket CLI for AI Agents

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Bitbucket logo
CLI logo
divider

Introduction

CLIs are eating MCPs. The industry is converging on the very same idea. MCPs for all their merit can be token hungry, slow, and unreliable for complex tool chaining. However, coding agents have become incredibly good at working with CLIs, and in fact they are far more comfortable working with CLI tools than MCP.

With Composio's Universal CLI, your coding agents can talk to over 1000+ SaaS applications. With Bitbucket, agents can create a new branch off main, open a pull request for your feature, comment on the latest open issue, and more — all without worrying about authentication.

This guide walks you through Composio Universal CLI and explains how you can connect it with coding agents like Claude Code, Codex, OpenCode, etc, for end-to-end Bitbucket automation.

Also integrate Bitbucket with

What is Universal CLI and why use it?

The idea behind building the universal CLI is to give agents a single command interface to interact with all your external applications. Here's what you'll get with it:

  • Agent-friendly: Coding agents like Claude Code, Codex, and OpenCode can use CLI tools natively — no MCP setup required.
  • Authentication handled: Connect once via OAuth or API Key, and all CLI commands work with your credentials automatically.
  • Tool discovery: Search, inspect, and execute 20,000+ tools across 1000+ apps from one interface.
  • Trigger support: Use triggers to listen for events across your apps, powered by real-time webhooks or polling under the hood.
  • Type generation: Generate typed schemas for autocomplete and type safety in your projects.

Prerequisites

Install the Composio CLI, authenticate, and initialize your project:

bash
# Install the Composio CLI
curl -fsSL https://composio.dev/install | bash

# Authenticate with Composio
composio login

During login you'll be redirected to sign in page, finish the complete flow and you're all set.

Composio CLI authentication flow

Connecting Bitbucket to Coding Agents via Universal CLI

Once it is installed, it's essentially done. Claude Code, Codex, OpenCode, OpenClaw, or any other agent will be able to access the CLI. A few steps to give agents access to your apps.

  1. Launch your Coding Agent — Claude Code, Codex, OpenCode, anything you prefer.
  2. Prompt it to "Authenticate with Bitbucket"
  3. Complete the authentication and authorization flow and your Bitbucket integration is all set.
  4. Start asking anything you want.

Supported Tools & Triggers

Tools
Approve Pull RequestTool to approve a pull request as the authenticated user.
Browse repository pathTool to retrieve content for a file path or browse directory contents at a specified revision in a Bitbucket repository.
Create a branchCreates a new branch in a Bitbucket repository from a target commit hash; the branch name must be unique, adhere to Bitbucket's naming conventions, and not include the 'refs/heads/' prefix.
Create an issueCreates a new issue in a Bitbucket repository, setting the authenticated user as reporter; ensures assignee (if provided) has repository access, and that any specified milestone, version, or component IDs exist.
Create an issue commentAdds a new comment with markdown support to an existing Bitbucket issue.
Create a pull requestCreates a new pull request in a specified Bitbucket repository, ensuring the source branch exists and is distinct from the (optional) destination branch.
Create pull request commentCreates a new comment on a Bitbucket pull request.
Create commit report annotationsAdds multiple annotations to a commit report in bulk.
List commits from revision (POST)Tool to list commits from a revision using POST method.
Create repositoryCreates a new Bitbucket 'git' repository in a specified workspace, defaulting to the workspace's oldest project if `project_key` is not provided.
Create snippet commentPosts a new top-level comment or a threaded reply to an existing comment on a specified Bitbucket snippet.
Create team pipeline variableCreates a team-level pipeline configuration variable in Bitbucket.
Create user pipeline variableCreates a user-level pipeline variable for Bitbucket pipelines.
Delete commit commentPermanently deletes a specific comment on a commit.
Delete issuePermanently deletes a specific issue, identified by its `issue_id`, from the repository specified by `repo_slug` within the given `workspace`.
Delete pull request commentPermanently deletes a specific pull request comment (top-level, inline, or threaded reply).
Delete commit report annotationDeletes a single annotation matching the provided ID from a commit report.
Delete repositoryPermanently deletes a specified Bitbucket repository; this action is irreversible and does not affect forks.
Delete snippet watchStops watching a specific snippet.
Delete user pipeline variablePermanently deletes a user-level pipeline configuration variable identified by its UUID.
Get branchRetrieves detailed information about a specific branch in a Bitbucket repository.
Get Commit Build StatusGet a specific build status for a commit in Bitbucket.
Get Commit ChangesTool to retrieve a page of changes made in a specified commit, showing all changed files with their change statistics (lines added/removed, status).
Get commit commentRetrieves a specific comment from a commit by its ID.
Get Commit DiffTool to retrieve the unified diff between two provided revisions or for a single commit in a Bitbucket repository.
Get current user (v2)Tool to retrieve complete profile information for the currently authenticated Bitbucket user.
Get deployment environment variablesRetrieves deployment environment level variables for a specific Bitbucket repository environment.
Get file from repositoryRetrieves a specific file's content from a Bitbucket repository at a given commit (hash, branch, or tag), failing if the file path is invalid for that commit.
Get hook eventsRetrieves a paginated list of all valid webhook events for a specified entity type (repository or workspace).
Get OpenID configuration for OIDC in PipelinesRetrieves the OpenID Connect discovery configuration for Bitbucket Pipelines OIDC.
Get Pull RequestGet a single pull request by ID with complete details.
Get pull request commentTool to retrieve a specific comment from a pull request by its ID.
Get Pull Request CommitsTool to retrieve commits for a specified pull request.
Get Pull Request DiffTool to fetch the unified diff for a Bitbucket pull request (follows 302 redirect to repository diff).
Get Pull Request DiffstatTool to get the diffstat for a Bitbucket pull request, showing all changed files with their change statistics (lines added/removed, status).
Get Repository Branching ModelReturn the branching model as applied to the repository.
Get Repository CommitTool to retrieve detailed information about a specific commit in a Bitbucket repository.
Get commit commentsRetrieves all comments on a specific commit in a Bitbucket repository.
Get commit reportReturns a single report matching the provided ID from a commit.
Get Commit ReportsTool to get reports linked to a specific commit.
Get commit report annotationReturns a single annotation matching the provided ID from a commit report.
Get commit statusesReturns all build statuses (e.
Get effective branching modelRetrieves the effective branching model for a Bitbucket repository, showing which branching model is currently applied (including any inheritance from project-level settings).
Get Repository EnvironmentRetrieve detailed information about a specific deployment environment in a Bitbucket repository.
Get file commit historyReturns a paginated list of commits that modified the specified file.
Check if user voted for issueTool to check whether the authenticated user has voted for a specific issue in a Bitbucket repository.
Get Repositories Merge BaseGet the merge base (best common ancestor) between two commits in a Bitbucket repository.
Get specific pipelineRetrieve a specified pipeline from a Bitbucket repository.
Get repository pipelines cachesRetrieves the repository pipelines caches.
Get repository pipeline runnersRetrieves the list of self-hosted runners configured for a repository's pipelines.
Get repository pipeline schedulesRetrieves configured pipeline schedules for a Bitbucket repository.
Get repository SSH known hostsRetrieves repository-level SSH known hosts configured for Bitbucket Pipelines.
Get repository pipeline variablesRetrieves repository-level pipeline variables for a specific Bitbucket repository.
Get pipeline stepsRetrieves all steps for a given pipeline.
Get pull requests activity logGet paginated activity log for all pull requests in a repository.
Get pull request commentsRetrieves a paginated list of comments on a specific pull request in a Bitbucket repository.
Get pull request statusesReturns all build statuses (e.
Get repository refsReturns the branches and tags in the repository.
Get tagRetrieves detailed information about a specific tag in a Bitbucket repository.
Get repositories srcLists the contents of the root directory on the repository's main branch without needing to specify a commit or branch.
Get repository watchersRetrieves a paginated list of all the watchers on the specified repository.
Get repositoryRetrieves detailed information about a specific repository in a Bitbucket workspace.
Get Repository PatchTool to retrieve the git patch content for a Bitbucket repository at a specified revision or commit range.
Get snippetRetrieves a specific Bitbucket snippet by its encoded ID from an existing workspace, returning its metadata and file structure.
Get snippet watch statusChecks if the current user is watching a specific snippet.
Get SSH keys for userRetrieves a paginated list of SSH keys for a specified Bitbucket user.
Get userRetrieves public profile information for a specific Bitbucket user by username or UUID.
Get user emailsReturns all the authenticated user's email addresses, both confirmed and unconfirmed.
Get user email detailsRetrieves details about a specific email address for the authenticated user.
Get user permissions for repositoriesReturns an object for each repository the caller has explicit access to, including their permission level.
Get user permissions for workspacesRetrieves workspace memberships and permission levels for the authenticated user.
Get user workspacesTool to retrieve all workspaces accessible to the authenticated user.
Get workspaceRetrieves detailed information about a specific Bitbucket workspace.
Get Workspace Pull Requests by UserTool to get all workspace pull requests authored by a specified user.
Search code in workspaceTool to search for code in the repositories of the specified workspace.
List branchesLists branches in a Bitbucket repository with optional server-side filtering by name pattern (BBQL) and sorting.
List commitsTool to retrieve a page of commits from a Bitbucket repository.
List commits from revisionTool to list commits starting from a specific revision in a Bitbucket repository.
List commits on masterLists commits on the master branch of a Bitbucket repository.
List deploymentsLists deployments for a specified Bitbucket repository.
List issues in a repositoryLists issues in a Bitbucket repository with optional filtering by state, priority, kind, or assignee.
List pipelinesTool to find pipelines in a Bitbucket repository.
List pull requestsLists pull requests in a specified, accessible Bitbucket repository, optionally filtering by state (OPEN, MERGED, DECLINED).
List pull request tasksLists all tasks associated with a pull request in a Bitbucket repository.
List all public repositoriesRetrieves a paginated list of all public repositories on Bitbucket.
List repository environmentsList all deployment environments configured for a Bitbucket repository.
List repositories in workspaceLists repositories in a specified Bitbucket workspace, accessible to the authenticated user, with options to filter by role or query string, and sort results.
List repository pathsLists file and directory entries under a repository path at a given revision, with optional breadth-first recursion via max_depth for repository traversal and scanning.
List snippetsReturns all snippets accessible to the authenticated user.
List tagsLists tags in a Bitbucket repository with optional server-side filtering by name pattern or commit hash (BBQL) and sorting.
List versionsLists versions (milestones) in a Bitbucket repository's issue tracker.
List workspace membersLists all members of a specified Bitbucket workspace; the workspace must exist.
List workspace projectsLists projects in a specified Bitbucket workspace.
List workspacesLists Bitbucket workspaces accessible to the authenticated user, optionally filtered and sorted.
Merge Pull RequestTool to merge a Bitbucket Cloud pull request via the REST API.
Request Pull Request ChangesTool to request changes on a pull request as the authenticated user.
Resolve pull request commentTool to resolve or reopen a pull request comment thread.
Search code in user repositoriesTool to search for code in the repositories of a specified user.
Update commit insight reportCreate or update an insight report for a commit.
Update an issueUpdates an existing issue in a Bitbucket repository by modifying specified attributes; requires `workspace`, `repo_slug`, `issue_id`, and at least one attribute to update.
Update Pull RequestTool to update an existing pull request's editable fields (e.
Update commit commentUpdates the contents of a comment on a commit.
Update commit report annotationCreates or updates an individual annotation for a commit report.
Update team pipeline variableUpdates a team-level pipeline configuration variable in Bitbucket.
Update user pipeline variableUpdates a user-level pipeline variable for Bitbucket pipelines.

Universal CLI Commands for Bitbucket

You can also manually execute CLI commands to interact with your Bitbucket.

Connect your Bitbucket account

Link your Bitbucket account and verify the connection:

bash
# Connect your Bitbucket account (opens OAuth flow)
composio connected-accounts link bitbucket

# Verify the connection
composio connected-accounts list --toolkits bitbucket

Discover Bitbucket tools

Search and inspect available Bitbucket tools:

bash
# List all available Bitbucket tools
composio tools list --toolkit bitbucket

# Search for Bitbucket tools by action
composio tools search "bitbucket"

# Inspect a tool's input schema
composio tools info BITBUCKET_CREATE_BRANCH

Common Bitbucket Actions

Create a branchCreates a new branch in a bitbucket repository from a target commit hash; the branch name must be unique, adhere to bitbucket's naming conventions, and not include the 'refs/heads/' prefix

bash
composio tools execute BITBUCKET_CREATE_BRANCH \
  --name "feature/new-branch" \
  --repo_slug "my-repo" \
  --workspace "my-workspace" \
  --target_hash "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0"

Create an issueCreates a new issue in a bitbucket repository, setting the authenticated user as reporter; ensures assignee (if provided) has repository access, and that any specified milestone, version, or component ids exist

bash
composio tools execute BITBUCKET_CREATE_ISSUE \
  --title "Bug: Login not working" \
  --content "Users are unable to log in when using Firefox browser" \
  --repo_slug "repo-name" \
  --workspace "workspace123"

Create an issue commentAdds a new comment with markdown support to an existing bitbucket issue

bash
composio tools execute BITBUCKET_CREATE_ISSUE_COMMENT \
  --content "This is a comment with **bold** text" \
  --issue_id "123" \
  --repo_slug "my-repo" \
  --workspace "my-workspace"

Create a pull requestCreates a new pull request in a specified bitbucket repository, ensuring the source branch exists and is distinct from the (optional) destination branch

bash
composio tools execute BITBUCKET_CREATE_PULL_REQUEST \
  --title "Feature: Add new login page" \
  --repo_slug "my-repo" \
  --workspace "my-workspace" \
  --source_branch "feature/login-page"

Generate Type Definitions

Generate typed schemas for Bitbucket tools to get autocomplete and type safety in your project:

bash
# Auto-detect language
composio generate --toolkits bitbucket

# TypeScript
composio ts generate --toolkits bitbucket

# Python
composio py generate --toolkits bitbucket

Tips & Tricks

  • Always inspect a tool's input schema before executing: composio tools info <TOOL_NAME>
  • Pipe output with jq for better readability: composio tools execute TOOL_NAME -d '{}' | jq
  • Set COMPOSIO_API_KEY as an environment variable for CI/CD pipelines
  • Use composio dev logs tools to inspect execution logs and debug issues

Next Steps

  • Try asking your coding agent to perform various Bitbucket operations
  • Explore cross-app workflows by connecting more toolkits
  • Set up triggers for real-time automation
  • Use composio generate for typed schemas in your projects

How to build Bitbucket MCP Agent with another framework

FAQ

What is the Composio Universal CLI?

The Composio Universal CLI is a single command-line interface that lets coding agents and developers interact with 1000+ SaaS applications. It handles authentication, tool discovery, action execution, and trigger setup — all from the terminal, without needing to configure MCP servers.

Which coding agents work with the Composio CLI?

Any coding agent that can run shell commands works with the Composio CLI — including Claude Code, Codex, OpenCode, OpenClaw, and others. Once the CLI is installed, agents automatically discover and use the composio commands to interact with Bitbucket and other connected apps.

How is the CLI different from using an MCP server for Bitbucket?

MCP servers require configuration and can be token-heavy for complex workflows. The CLI gives agents a direct, lightweight interface — no server setup needed. Agents simply call composio commands like any other shell tool. It's faster to set up, more reliable for multi-step tool chaining, and works natively with how coding agents already operate.

How safe is my Bitbucket data when using the Composio CLI?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Bitbucket data and credentials are handled as safely as possible. You can also bring your own OAuth credentials for full control.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.