get-story-branch-name
Generate a valid branch name for a specific Shortcut story by providing its public ID, streamlining version control workflows in project management.
Instructions
Get a valid branch name for a specific story.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| storyPublicId | Yes | The public Id of the story |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"storyPublicId": {
"description": "The public Id of the story",
"exclusiveMinimum": 0,
"type": "number"
}
},
"required": [
"storyPublicId"
],
"type": "object"
}
Implementation Reference
- src/tools/stories.ts:395-408 (handler)The handler function that fetches the story, gets the current user, and returns either the existing formatted VCS branch name or generates a new one using createBranchName.async getStoryBranchName(storyPublicId: number) { const currentUser = await this.client.getCurrentUser(); if (!currentUser) throw new Error("Unable to find current user"); const story = await this.client.getStory(storyPublicId); if (!story) throw new Error(`Failed to retrieve Shortcut story with public ID: ${storyPublicId}`); const branchName = (story as Story & { formatted_vcs_branch_name: string | null }).formatted_vcs_branch_name || this.createBranchName(currentUser, story); return this.toResult(`Branch name for story sc-${storyPublicId}: ${branchName}`); }
- src/tools/stories.ts:119-126 (registration)Registers the tool named 'stories-get-branch-name' with input schema and points to the getStoryBranchName handler.server.addToolWithReadAccess( "stories-get-branch-name", "Get a valid branch name for a specific story.", { storyPublicId: z.number().positive().describe("The public Id of the story"), }, async ({ storyPublicId }) => await tools.getStoryBranchName(storyPublicId), );
- src/tools/stories.ts:122-124 (schema)Input schema for the tool: requires storyPublicId as a positive number.{ storyPublicId: z.number().positive().describe("The public Id of the story"), },
- src/tools/stories.ts:388-393 (helper)Private helper that generates a branch name in the format '{mention_name}/sc-{id}/{slugified-name}' truncated to 50 chars.private createBranchName(currentUser: MemberInfo, story: Story) { return `${currentUser.mention_name}/sc-${story.id}/${story.name .toLowerCase() .replace(/\s+/g, "-") .replace(/[^\w-]/g, "")}`.substring(0, 50); }