get_project
Retrieve a specific Bitbucket project using its unique key to access project details and manage repository information directly from your workspace.
Instructions
Get a single project by its key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_key | Yes | The key of the project. |
Implementation Reference
- src/tools/projects/getProject.ts:19-67 (handler)The core handler function that executes the get_project tool: validates input, fetches project data from Bitbucket API, formats details, and returns formatted text content or error.export async function getProject( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const { project_key } = args; if (!project_key) { throw new Error('Project key is required'); } console.error(`Fetching project: ${project_key}`); const response = await axiosInstance.get<BitbucketProject>( `/workspaces/${config.BITBUCKET_WORKSPACE}/projects/${project_key}` ); const project = response.data; const projectDetails = `**Project Details: ${project.name}** - Key: ${project.key} - Description: ${project.description || 'No description'} - Private: ${project.is_private} - Created: ${new Date(project.created_on).toLocaleDateString()} - Updated: ${new Date(project.updated_on).toLocaleDateString()} - URL: ${project.links.html.href}`; return { content: [ { type: 'text', text: projectDetails, }, ], }; } catch (error) { console.error('Error fetching project:', error); return { content: [ { type: 'text', text: `Error fetching project: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
- Defines the tool metadata including name 'get_project', description, and input schema requiring 'project_key'.export const getProjectTool = { name: 'get_project', description: 'Get a single project by its key.', inputSchema: { type: 'object', properties: { project_key: { type: 'string', description: 'The key of the project.', }, }, required: ['project_key'], }, };
- src/index.ts:111-135 (registration)Registers getProjectTool in the list of available tools for ListToolsRequestHandler.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Repositories listRepositoriesTool, getRepositoryDetailsTool, // Commits listCommitsTool, getCommitTool, // Branching Model updateRepositoryBranchingModelSettingsTool, updateProjectBranchingModelSettingsTool, listBranchRestrictionsTool, getBranchRestrictionTool, // Projects getProjectTool, listDefaultReviewersTool, // Pull Requests listPullRequestsTool, getPullRequestTool, createPullRequestTool, updatePullRequestTool, // Workspaces listWorkspacesTool, ], }));
- src/index.ts:142-173 (registration)Maps the 'get_project' tool name to the getProject handler function in the CallToolRequestHandler.const handlers: Record< string, ( axiosInstance: AxiosInstance, config: Config, args: any ) => Promise<{ content: Array<{ type: string; text: string }> }> > = { // Repositories list_repositories: listRepositories, get_repository_details: getRepositoryDetails, // Commits list_commits: listCommits, get_commit: getCommit, // Branching Model update_repository_branching_model_settings: updateRepositoryBranchingModelSettings, update_project_branching_model_settings: updateProjectBranchingModelSettings, list_branch_restrictions: listBranchRestrictions, get_branch_restriction: getBranchRestriction, // Projects get_project: getProject, list_default_reviewers: listDefaultReviewers, // Pull Requests list_pull_requests: listPullRequests, get_pull_request: getPullRequest, create_pull_request: createPullRequest, update_pull_request: updatePullRequest, // Workspaces list_workspaces: listWorkspaces, };
- src/index.ts:46-46 (registration)Imports the getProject handler and getProjectTool schema from the tool module.import { getProject, getProjectTool } from './tools/projects/getProject.js';