Skip to main content

Git Operations - MCP Tool Specification

This document outlines the specification for tools within the Git Operations module that are integrated with the Model Context Protocol (MCP). These tools are defined in mcp_tools.py and exposed via the @mcp_tool decorator.

General Considerations​

  • Tool Integration: This module provides version control automation and Git workflow management.
  • Configuration: Operations are performed relative to a repository root, which can be specified or auto-detected.
  • Implementation: All tools are defined in mcp_tools.py using the @mcp_tool decorator.

Tool: git_check_availability​

1. Tool Purpose and Description​

Check if git is available on the current system.

2. Invocation Name​

codomyrmex.git_check_availability

3. Input Schema (Parameters)​

No parameters required.

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok""ok"
git_availablebooleanWhether git is installedtrue

5. Idempotency​

  • Idempotent: Yes

Tool: git_is_repo​

1. Tool Purpose and Description​

Check if a directory is a git repository.

2. Invocation Name​

codomyrmex.git_is_repo

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to check"/projects/myapp"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
is_git_repositorybooleanWhether path is a git repotrue
pathstringChecked path"/projects/myapp"

5. Idempotency​

  • Idempotent: Yes

Tool: git_repo_status​

1. Tool Purpose and Description​

Gets the current status of a Git repository, including staged/unstaged changes, untracked files, and branch information.

2. Invocation Name​

codomyrmex.git_repo_status

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
git_statusobjectStatus information from get_status(){...}

5. Error Handling​

  • Returns {"status": "error", "error": "<message>"} if path is not a Git repository.

6. Idempotency​

  • Idempotent: Yes

Tool: git_current_branch​

1. Tool Purpose and Description​

Get the current branch name of a git repository.

2. Invocation Name​

codomyrmex.git_current_branch

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
branchstringCurrent branch name"main"

5. Idempotency​

  • Idempotent: Yes

Tool: git_diff​

1. Tool Purpose and Description​

Get the diff of uncommitted changes in a git repository.

2. Invocation Name​

codomyrmex.git_diff

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
stagedbooleanNoShow staged changes only (default: false)true

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
diffstringDiff output"diff --git..."

5. Idempotency​

  • Idempotent: Yes

Tool: git_log​

1. Tool Purpose and Description​

Get recent commit history for a git repository.

2. Invocation Name​

codomyrmex.git_log

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
max_countintegerNoMaximum commits to return (default: 10)20

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
commitsarrayList of commit objects[...]

5. Idempotency​

  • Idempotent: Yes

Tool: git_init​

1. Tool Purpose and Description​

Initialize a new git repository at the given path.

2. Invocation Name​

codomyrmex.git_init

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath where to initialize the repo"/projects/new-app"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
initializedbooleanWhether initialization succeededtrue
pathstringRepository path"/projects/new-app"
resultanyResult from initialize_git_repository()...

5. Idempotency​

  • Idempotent: No. Fails if already initialized.

Tool: git_clone​

1. Tool Purpose and Description​

Clone a git repository from a URL to a local path.

2. Invocation Name​

codomyrmex.git_clone

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
urlstringYesRepository URL to clone"https://github.com/org/repo.git"
pathstringYesLocal destination path"/projects/repo"
branchstringNoBranch to clone (default: default branch)"develop"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
clonedbooleanWhether clone succeededtrue
resultanyResult from clone_repository()...

5. Idempotency​

  • Idempotent: No. Fails if destination path already exists.

Tool: git_commit​

1. Tool Purpose and Description​

Stage files and create a commit with a message.

2. Invocation Name​

codomyrmex.git_commit

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
messagestringYesCommit message"Fix login bug"
filesarray[string]NoSpecific files to stage before commit["src/auth.py"]

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
committedbooleanWhether commit succeededtrue
resultanyResult from commit_changes()...

5. Idempotency​

  • Idempotent: No. Creates a new commit each time.

Tool: git_create_branch​

1. Tool Purpose and Description​

Create a new branch in a git repository.

2. Invocation Name​

codomyrmex.git_create_branch

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
branch_namestringYesName for the new branch"feature/new-login"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
branchstringBranch name"feature/new-login"
resultanyResult from create_branch()...

5. Idempotency​

  • Idempotent: No. Fails if branch already exists.

Tool: git_switch_branch​

1. Tool Purpose and Description​

Switch to a different branch in a git repository.

2. Invocation Name​

codomyrmex.git_switch_branch

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
branch_namestringYesBranch to switch to"feature/new-login"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
branchstringCurrent branch after switch"feature/new-login"
resultanyResult from switch_branch()...

5. Idempotency​

  • Idempotent: Yes (switching to current branch is a no-op).

Tool: git_pull​

1. Tool Purpose and Description​

Pull latest changes from a remote git repository.

2. Invocation Name​

codomyrmex.git_pull

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
remotestringNoRemote name (default: "origin")"upstream"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
pulledbooleanWhether pull succeededtrue
resultanyResult from pull_changes()...

