Skip to main content
Glama
RajuSudhar

Atlassian Bitbucket MCP Server

by RajuSudhar

bitbucket_search_code

Search code across repositories in a Bitbucket project by providing a project key and search query, with options to limit results and paginate.

Instructions

Search code across repositories in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesProject key
queryYesSearch query
limitNoMax results
startNoPagination start

Implementation Reference

  • Main handler function for bitbucket_search_code. Parses args using searchCodeShape schema, requires 'search_code' permission, calls searchApi.searchCode(), and returns the result or an error.
    bitbucket_search_code: async (args: unknown): Promise<McpToolResult> => {
      const start = Date.now();
      try {
        const input = z.object(searchCodeShape).parse(args);
        requirePermission(config, 'search_code');
        log('info', 'tool start', { operation: 'tool_execute', toolName: 'bitbucket_search_code' });
        const result = await searchApi.searchCode(
          input.project,
          input.query,
          input.limit,
          input.start
        );
        log('info', 'tool end', {
          toolName: 'bitbucket_search_code',
          durationMs: Date.now() - start,
        });
        return textResult(result);
      } catch (err) {
        log('error', 'tool error', {
          toolName: 'bitbucket_search_code',
          error: String(err),
          durationMs: Date.now() - start,
        });
        return errorResult('SEARCH_CODE_FAILED', err instanceof Error ? err.message : String(err));
      }
    },
  • Input schema (ZodRawShape) for search_code: project, query, optional limit and start.
    export const searchCodeShape = {
      project,
      query: z.string().min(1).max(500).describe('Search query'),
      limit,
      start,
    } as const;
  • Tool registration entry pairing name='bitbucket_search_code', description, shape=searchCodeShape, and handler reference h.search.bitbucket_search_code.
    // --- Search tools ---
    {
      name: 'bitbucket_search_code',
      description: 'Search code across repositories in a project',
      shape: searchCodeShape,
      handler: h.search.bitbucket_search_code,
    },
  • Underlying API call: SearchApi.searchCode() that performs the HTTP GET to /projects/{project}/search/code with query, limit, start parameters.
    async searchCode(
      project: string,
      query: string,
      limit = 25,
      start = 0
    ): Promise<BitbucketSearchResult> {
      return this.client.requestJson<BitbucketSearchResult>(`/projects/${project}/search/code`, {
        queryParams: { query, limit, start },
      });
    }
Behavior2/5

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

No annotations provided, and the description does not disclose behavioral aspects like read-only nature, rate limits, or behavior on empty results. Minimal disclosure.

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

Conciseness4/5

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

Single sentence, front-loaded, no redundant information. Very concise, though could include a bit more context without harming conciseness.

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

Completeness2/5

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

Given the tool's simplicity (4 params, no output schema), the description is terse and omits details about return format, pagination, or search behavior. Incomplete for an AI agent.

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 coverage is 100% with descriptions for all parameters, so the description adds no additional meaning. Baseline of 3 is appropriate.

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 searches code across repositories in a project, using a specific verb (search) and resource (code). It distinguishes from siblings like bitbucket_search_commits which searches commits.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives such as bitbucket_search_commits, or when not to use it. Lacks context for selection.

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

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