Skip to main content
Glama

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
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name
refYesThe name of the fully qualified reference (e.g., refs/tags/v1.0.0)
shaYesThe SHA1 value to set this reference to

Implementation Reference

  • 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);
    }
  • 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),
    },
  • 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) }],
      };
    }
  • 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(),
      }),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server