tag_create
Create and manage Git tags with a specified name, message, and options like force creation, annotation, or signing. Supports repository path input for precise tag management.
Instructions
Create a tag
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| annotated | No | Create an annotated tag | |
| force | No | Force create tag even if it exists | |
| message | No | Tag message | |
| name | Yes | Tag name | |
| path | No | Path to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo) | |
| sign | No | Create a signed tag |
Implementation Reference
- src/git-operations.ts:530-563 (handler)The core handler function for the 'tag_create' tool. Validates the repository and tag name, constructs the appropriate 'git tag' or 'git tag -a -m' command, executes it using CommandExecutor, formats the output, manages caching, and returns the GitToolResult.static async tagCreate({ path, name, message }: TagOptions, context: GitToolContext): Promise<GitToolResult> { const resolvedPath = this.getPath({ path }); return await this.executeOperation( context.operation, resolvedPath, async () => { const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath); PathValidator.validateTagName(name); let command = `tag ${name}`; if (typeof message === 'string' && message.length > 0) { command = `tag -a ${name} -m "${message}"`; } const result = await CommandExecutor.executeGitCommand( command, context.operation, repoPath ); return { content: [{ type: 'text', text: `Tag '${name}' created successfully\n${CommandExecutor.formatOutput(result)}` }] }; }, { command: 'tag_create', invalidateCache: true, // Invalidate tag cache stateType: RepoStateType.TAG } ); }
- src/tool-handler.ts:314-350 (registration)Registers the 'tag_create' tool with the MCP server in the ListTools response, providing the tool name, description, and detailed input JSON schema.{ name: 'tag_create', description: 'Create a tag', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, name: { type: 'string', description: 'Tag name', }, message: { type: 'string', description: 'Tag message', }, force: { type: 'boolean', description: 'Force create tag even if it exists', default: false }, annotated: { type: 'boolean', description: 'Create an annotated tag', default: true }, sign: { type: 'boolean', description: 'Create a signed tag', default: false } }, required: ['name'], }, },
- src/types.ts:85-91 (schema)TypeScript interface defining the TagOptions type used for input validation in the tag_create handler.export interface TagOptions extends GitOptions, BasePathOptions { name: string; message?: string; force?: boolean; // Allow force operations annotated?: boolean; // Create an annotated tag sign?: boolean; // Create a signed tag }
- src/types.ts:182-186 (schema)Runtime type guard function isTagOptions used to validate arguments before calling the tag_create handler.export function isTagOptions(obj: any): obj is TagOptions { return obj && validatePath(obj.path) && typeof obj.name === 'string'; }
- src/tool-handler.ts:628-631 (registration)Dispatches calls to the 'tag_create' tool by validating arguments with isTagOptions and invoking GitOperations.tagCreate.case 'tag_create': { const validArgs = this.validateArguments(operation, args, isTagOptions); return await GitOperations.tagCreate(validArgs, context); }