From e0779c724a616586cdaea0a067d7a74a493c637e Mon Sep 17 00:00:00 2001 From: Mark Wylde Date: Thu, 11 Jun 2026 20:25:16 +0100 Subject: [PATCH] fix: align workflows with Claude Code 2.1 MCP behavior --- .github/workflows/claude-review.yml | 1 + .github/workflows/claude.yml | 1 + .github/workflows/test-mcp-servers.yml | 65 +++++++++++++++++--------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml index cc8d299..eadad44 100644 --- a/.github/workflows/claude-review.yml +++ b/.github/workflows/claude-review.yml @@ -22,6 +22,7 @@ jobs: with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} prompt: "/review-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}" claude_args: | diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 91ce682..64d889e 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -35,6 +35,7 @@ jobs: with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} claude_args: | --allowedTools "Bash(bun install),Bash(bun test:*),Bash(bun run format),Bash(bun typecheck)" --model "claude-opus-4-1-20250805" diff --git a/.github/workflows/test-mcp-servers.yml b/.github/workflows/test-mcp-servers.yml index 957d04c..b0962d5 100644 --- a/.github/workflows/test-mcp-servers.yml +++ b/.github/workflows/test-mcp-servers.yml @@ -27,9 +27,10 @@ jobs: uses: ./base-action id: claude-test with: - prompt: "List all available tools" + prompt: "Call the test_tool tool and report its response." anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + claude_args: --allowedTools mcp__test-server__test_tool env: # Change to test directory so it finds .mcp.json CLAUDE_WORKING_DIR: ${{ github.workspace }}/base-action/test/mcp-test @@ -53,21 +54,29 @@ jobs: if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" > /dev/null; then echo "✓ Found mcp_servers in output" - # Check if test-server is connected - if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server" and .status == "connected")' "$OUTPUT_FILE" > /dev/null; then - echo "✓ test-server is connected" + # MCP servers can connect asynchronously, so the init event may + # report the server as pending. Check registration there, then + # verify the tool actually ran. + if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server")' "$OUTPUT_FILE" > /dev/null; then + echo "✓ test-server is registered" else - echo "✗ test-server not found or not connected" + echo "✗ test-server not found" jq '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" exit 1 fi - - # Check if mcp tools are available - if jq -e '.[] | select(.type == "system" and .subtype == "init") | .tools[] | select(. == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then - echo "✓ MCP test tool found" + + if jq -e '.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use" and .name == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then + echo "✓ MCP test tool was called" else - echo "✗ MCP test tool not found" - jq '.[] | select(.type == "system" and .subtype == "init") | .tools' "$OUTPUT_FILE" + echo "✗ MCP test tool was not called" + jq '[.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name]' "$OUTPUT_FILE" + exit 1 + fi + + if jq -e '.[] | select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | tostring | contains("Test tool response"))' "$OUTPUT_FILE" > /dev/null; then + echo "✓ MCP test tool returned its response" + else + echo "✗ MCP test tool response not found" exit 1 fi else @@ -109,10 +118,12 @@ jobs: uses: ./base-action id: claude-config-test with: - prompt: "List all available tools" + prompt: "Call the test_tool tool and report its response." anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - mcp_config: '{"mcpServers":{"test-server":{"type":"stdio","command":"bun","args":["simple-mcp-server.ts"],"env":{}}}}' + claude_args: | + --allowedTools mcp__test-server__test_tool + --mcp-config '{"mcpServers":{"test-server":{"type":"stdio","command":"bun","args":["simple-mcp-server.ts"],"env":{}}}}' env: # Change to test directory so bun can find the MCP server script CLAUDE_WORKING_DIR: ${{ github.workspace }}/base-action/test/mcp-test @@ -136,21 +147,29 @@ jobs: if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" > /dev/null; then echo "✓ Found mcp_servers in output" - # Check if test-server is connected - if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server" and .status == "connected")' "$OUTPUT_FILE" > /dev/null; then - echo "✓ test-server is connected" + # MCP servers can connect asynchronously, so the init event may + # report the server as pending. Check registration there, then + # verify the tool actually ran. + if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server")' "$OUTPUT_FILE" > /dev/null; then + echo "✓ test-server is registered" else - echo "✗ test-server not found or not connected" + echo "✗ test-server not found" jq '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" exit 1 fi - - # Check if mcp tools are available - if jq -e '.[] | select(.type == "system" and .subtype == "init") | .tools[] | select(. == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then - echo "✓ MCP test tool found" + + if jq -e '.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use" and .name == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then + echo "✓ MCP test tool was called" else - echo "✗ MCP test tool not found" - jq '.[] | select(.type == "system" and .subtype == "init") | .tools' "$OUTPUT_FILE" + echo "✗ MCP test tool was not called" + jq '[.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name]' "$OUTPUT_FILE" + exit 1 + fi + + if jq -e '.[] | select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | tostring | contains("Test tool response"))' "$OUTPUT_FILE" > /dev/null; then + echo "✓ MCP test tool returned its response" + else + echo "✗ MCP test tool response not found" exit 1 fi else