5. Idempotency​

  • Idempotent: Yes (if already up to date, returns success).

Tool: git_push​

1. Tool Purpose and Description​

Push local commits to a remote git repository.

2. Invocation Name​

codomyrmex.git_push

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
remotestringNoRemote name (default: "origin")"upstream"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
pushedbooleanWhether push succeededtrue
resultanyResult from push_changes()...

5. Error Handling​

  • Returns {"status": "error", "error": "<message>"} on failures (remote not found, auth issues, etc.).

6. Idempotency​

  • Idempotent: Yes (if already pushed, returns success).

Tool: git_delete_branch​

1. Tool Purpose and Description​

Delete a local branch. Use force=True to delete unmerged branches.

2. Invocation Name​

codomyrmex.git_delete_branch

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
branch_namestringYesBranch to delete"feature/old-work"
forcebooleanNoForce-delete unmerged branch (default: false)true

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
branchstringDeleted branch name"feature/old-work"
deletedanyResult from delete_branch()...

5. Idempotency​

  • Idempotent: No. Fails if branch does not exist.

Tool: git_merge​

1. Tool Purpose and Description​

Merge a source branch into a target branch (or the current branch if target is omitted).

2. Invocation Name​

codomyrmex.git_merge

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
source_branchstringYesBranch to merge from"feature/login"
target_branchstringNoBranch to merge into (default: current branch)"main"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
mergedanyResult from merge_branch()...
sourcestringSource branch name"feature/login"
targetstringTarget branch name"main"

5. Idempotency​

  • Idempotent: No. Creates a merge commit each time.

Tool: git_rebase​

1. Tool Purpose and Description​

Rebase the current branch onto a target branch.

2. Invocation Name​

codomyrmex.git_rebase

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
target_branchstringYesBranch to rebase onto"main"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
rebasedanyResult from rebase_branch()...
targetstringTarget branch"main"

5. Idempotency​

  • Idempotent: No. Rewrites commit history.

Tool: git_cherry_pick​

1. Tool Purpose and Description​

Cherry-pick a specific commit onto the current branch.

2. Invocation Name​

codomyrmex.git_cherry_pick

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
commit_shastringYesSHA of the commit to cherry-pick"a1b2c3d"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
cherry_pickedanyResult from cherry_pick()...
commitstringCommit SHA"a1b2c3d"

5. Idempotency​

  • Idempotent: No. Creates a new commit each time.

Tool: git_revert​

1. Tool Purpose and Description​

Revert a specific commit by creating a new inverse commit.

2. Invocation Name​

codomyrmex.git_revert

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
commit_shastringYesSHA of the commit to revert"a1b2c3d"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
revertedanyResult from revert_commit()...
commitstringReverted commit SHA"a1b2c3d"

5. Idempotency​

  • Idempotent: No. Creates a new revert commit each time.

Tool: git_reset​

1. Tool Purpose and Description​

Reset the repository to a commit using soft, mixed, or hard mode.

2. Invocation Name​

codomyrmex.git_reset

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
modestringNoReset mode: "soft", "mixed", or "hard" (default: "mixed")"hard"
targetstringNoCommit to reset to (default: "HEAD")"HEAD~3"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
resetanyResult from reset_changes()...
modestringReset mode used"hard"
targetstringTarget commit"HEAD~3"

5. Idempotency​

  • Idempotent: Yes (resetting to the same target is a no-op).

Tool: git_amend​

1. Tool Purpose and Description​

Amend the most recent commit message or content.

2. Invocation Name​

codomyrmex.git_amend

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
messagestringNoNew commit message (default: keep existing)"Updated commit msg"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
amended_shaanyNew commit SHA after amend"d4e5f6g"

5. Idempotency​

  • Idempotent: No. Rewrites the most recent commit.

Tool: git_stash​

1. Tool Purpose and Description​

Stash uncommitted changes with an optional description message.

2. Invocation Name​

codomyrmex.git_stash

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
messagestringNoDescription for the stash entry"WIP: login feature"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
stashedanyResult from stash_changes()...

5. Idempotency​

  • Idempotent: No. Creates a new stash entry each time.

Tool: git_stash_apply​

1. Tool Purpose and Description​

Apply a stash entry to the working directory.

2. Invocation Name​

codomyrmex.git_stash_apply

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
stash_refstringNoStash reference to apply (default: latest)"stash@{2}"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
appliedanyResult from apply_stash()...

5. Idempotency​

  • Idempotent: Yes (applying the same stash twice may conflict but does not create new state).

Tool: git_stash_list​

1. Tool Purpose and Description​

List all stash entries in the repository.

2. Invocation Name​

codomyrmex.git_stash_list

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
stashesarrayList of stash entries[...]
countintegerNumber of stash entries3

5. Idempotency​

  • Idempotent: Yes

Tool: git_create_tag​

