|
|
@@ -73,6 +73,32 @@ fi
|
|
|
cd "$REPO_PATH" || exit 1
|
|
|
echo "Working directory: $(pwd)"
|
|
|
|
|
|
+# Load .env file to get GOGS_MCP_PATH
|
|
|
+if [ -f "$REPO_PATH/.env" ]; then
|
|
|
+ export $(grep -v '^#' "$REPO_PATH/.env" | grep GOGS_MCP_PATH | xargs)
|
|
|
+fi
|
|
|
+
|
|
|
+# Set default GOGS_MCP_PATH if not set
|
|
|
+GOGS_MCP_PATH="${GOGS_MCP_PATH:-/data/gogs-mcp/dist/index.js}"
|
|
|
+
|
|
|
+# Generate MCP config file dynamically with environment-specific path
|
|
|
+cat > "$REPO_PATH/.mcp-gogs.json" <<EOF
|
|
|
+{
|
|
|
+ "mcpServers": {
|
|
|
+ "gogs": {
|
|
|
+ "type": "stdio",
|
|
|
+ "command": "node",
|
|
|
+ "args": [
|
|
|
+ "$GOGS_MCP_PATH"
|
|
|
+ ],
|
|
|
+ "env": {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+EOF
|
|
|
+
|
|
|
+echo "Generated MCP config with path: $GOGS_MCP_PATH"
|
|
|
+
|
|
|
# Build the prompt for Claude with instructions to use Gogs MCP tool
|
|
|
if [ -n "$COMMENT_BODY" ]; then
|
|
|
# Issue comment event - new comment was added
|
|
|
@@ -217,11 +243,13 @@ echo "---"
|
|
|
# Call claude with the prompt in non-interactive mode
|
|
|
# -p / --print: Non-interactive mode, prints output and exits
|
|
|
# --output-format json: Get structured JSON output for programmatic parsing
|
|
|
+# --mcp-config: Load MCP servers from config file (enables gogs MCP tools)
|
|
|
# --allowedTools: Enable specific tools (MCP Gogs server and file tools)
|
|
|
# --dangerously-skip-permissions: Skip all permission prompts (safe in controlled environment)
|
|
|
# This allows Claude to run unattended without waiting for user input
|
|
|
OUTPUT=$(claude -p "$PROMPT" \
|
|
|
--output-format json \
|
|
|
+ --mcp-config "$REPO_PATH/.mcp-gogs.json" \
|
|
|
--allowedTools "mcp__gogs,Read,Write,Edit,Bash,Grep,Glob,TodoWrite" \
|
|
|
--dangerously-skip-permissions 2>&1)
|
|
|
EXIT_CODE=$?
|