|
76 | 76 | fi |
77 | 77 |
|
78 | 78 | echo "✓ All MCP server checks passed!" |
| 79 | +
|
| 80 | + test-mcp-config-flag: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - name: Checkout repository |
| 84 | + uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Setup Bun |
| 87 | + uses: oven-sh/setup-bun@v2 |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: | |
| 91 | + bun install |
| 92 | + cd test/mcp-test |
| 93 | + bun install |
| 94 | +
|
| 95 | + - name: Debug environment paths (--mcp-config test) |
| 96 | + run: | |
| 97 | + echo "=== Environment Variables (--mcp-config test) ===" |
| 98 | + echo "HOME: $HOME" |
| 99 | + echo "XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-not set}" |
| 100 | + echo "CLAUDE_CONFIG_DIR: ${CLAUDE_CONFIG_DIR:-not set}" |
| 101 | + echo "" |
| 102 | + echo "=== Expected Config Paths ===" |
| 103 | + echo "GitHub action writes to: $HOME/.claude/settings.json" |
| 104 | + if [ -n "${XDG_CONFIG_HOME:-}" ]; then |
| 105 | + echo "Claude might read from: $XDG_CONFIG_HOME/claude/settings.json" |
| 106 | + else |
| 107 | + echo "Claude should read from: $HOME/.claude/settings.json" |
| 108 | + fi |
| 109 | + echo "" |
| 110 | + echo "=== Actual File System ===" |
| 111 | + ls -la $HOME/.claude/ || echo "No $HOME/.claude directory" |
| 112 | + if [ -n "${XDG_CONFIG_HOME:-}" ]; then |
| 113 | + ls -la $XDG_CONFIG_HOME/ || echo "No $XDG_CONFIG_HOME directory" |
| 114 | + ls -la $XDG_CONFIG_HOME/claude/ || echo "No $XDG_CONFIG_HOME/claude directory" |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: Run Claude Code with --mcp-config flag |
| 118 | + uses: ./ |
| 119 | + id: claude-config-test |
| 120 | + with: |
| 121 | + prompt: "List all available tools" |
| 122 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 123 | + mcp_config: '{"mcpServers":{"test-server":{"type":"stdio","command":"bun","args":["simple-mcp-server.ts"],"env":{}}}}' |
| 124 | + env: |
| 125 | + # Change to test directory so bun can find the MCP server script |
| 126 | + CLAUDE_WORKING_DIR: ${{ github.workspace }}/test/mcp-test |
| 127 | + |
| 128 | + - name: Check MCP server output with --mcp-config |
| 129 | + run: | |
| 130 | + echo "Checking Claude output for MCP servers with --mcp-config flag..." |
| 131 | +
|
| 132 | + # Parse the JSON output |
| 133 | + OUTPUT_FILE="${RUNNER_TEMP}/claude-execution-output.json" |
| 134 | +
|
| 135 | + if [ ! -f "$OUTPUT_FILE" ]; then |
| 136 | + echo "Error: Output file not found!" |
| 137 | + exit 1 |
| 138 | + fi |
| 139 | +
|
| 140 | + echo "Output file contents:" |
| 141 | + cat $OUTPUT_FILE |
| 142 | +
|
| 143 | + # Check if mcp_servers field exists in the init event |
| 144 | + if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" > /dev/null; then |
| 145 | + echo "✓ Found mcp_servers in output" |
| 146 | + |
| 147 | + # Check if test-server is connected |
| 148 | + if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server" and .status == "connected")' "$OUTPUT_FILE" > /dev/null; then |
| 149 | + echo "✓ test-server is connected" |
| 150 | + else |
| 151 | + echo "✗ test-server not found or not connected" |
| 152 | + jq '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" |
| 153 | + exit 1 |
| 154 | + fi |
| 155 | + |
| 156 | + # Check if mcp tools are available |
| 157 | + if jq -e '.[] | select(.type == "system" and .subtype == "init") | .tools[] | select(. == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then |
| 158 | + echo "✓ MCP test tool found" |
| 159 | + else |
| 160 | + echo "✗ MCP test tool not found" |
| 161 | + jq '.[] | select(.type == "system" and .subtype == "init") | .tools' "$OUTPUT_FILE" |
| 162 | + exit 1 |
| 163 | + fi |
| 164 | + else |
| 165 | + echo "✗ No mcp_servers field found in init event" |
| 166 | + jq '.[] | select(.type == "system" and .subtype == "init")' "$OUTPUT_FILE" |
| 167 | + exit 1 |
| 168 | + fi |
| 169 | +
|
| 170 | + echo "✓ All MCP server checks passed with --mcp-config flag!" |
0 commit comments