Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

search_code

Search for code across all repositories in a Bitbucket Cloud workspace to find specific code snippets, functions, or patterns.

Instructions

Search for code across all repositories in a workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
search_queryYesSearch query string
pageNoPage number
pagelenNoResults per page

Implementation Reference

  • The core handler function that performs the Bitbucket API call to search for code in a workspace.
    async searchCode(params: SearchCodeParams): Promise<PaginatedResponse<BitbucketSearchResult>> {
      const { workspace, search_query, ...queryParams } = params;
      return this.client.get<PaginatedResponse<BitbucketSearchResult>>(
        `/workspaces/${workspace}/search/code`,
        {
          search_query,
          ...queryParams,
        } as Record<string, string | number | undefined>
      );
    }
  • Registration of the 'search_code' tool in the toolDefinitions array for MCP, including name, description, and inputSchema.
    {
      name: 'search_code',
      description: 'Search for code across all repositories in a workspace.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          workspace: { type: 'string', description: 'The workspace slug' },
          search_query: { type: 'string', description: 'Search query string' },
          page: { type: 'number', description: 'Page number' },
          pagelen: { type: 'number', description: 'Results per page' },
        },
        required: ['workspace', 'search_query'],
      },
    },
  • Zod schema used for input validation and parsing in the tool handler.
    search_code: z.object({
      workspace: z.string().describe('The workspace slug'),
      search_query: z.string().describe('Search query string'),
      page: z.number().optional().describe('Page number'),
      pagelen: z.number().optional().describe('Results per page'),
    }),
  • Dispatcher logic in ToolHandler.handleTool that parses arguments and delegates to the SearchAPI.searchCode method.
    case 'search_code': {
      const params = toolSchemas.search_code.parse(args);
      return this.search.searchCode(params);
    }
  • TypeScript interface defining the parameters for the search_code tool.
    export interface SearchCodeParams {
      workspace: string;
      search_query: string;
      page?: number;
      pagelen?: number;
    }
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. It states the tool searches code, implying a read-only operation, but doesn't describe key behaviors like pagination handling (implied by 'page' and 'pagelen' parameters but not explained), rate limits, authentication needs, error conditions, or what the search results include (e.g., file paths, snippets). This is a significant gap for a search tool with no annotation coverage.

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 a single, clear sentence that efficiently conveys the core purpose without any wasted words. It's front-loaded with the main action and scope, making it easy to understand at a glance.

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 complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavior (e.g., pagination, result format), usage context, and doesn't compensate for the absence of structured output information, making it inadequate for effective tool selection and invocation.

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 (workspace, search_query, page, pagelen) with basic descriptions. The description adds no additional meaning beyond implying a workspace context and search functionality, which is already covered by 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.

Purpose4/5

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

The description clearly states the action ('Search for code') and scope ('across all repositories in a workspace'), which is specific and distinguishes it from sibling tools that operate on specific resources like branches, issues, or pull requests. However, it doesn't explicitly differentiate from potential similar search tools (none are listed among siblings), so it's not a perfect 5.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a workspace), exclusions, or compare it to other search-related tools (none are listed, but general context like 'use this for code search vs. issue search' is missing).

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

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