create_tag
Create new tags in GitHub repositories to mark specific commits for versioning or releases.
Instructions
Create a new tag in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| ref | Yes | The name of the fully qualified reference (e.g., refs/tags/v1.0.0) | |
| 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 by making a POST request to GitHub's git/refs endpoint to create a tag reference pointing to the specified SHA.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 input schemas for the create_tag tool: public CreateTagSchema and internal _CreateTagSchema including 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)Registration of the create_tag tool in the MCP server's tool list, providing name, description, and input schema reference.{ 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 CallToolRequest switch statement that parses arguments and delegates to the releases.createTag implementation.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) }], }; }
- src/operations/releases.ts:43-52 (schema)Output schema (TagSchema) used by the createTag handler to validate the GitHub API response.export const TagSchema = z.object({ ref: z.string(), node_id: z.string(), url: z.string(), object: z.object({ sha: z.string(), type: z.string(), url: z.string(), }), });