1. Tool Purpose and Description​

Create a lightweight or annotated tag at the current commit.

2. Invocation Name​

codomyrmex.git_create_tag

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
tag_namestringYesTag name"v1.2.0"
messagestringNoAnnotation message (creates annotated tag if provided)"Release 1.2.0"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
tagstringTag name"v1.2.0"
createdanyResult from create_tag()...

5. Idempotency​

  • Idempotent: No. Fails if tag already exists.

Tool: git_list_tags​

1. Tool Purpose and Description​

List all tags in the repository.

2. Invocation Name​

codomyrmex.git_list_tags

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
tagsarrayList of tag names["v1.0.0", "v1.1.0"]
countintegerNumber of tags2

5. Idempotency​

  • Idempotent: Yes

Tool: git_fetch​

1. Tool Purpose and Description​

Fetch changes from a remote repository without merging.

2. Invocation Name​

codomyrmex.git_fetch

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"
remotestringNoRemote name (default: "origin")"upstream"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
fetchedanyResult from fetch_changes()...
remotestringRemote name"origin"

5. Idempotency​

  • Idempotent: Yes

Tool: git_add_remote​

1. Tool Purpose and Description​

Add a named remote URL to the repository.

2. Invocation Name​

codomyrmex.git_add_remote

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
namestringYesRemote name"upstream"
urlstringYesRemote URL"https://github.com/org/repo.git"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
addedanyResult from add_remote()...
namestringRemote name"upstream"
urlstringRemote URL"https://github.com/org/repo.git"

5. Idempotency​

  • Idempotent: No. Fails if remote name already exists.

Tool: git_remove_remote​

1. Tool Purpose and Description​

Remove a named remote from the repository.

2. Invocation Name​

codomyrmex.git_remove_remote

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
namestringYesRemote name to remove"upstream"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
removedanyResult from remove_remote()...
namestringRemoved remote name"upstream"

5. Idempotency​

  • Idempotent: No. Fails if remote does not exist.

Tool: git_list_remotes​

1. Tool Purpose and Description​

List all configured remotes for the repository.

2. Invocation Name​

codomyrmex.git_list_remotes

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringNoPath to repository (default: ".")"/path/to/repo"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
remotesarrayList of remote objects[...]
countintegerNumber of remotes2

5. Idempotency​

  • Idempotent: Yes

Tool: git_blame​

1. Tool Purpose and Description​

Show git blame output for a file (line-by-line commit attribution).

2. Invocation Name​

codomyrmex.git_blame

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
file_pathstringYesFile to blame"src/auth.py"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
blameanyBlame output from get_blame()...

5. Idempotency​

  • Idempotent: Yes

Tool: git_commit_details​

1. Tool Purpose and Description​

Get detailed metadata for a specific commit by SHA.

2. Invocation Name​

codomyrmex.git_commit_details

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
commit_shastringYesCommit SHA to inspect"a1b2c3d"

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
commitobjectCommit metadata from get_commit_details(){...}

5. Idempotency​

  • Idempotent: Yes

Tool: git_get_config​

1. Tool Purpose and Description​

Read a git configuration value by key.

2. Invocation Name​

codomyrmex.git_get_config

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
keystringYesConfig key to read"user.email"
global_configbooleanNoRead from global config (default: false)true

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
keystringConfig key"user.email"
valuestringConfig value"dev@example.com"

5. Idempotency​

  • Idempotent: Yes

Tool: git_set_config​

1. Tool Purpose and Description​

Set a git configuration value (local or global scope).

2. Invocation Name​

codomyrmex.git_set_config

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
keystringYesConfig key to set"user.email"
valuestringYesConfig value"dev@example.com"
global_configbooleanNoSet in global config (default: false)true

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
keystringConfig key"user.email"
valuestringConfig value"dev@example.com"
setanyResult from set_config()...

5. Idempotency​

  • Idempotent: Yes (setting the same value is a no-op).

Tool: git_clean​

1. Tool Purpose and Description​

WARNING: Irreversible. Deletes untracked files from the working tree.

2. Invocation Name​

codomyrmex.git_clean

3. Input Schema (Parameters)​

Parameter NameTypeRequiredDescriptionExample Value
pathstringYesPath to repository"/path/to/repo"
forcebooleanNoForce clean (default: false)true
directoriesbooleanNoAlso remove untracked directories (default: false)true

4. Output Schema (Return Value)​

Field NameTypeDescriptionExample Value
statusstring"ok" or "error""ok"
cleanedanyResult from clean_repository()...

5. Idempotency​

  • Idempotent: Yes (cleaning an already-clean tree is a no-op).

Security Considerations (All Tools)​

  • Path Validation: Repository paths should be validated to prevent directory traversal.
  • Credential Handling: Git credentials are managed by the system's git credential helper; never stored in tool responses.
  • Remote Operations: git_push, git_pull, and git_clone perform network operations.