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
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| search_query | Yes | Search query string | |
| page | No | Page number | |
| pagelen | No | Results per page |
Implementation Reference
- src/api/search.ts:10-19 (handler)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> ); }
- src/tools/index.ts:847-860 (registration)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'], }, },
- src/tools/index.ts:289-294 (schema)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'), }),
- src/tools/index.ts:1078-1081 (helper)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); }
- src/types/index.ts:371-376 (schema)TypeScript interface defining the parameters for the search_code tool.export interface SearchCodeParams { workspace: string; search_query: string; page?: number; pagelen?: number; }