get_git_repository
Retrieve details of a specific Git repository by providing project ID, project key, repository ID or name. Returns information such as name, URL, and description.
Instructions
Returns information about a specific Git repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The numeric ID of the project (e.g., 12345) | |
| projectKey | No | The key of the project (e.g., 'PROJECT') | |
| repoId | No | Repository ID | |
| repoName | No | Repository name | |
| organization | No | Optional organization name. Use list_organizations to inspect available organizations. |
Implementation Reference
- src/tools/getGitRepository.ts:52-70 (handler)The handler function for the 'get_git_repository' tool. It resolves the project (by ID or key) and repository (by ID or name), then calls backlog.getGitRepository().
handler: async ({ projectId, projectKey, repoId, repoName }) => { const result = resolveIdOrKey( 'project', { id: projectId, key: projectKey }, t ); if (!result.ok) { throw result.error; } const repoResult = resolveIdOrName( 'repository', { id: repoId, name: repoName }, t ); if (!repoResult.ok) { throw repoResult.error; } return backlog.getGitRepository(result.value, String(repoResult.value)); }, - src/tools/getGitRepository.ts:8-35 (schema)Input schema defined via buildToolSchema: accepts projectId (number, optional), projectKey (string, optional), repoId (number, optional), repoName (string, optional). At least one of projectId or projectKey must be provided, and one of repoId or repoName.
const getGitRepositorySchema = buildToolSchema((t) => ({ projectId: z .number() .optional() .describe( t( 'TOOL_GET_GIT_REPOSITORY_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)' ) ), projectKey: z .string() .optional() .describe( t( 'TOOL_GET_GIT_REPOSITORY_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')" ) ), repoId: z .number() .optional() .describe(t('TOOL_GET_GIT_REPOSITORY_REPO_ID', 'Repository ID')), repoName: z .string() .optional() .describe(t('TOOL_GET_GIT_REPOSITORY_REPO_NAME', 'Repository name')), })); - Output schema (GitRepositorySchema) defining the shape of the returned Git repository object with fields: id, projectId, name, description, hookUrl, httpUrl, sshUrl, displayOrder, pushedAt, createdUser, created, updatedUser, updated.
export const GitRepositorySchema = z.object({ id: z.number(), projectId: z.number(), name: z.string(), description: z.string(), hookUrl: z.string().optional(), httpUrl: z.string(), sshUrl: z.string(), displayOrder: z.number(), pushedAt: z.string().optional(), createdUser: UserSchema, created: z.string(), updatedUser: UserSchema, updated: z.string(), }); - src/tools/tools.ts:17-143 (registration)Import and registration of getGitRepositoryTool. Imported at line 17 and registered as part of the 'git' toolset (line 143) in the allTools function.
import { getGitRepositoryTool } from './getGitRepository.js'; import { getIssueTool } from './getIssue.js'; import { getIssueCommentsTool } from './getIssueComments.js'; import { getIssuesTool } from './getIssues.js'; import { getIssueTypesTool } from './getIssueTypes.js'; import { getMyselfTool } from './getMyself.js'; import { getNotificationsTool } from './getNotifications.js'; import { getNotificationsCountTool } from './getNotificationsCount.js'; import { getPrioritiesTool } from './getPriorities.js'; import { getProjectTool } from './getProject.js'; import { getProjectListTool } from './getProjectList.js'; import { getPullRequestTool } from './getPullRequest.js'; import { getPullRequestCommentsTool } from './getPullRequestComments.js'; import { getPullRequestsTool } from './getPullRequests.js'; import { getPullRequestsCountTool } from './getPullRequestsCount.js'; import { getResolutionsTool } from './getResolutions.js'; import { getSpaceTool } from './getSpace.js'; import { getSpaceActivitiesTool } from './getSpaceActivities.js'; import { getUserStarsCountTool } from './getUserStarsCount.js'; import { getUsersTool } from './getUsers.js'; import { getUserRecentUpdatesTool } from './getUserRecentUpdates.js'; import { getWatchingListCountTool } from './getWatchingListCount.js'; import { getWatchingListItemsTool } from './getWatchingListItems.js'; import { addWatchingTool } from './addWatching.js'; import { updateWatchingTool } from './updateWatching.js'; import { deleteWatchingTool } from './deleteWatching.js'; import { markWatchingAsReadTool } from './markWatchingAsRead.js'; import { getWikiTool } from './getWiki.js'; import { getWikiPagesTool } from './getWikiPages.js'; import { getWikisCountTool } from './getWikisCount.js'; import { markNotificationAsReadTool } from './markNotificationAsRead.js'; import { resetUnreadNotificationCountTool } from './resetUnreadNotificationCount.js'; import { updateIssueTool } from './updateIssue.js'; import { updateProjectTool } from './updateProject.js'; import { updatePullRequestTool } from './updatePullRequest.js'; import { updatePullRequestCommentTool } from './updatePullRequestComment.js'; import { getDocumentTool } from './getDocument.js'; import { getDocumentsTool } from './getDocuments.js'; import { getDocumentTreeTool } from './getDocumentTree.js'; import { getVersionMilestoneListTool } from './getVersionMilestoneList.js'; import { addVersionMilestoneTool } from './addVersionMilestone.js'; import { updateVersionMilestoneTool } from './updateVersionMilestone.js'; import { deleteVersionTool } from './deleteVersion.js'; import { addDocumentTool } from './addDocument.js'; export const allTools = ( backlog: Backlog, helper: TranslationHelper ): ToolsetGroup => { return { toolsets: [ { name: 'space', description: 'Tools for managing Backlog space settings and general information.', enabled: false, tools: [ getSpaceTool(backlog, helper), getSpaceActivitiesTool(backlog, helper), getUsersTool(backlog, helper), getUserStarsCountTool(backlog, helper), getMyselfTool(backlog, helper), getUserRecentUpdatesTool(backlog, helper), ], }, { name: 'project', description: 'Tools for managing projects, categories, custom fields, and issue types.', enabled: false, tools: [ getProjectListTool(backlog, helper), addProjectTool(backlog, helper), getProjectTool(backlog, helper), updateProjectTool(backlog, helper), deleteProjectTool(backlog, helper), ], }, { name: 'issue', description: 'Tools for managing issues and their comments.', enabled: false, tools: [ getIssueTool(backlog, helper), getIssuesTool(backlog, helper), countIssuesTool(backlog, helper), addIssueTool(backlog, helper), updateIssueTool(backlog, helper), deleteIssueTool(backlog, helper), getIssueCommentsTool(backlog, helper), addIssueCommentTool(backlog, helper), getPrioritiesTool(backlog, helper), getCategoriesTool(backlog, helper), getCustomFieldsTool(backlog, helper), getIssueTypesTool(backlog, helper), getResolutionsTool(backlog, helper), getWatchingListItemsTool(backlog, helper), getWatchingListCountTool(backlog, helper), addWatchingTool(backlog, helper), updateWatchingTool(backlog, helper), deleteWatchingTool(backlog, helper), markWatchingAsReadTool(backlog, helper), getVersionMilestoneListTool(backlog, helper), addVersionMilestoneTool(backlog, helper), updateVersionMilestoneTool(backlog, helper), deleteVersionTool(backlog, helper), ], }, { name: 'wiki', description: 'Tools for managing wiki pages.', enabled: false, tools: [ getWikiPagesTool(backlog, helper), getWikisCountTool(backlog, helper), getWikiTool(backlog, helper), addWikiTool(backlog, helper), updateWikiTool(backlog, helper), ], }, { name: 'git', description: 'Tools for managing Git repositories and pull requests.', enabled: false, tools: [ getGitRepositoriesTool(backlog, helper), getGitRepositoryTool(backlog, helper), - src/utils/resolveIdOrKey.ts:22-65 (helper)Helper functions resolveIdOrKey and resolveIdOrName used by the handler to resolve project (by id or key) and repository (by id or name) identifiers.
function resolveIdOrField<E extends EntityName, F extends string>( entity: E, fieldName: F, values: ResolveIdOrFieldInput<F>, t: TranslationHelper['t'] ): ResolveResult { const value = tryResolveIdOrField(fieldName, values); if (value === undefined) { return { ok: false, error: new Error( t( `${entity.toUpperCase()}_ID_OR_${fieldName.toUpperCase()}_REQUIRED`, `${capitalize(entity)} ID or ${fieldName} is required` ) ), }; } return { ok: true, value }; } function tryResolveIdOrField<F extends string>( fieldName: F, values: ResolveIdOrFieldInput<F> ): string | number | undefined { return values.id !== undefined ? values.id : values[fieldName]; } export const resolveIdOrKey = <E extends EntityName>( entity: E, values: { id?: number; key?: string }, t: TranslationHelper['t'] ): ResolveResult => resolveIdOrField(entity, 'key', values, t); export const resolveIdOrName = <E extends EntityName>( entity: E, values: { id?: number; name?: string }, t: TranslationHelper['t'] ): ResolveResult => resolveIdOrField(entity, 'name', values, t); function capitalize(str: string): string { return str.charAt(0).toUpperCase() + str.slice(1); }