create_tag
Generate a new tag in a GitHub repository by specifying the owner, repo, ref, and SHA. Streamlines version control and tracking for developers.
Instructions
Create a new tag in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| ref | Yes | The name of the fully qualified reference (e.g., refs/tags/v1.0.0) | |
| repo | Yes | Repository name | |
| sha | Yes | The SHA1 value to set this reference to |
Implementation Reference
- src/operations/releases.ts:228-251 (handler)The core handler function that implements the create_tag tool logic by creating a Git tag reference via the GitHub API.export async function createTag( github_pat: string, owner: string, repo: string, ref: string, sha: string ): Promise<z.infer<typeof TagSchema>> { // Ensure the ref is properly formatted const formattedRef = ref.startsWith("refs/") ? ref : `refs/tags/${ref}`; const response = await githubRequest( github_pat, `https://api.github.com/repos/${owner}/${repo}/git/refs`, { method: "POST", body: { ref: formattedRef, sha, }, } ); return TagSchema.parse(response); }
- src/operations/releases.ts:116-125 (schema)Zod schemas defining the input parameters for the create_tag tool, including public schema and internal version with github_pat.export const CreateTagSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), ref: z.string().describe("The name of the fully qualified reference (e.g., refs/tags/v1.0.0)"), sha: z.string().describe("The SHA1 value to set this reference to") }); export const _CreateTagSchema = CreateTagSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/index.ts:189-193 (registration)Tool registration in the list of available tools returned by ListToolsRequestSchema.{ name: "create_tag", description: "Create a new tag in a GitHub repository", inputSchema: zodToJsonSchema(releases.CreateTagSchema), },
- src/index.ts:578-585 (handler)Dispatch handler in the main CallToolRequestSchema switch that parses arguments and delegates to the releases.createTag function.case "create_tag": { const args = releases._CreateTagSchema.parse(params.arguments); const { github_pat, owner, repo, ref, sha } = args; const result = await releases.createTag(github_pat, owner, repo, ref, sha); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }