Skip to content

Instantly share code, notes, and snippets.

@hed0rah
Created April 3, 2026 14:28
Show Gist options
  • Select an option

  • Save hed0rah/a5611edd1e34e2e268411bf2fa8ff910 to your computer and use it in GitHub Desktop.

Select an option

Save hed0rah/a5611edd1e34e2e268411bf2fa8ff910 to your computer and use it in GitHub Desktop.
Windows Basic Git Bash MCP
{
"mcpServers": {
"dumb_shell": {
"command": "python",
"args": [
"-u",
"C:/Users/<username>/<directory>/gitbash_mcp.py"
],
"cwd": "C:/Users/<username>/<directory>/",
"env": {
"PYTHONUNBUFFERED": "1",
"PYTHONIOENCODING": "utf-8"
}
}
}
}
#!/usr/bin/env python3
import subprocess
from pathlib import Path
from fastmcp import FastMCP
# Resolve project root
ROOT = Path.cwd().resolve()
def to_gitbash_path(p: Path) -> str:
"""
Convert Windows path (C:\foo\bar) -> Git Bash path (/c/foo/bar)
"""
drive = p.drive[0].lower()
rest = str(p).replace("\\", "/")[2:]
return f"/{drive}/{rest}"
ROOT_BASH = to_gitbash_path(ROOT)
app = FastMCP("dumb_shell")
@app.tool
async def run_command(command: str) -> str:
"""Run a shell command inside Git Bash from project root."""
try:
full_cmd = f"cd {ROOT_BASH} && {command}"
result = subprocess.run(
[
r"C:\Program Files\Git\usr\bin\bash.exe",
"-lc", # login shell (important)
full_cmd
],
capture_output=True,
text=True,
timeout=30,
)
output = f"exit={result.returncode}\n"
if result.stdout:
output += result.stdout
if result.stderr:
output += result.stderr
return output.strip()
except subprocess.TimeoutExpired:
return "ERROR: command timed out"
except Exception as e:
return f"ERROR: {e}"
if __name__ == "__main__":
app.run(transport="stdio")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment