Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

bb_search_repositories

Search Bitbucket repositories by name, project key, language, or update date using Bitbucket's query syntax. Supports pagination and workspace-specific searches for efficient repository management.

Instructions

Search repositories in Bitbucket using Bitbucket's query syntax. Search by name (name ~ "pattern"), project key (project.key = "PROJ"), language (language = "python"), or dates (updated_on >= "2024-01-19"). NOTE: All dates must be in ISO 8601 format (YYYY-MM-DD). For searching files within repositories, use Bitbucket's code search in the web interface.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for pagination
pagelenNoNumber of results per page (max 100)
queryYesSearch query (e.g., 'name ~ "test"' or 'project.key = "PROJ"')
workspaceNoWorkspace to search in (defaults to kallows)kallows

Implementation Reference

  • The handler function within handle_call_tool that executes the bb_search_repositories tool by querying the Bitbucket API with the provided search parameters, formatting and returning the repository results.
    elif name == "bb_search_repositories":
        workspace = arguments.get("workspace", "kallows")
        query = arguments.get("query")
        page = arguments.get("page", 1)
        pagelen = min(arguments.get("pagelen", 10), 100)  # Cap at 100
    
        url = f"https://api.bitbucket.org/2.0/repositories/{workspace}"
        
        params = {
            'q': query,
            'page': page,
            'pagelen': pagelen
        }
        
        response = requests.get(url, params=params, auth=auth, headers=headers)
    
        if response.status_code == 200:
            repos = response.json()
            
            # Format the results nicely
            results = []
            for repo in repos.get('values', []):
                repo_info = {
                    'name': repo.get('name'),
                    'full_name': repo.get('full_name'),
                    'description': repo.get('description', 'No description'),
                    'created_on': repo.get('created_on'),
                    'updated_on': repo.get('updated_on'),
                    'size': repo.get('size', 0),
                    'language': repo.get('language', 'Unknown'),
                    'has_wiki': repo.get('has_wiki', False),
                    'is_private': repo.get('is_private', True),
                    'url': repo.get('links', {}).get('html', {}).get('href', '')
                }
                results.append(repo_info)
            
            # Add pagination info
            pagination = {
                'page': page,
                'pagelen': pagelen,
                'size': repos.get('size', 0),
                'next': 'next' in repos.get('links', {}),
                'previous': 'previous' in repos.get('links', {})
            }
            
            return [types.TextContent(
                type="text",
                text=f"Found {len(results)} repositories:\n\n" + 
                     '\n\n'.join([
                         f"• {r['name']}\n"
                         f"  Description: {r['description']}\n"
                         f"  Language: {r['language']}\n"
                         f"  URL: {r['url']}"
                         for r in results
                     ]) +
                     f"\n\nPage {pagination['page']} | "
                     f"Total results: {pagination['size']} | "
                     f"{'More results available' if pagination['next'] else 'End of results'}"
            )]
        else:
            return [types.TextContent(
                type="text",
                text=f"Failed to search repositories: {response.status_code}\n{format_permission_error(response.text)}",
                isError=True
            )]
  • The tool registration in handle_list_tools, defining the name, description, and input schema for bb_search_repositories.
    types.Tool(
        name="bb_search_repositories",
        description="Search repositories in Bitbucket using Bitbucket's query syntax. Search by name (name ~ \"pattern\"), project key (project.key = \"PROJ\"), language (language = \"python\"), or dates (updated_on >= \"2024-01-19\"). NOTE: All dates must be in ISO 8601 format (YYYY-MM-DD). For searching files within repositories, use Bitbucket's code search in the web interface.",
        inputSchema={
            "type": "object",
            "properties": {
                "workspace": {
                    "type": "string",
                    "description": "Workspace to search in (defaults to kallows)",
                    "default": "kallows"
                },
                "query": {
                    "type": "string",
                    "description": "Search query (e.g., 'name ~ \"test\"' or 'project.key = \"PROJ\"')"
                },
                "page": {
                    "type": "integer",
                    "description": "Page number for pagination",
                    "default": 1
                },
                "pagelen": {
                    "type": "integer",
                    "description": "Number of results per page (max 100)",
                    "default": 10
                }
            },
            "required": ["query"]
        }
    ),
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions date format requirements (ISO 8601) and pagination context (implied by parameters), but doesn't cover other important behaviors like rate limits, authentication needs, error handling, or what the response looks like. It's adequate but has clear gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with two sentences: the first states the purpose and key capabilities, the second provides important exclusions and alternatives. Every sentence earns its place with no wasted words, and critical information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 4 parameters, 100% schema coverage, but no annotations and no output schema, the description is moderately complete. It covers the core purpose and usage boundaries well, but lacks information about response format, error conditions, and other behavioral aspects that would help an agent use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema - it provides query syntax examples that align with the schema's description, but doesn't explain parameters like 'workspace' or 'pagelen' beyond what's already in the structured data.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Search repositories in Bitbucket') and resource ('repositories'), distinguishing it from sibling tools like bb_create_repository or bb_delete_repository. It explicitly mentions using Bitbucket's query syntax, which adds specificity beyond a generic search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool (searching repositories) and when not to use it (for searching files within repositories, directing users to Bitbucket's web interface instead). It also distinguishes from siblings by focusing on repository-level search rather than file operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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

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