search_code
Search for code across all repositories in a Bitbucket Cloud workspace to find specific functions, variables, 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/tools/index.ts:1076-1079 (handler)Handler for 'search_code' tool in ToolHandler.handleTool method, parses args and delegates to SearchAPI.searchCodecase 'search_code': { const params = toolSchemas.search_code.parse(args); return this.search.searchCode(params); }
- src/api/search.ts:10-19 (helper)Core implementation of searchCode in SearchAPI class, makes API call to Bitbucket search endpointasync 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:289-294 (schema)Zod schema definition for search_code tool input parameterssearch_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:847-860 (registration)Registration of 'search_code' tool in the toolDefinitions export array for MCP{ 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/types/index.ts:369-374 (schema)TypeScript interface defining SearchCodeParams for type safetyexport interface SearchCodeParams { workspace: string; search_query: string; page?: number; pagelen?: number; }