Skip to main content
Glama
garc33

Bitbucket Server MCP

by garc33

browse_repository

Explore Bitbucket repository structure to list files and directories, helping users navigate codebases and locate specific files efficiently.

Instructions

Browse and list files and directories in a Bitbucket repository. Use this to explore repository structure, find files, or navigate directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNoBitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable.
repositoryYesRepository slug to browse.
pathNoDirectory path to browse (empty or "/" for root directory).
branchNoBranch or commit hash to browse (defaults to main/master branch if not specified).
limitNoMaximum number of items to return (default: 50).

Implementation Reference

  • Core handler function that implements the browse_repository tool by calling Bitbucket's /browse API endpoint to list files and directories in a repository path, with support for branch specification and pagination.
    private async browseRepository(options: { project: string; repository: string; path?: string; branch?: string; limit?: number }) {
      const { project, repository, path = '', branch, limit = 50 } = options;
      
      if (!project || !repository) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Project and repository are required'
        );
      }
    
      const params: Record<string, string | number> = {
        limit
      };
    
      if (branch) {
        params.at = branch;
      }
    
      const browsePath = path ? `/${path}` : '';
      const response = await this.api.get(
        `/projects/${project}/repos/${repository}/browse${browsePath}`,
        { params }
      );
    
      const children = response.data.children || {};
      const browseResults = {
        project,
        repository,
        path: path || 'root',
        branch: branch || response.data.revision || 'default',
        isLastPage: children.isLastPage || false,
        size: children.size || 0,
        showing: children.values?.length || 0,
        items: children.values?.map((item: { 
          path: { name: string; toString: string }; 
          type: string; 
          size?: number 
        }) => ({
          name: item.path.name,
          path: item.path.toString,
          type: item.type,
          size: item.size
        })) || []
      };
    
      return {
        content: [{ type: 'text', text: JSON.stringify(browseResults, null, 2) }]
      };
    }
  • Input schema/JSON Schema definition for the browse_repository tool parameters, specifying types, descriptions, and required fields.
    inputSchema: {
      type: 'object',
      properties: {
        project: { type: 'string', description: 'Bitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable.' },
        repository: { type: 'string', description: 'Repository slug to browse.' },
        path: { type: 'string', description: 'Directory path to browse (empty or "/" for root directory).' },
        branch: { type: 'string', description: 'Branch or commit hash to browse (defaults to main/master branch if not specified).' },
        limit: { type: 'number', description: 'Maximum number of items to return (default: 50).' }
      },
      required: ['repository']
    }
  • src/index.ts:379-393 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema for browse_repository.
    {
      name: 'browse_repository',
      description: 'Browse and list files and directories in a Bitbucket repository. Use this to explore repository structure, find files, or navigate directories.',
      inputSchema: {
        type: 'object',
        properties: {
          project: { type: 'string', description: 'Bitbucket project key. If omitted, uses BITBUCKET_DEFAULT_PROJECT environment variable.' },
          repository: { type: 'string', description: 'Repository slug to browse.' },
          path: { type: 'string', description: 'Directory path to browse (empty or "/" for root directory).' },
          branch: { type: 'string', description: 'Branch or commit hash to browse (defaults to main/master branch if not specified).' },
          limit: { type: 'number', description: 'Maximum number of items to return (default: 50).' }
        },
        required: ['repository']
      }
    }
  • src/index.ts:569-577 (registration)
    Dispatch case in the central CallToolRequestSchema switch statement that routes calls to the browseRepository handler.
    case 'browse_repository': {
      return await this.browseRepository({
        project: getProject(args.project as string),
        repository: args.repository as string,
        path: args.path as string,
        branch: args.branch as string,
        limit: args.limit as number
      });
    }
  • src/index.ts:162-162 (registration)
    Inclusion of browse_repository in the readOnlyTools list, allowing it in read-only mode.
    const readOnlyTools = ['list_projects', 'list_repositories', 'get_pull_request', 'get_diff', 'get_reviews', 'get_activities', 'get_comments', 'search', 'get_file_content', 'browse_repository'];
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the tool's purpose, it lacks details on behavioral traits such as pagination behavior (implied by the 'limit' parameter but not explained), error handling, authentication requirements, or rate limits. This is a significant gap for a tool with multiple parameters and no annotations.

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 appropriately sized and front-loaded, with two concise sentences that directly state the tool's purpose and usage context. Every sentence earns its place without redundancy or unnecessary elaboration.

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?

Given the tool's moderate complexity (5 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and usage but lacks behavioral details (e.g., output format, error cases) that would help an agent use it effectively. Without annotations or an output schema, more context is needed for full completeness.

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?

The schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description does not add any additional meaning or context beyond what the schema provides (e.g., it doesn't explain parameter interactions or default values beyond the schema). Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose with specific verbs ('browse and list') and resources ('files and directories in a Bitbucket repository'). It distinguishes this from sibling tools like 'get_file_content' (which retrieves content) or 'search' (which searches across repositories) by focusing on structural exploration.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('to explore repository structure, find files, or navigate directories'), but it does not explicitly state when not to use it or name specific alternatives. For example, it doesn't clarify that 'get_file_content' should be used for reading file contents instead of this tool.

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

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

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