bitbucket-mcp-server-rahul
v1.0.0
Published
MCP Server for Bitbucket Cloud API integration
Maintainers
Readme
Bitbucket MCP Server
A comprehensive Model Context Protocol (MCP) server for integrating with Bitbucket Cloud API. This server provides AI systems with seamless access to Bitbucket repositories, pull requests, issues, branches, commits, and more.
Features
Repository Management
- List repositories in workspaces
- Get detailed repository information
- Create new repositories
- Search repositories
- Update repository settings
- Delete repositories
Branch Management
- List branches in repositories
- Get branch details
- Create new branches
- Delete branches
Commit Management
- List commits in repositories
- Get detailed commit information
- Filter commits by branch
File Management
- Read file contents
- List directory contents
- Update files
- Delete files
Pull Request Management
- List pull requests
- Get pull request details
- Create new pull requests
- Update pull requests
- Merge pull requests
- Decline pull requests
- Manage pull request comments
Issue Management
- List issues in repositories
- Get issue details
- Create new issues
- Update issues
- Manage issue comments
User and Workspace Management
- Get current user information
- List accessible workspaces
- Get workspace details
Search and Utility
- Search code across repositories
- Get repository statistics
- Manage webhooks
- Fork repositories
Installation
- Clone this repository:
git clone <repository-url>
cd bitbucket-mcp-server- Install dependencies:
npm install- Build the project:
npm run buildConfiguration
- Copy the example environment file:
cp env.example .env- Configure your Bitbucket credentials in
.env. Choose one of the authentication methods below:
Authentication Methods
Option 1: OAuth 2.0 (Recommended for Production)
OAuth 2.0 provides the most secure and flexible authentication method.
Create an OAuth Consumer:
- Go to your Bitbucket workspace settings
- Navigate to "OAuth consumers" under "Access management"
- Create a new consumer with appropriate scopes
- See OAuth Setup Guide for detailed instructions
Configure OAuth in
.env:
# OAuth 2.0 Configuration
BITBUCKET_CLIENT_ID=your-oauth-client-id
BITBUCKET_CLIENT_SECRET=your-oauth-client-secret
BITBUCKET_REDIRECT_URI=http://localhost:3000/oauth/callback
BITBUCKET_SCOPES=repository:read,repository:write,pullrequest:read,pullrequest:write,issue:read,issue:write,account:read
# Optional: Direct access token (if you already have one)
BITBUCKET_ACCESS_TOKEN=your-oauth-access-token
BITBUCKET_REFRESH_TOKEN=your-oauth-refresh-tokenOption 2: App Password (Simple Setup)
Go to your Bitbucket account settings
Navigate to "App passwords" under "Access management"
Create a new app password with the required scopes:
- Repositories: Read, Write
- Pull requests: Read, Write
- Issues: Read, Write
- Account: Read
Configure App Password in
.env:
# Basic Authentication
BITBUCKET_USERNAME=your-username
BITBUCKET_APP_PASSWORD=your-app-password
# OR use API token instead of app password
BITBUCKET_API_TOKEN=your-api-tokenOption 3: API Token
- Go to your Bitbucket account settings
- Navigate to "Personal access tokens"
- Create a new token with appropriate permissions
Usage
Running the Server
# Development mode
npm run dev
# Production mode
npm startMCP Client Configuration
Add the server to your MCP client configuration:
{
"mcpServers": {
"bitbucket": {
"command": "node",
"args": ["/path/to/bitbucket-mcp-server/dist/index.js"],
"env": {
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_APP_PASSWORD": "your-app-password",
"BITBUCKET_WORKSPACE": "your-workspace"
}
}
}
}Available Tools
User and Workspace Management
get_current_user- Get current user informationget_workspace- Get workspace detailsget_workspaces- List all accessible workspaces
Repository Management
get_repositories- List repositories in a workspaceget_repository- Get repository detailscreate_repository- Create a new repositorysearch_repositories- Search repositories by query
Branch Management
get_branches- List branches in a repositoryget_branch- Get branch detailscreate_branch- Create a new branch
Commit Management
get_commits- List commits in a repositoryget_commit- Get commit details
File Management
get_file_content- Read file contentsget_directory_contents- List directory contents
Pull Request Management
get_pull_requests- List pull requestsget_pull_request- Get pull request detailscreate_pull_request- Create a new pull requestmerge_pull_request- Merge a pull request
Issue Management
get_issues- List issues in a repositoryget_issue- Get issue detailscreate_issue- Create a new issue
Search and Utility
search_code- Search code across repositories
OAuth 2.0 Management
generate_oauth_url- Generate OAuth authorization URLexchange_oauth_code- Exchange authorization code for access tokenrefresh_oauth_token- Refresh OAuth access tokenvalidate_oauth_token- Validate OAuth access tokenrevoke_oauth_token- Revoke OAuth access tokenget_oauth_user_info- Get user information using OAuth token
API Reference
The server implements the Bitbucket Cloud REST API v2. For detailed information about the API endpoints and data structures, refer to the official Bitbucket API documentation.
Error Handling
The server includes comprehensive error handling for:
- Authentication failures
- Network connectivity issues
- API rate limiting
- Invalid parameters
- Resource not found errors
All errors are returned with descriptive messages to help with debugging.
Development
Project Structure
src/
├── index.ts # Main MCP server implementation
├── bitbucket-client.ts # Bitbucket API client
└── types.ts # TypeScript type definitionsBuilding
npm run buildTesting
npm testContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check the Bitbucket API documentation
- Review the error messages in the server logs
- Open an issue in this repository
Changelog
v1.0.0
- Initial release
- Complete Bitbucket Cloud API integration
- Support for repositories, branches, commits, pull requests, issues
- User and workspace management
- Search functionality
