Kaynağa Gözat

fix: enable MCP tools in Claude Code headless mode for issue handler

The previous fix corrected the command syntax but Claude still couldn't
post comments because MCP tools were not explicitly enabled.

Changes:
- Added --allowedTools flag with mcp__gogs and essential tools
- Enables Gogs MCP server tools (get_issue, list_issue_comments, create_issue_comment, etc.)
- Includes Read, Write, Edit, Bash, Grep, Glob, TodoWrite for file operations
- Multi-line command format for better readability

According to Claude Code headless documentation, tools must be explicitly
allowed using --allowedTools flag with comma-separated tool names.
MCP servers use the naming convention mcp__[server_name].

Tested with test-mcp-tools.sh which confirms Claude can now access and
use all Gogs MCP tools including create_issue_comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude 9 ay önce
ebeveyn
işleme
9d0e81e89d
1 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. 5 1
      scripts/handle-issue.sh

+ 5 - 1
scripts/handle-issue.sh

@@ -217,9 +217,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
+# --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 --dangerously-skip-permissions 2>&1)
+OUTPUT=$(claude -p "$PROMPT" \
+    --output-format json \
+    --allowedTools "mcp__gogs,Read,Write,Edit,Bash,Grep,Glob,TodoWrite" \
+    --dangerously-skip-permissions 2>&1)
 EXIT_CODE=$?
 
 echo "---"