55 workflow_dispatch :
66 workflow_call :
77
8+ # The Claude API is authenticated via workload identity federation: id-token
9+ # lets the action mint the GitHub OIDC token it exchanges for a short-lived
10+ # access token. See docs/setup.md.
11+ permissions :
12+ contents : read
13+ id-token : write
14+
815jobs :
916 test-mcp-integration :
1017 runs-on : ubuntu-latest
2532 uses : ./base-action
2633 id : claude-test
2734 with :
28- prompt : " List all available tools"
29- anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
35+ prompt : " Call the test_tool tool and report its response."
36+ anthropic_federation_rule_id : ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
37+ anthropic_organization_id : ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
38+ anthropic_service_account_id : ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
39+ claude_args : --allowedTools mcp__test-server__test_tool
3040 env :
3141 # Change to test directory so it finds .mcp.json
3242 CLAUDE_WORKING_DIR : ${{ github.workspace }}/base-action/test/mcp-test
@@ -50,21 +60,29 @@ jobs:
5060 if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" > /dev/null; then
5161 echo "✓ Found mcp_servers in output"
5262
53- # Check if test-server is connected
54- if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server" and .status == "connected")' "$OUTPUT_FILE" > /dev/null; then
55- echo "✓ test-server is connected"
63+ # MCP servers can connect asynchronously, so the init event may
64+ # report the server as pending — check registration there, then
65+ # verify the tool actually ran.
66+ if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server")' "$OUTPUT_FILE" > /dev/null; then
67+ echo "✓ test-server is registered"
5668 else
57- echo "✗ test-server not found or not connected "
69+ echo "✗ test-server not found"
5870 jq '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE"
5971 exit 1
6072 fi
61-
62- # Check if mcp tools are available
63- if jq -e '.[] | select(.type == "system" and .subtype == "init") | .tools[] | select(. == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then
64- echo "✓ MCP test tool found"
73+
74+ if jq -e '.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use" and .name == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then
75+ echo "✓ MCP test tool was called"
76+ else
77+ echo "✗ MCP test tool was not called"
78+ jq '[.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name]' "$OUTPUT_FILE"
79+ exit 1
80+ fi
81+
82+ if jq -e '.[] | select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | tostring | contains("Test tool response"))' "$OUTPUT_FILE" > /dev/null; then
83+ echo "✓ MCP test tool returned its response"
6584 else
66- echo "✗ MCP test tool not found"
67- jq '.[] | select(.type == "system" and .subtype == "init") | .tools' "$OUTPUT_FILE"
85+ echo "✗ MCP test tool response not found"
6886 exit 1
6987 fi
7088 else
@@ -106,9 +124,13 @@ jobs:
106124 uses : ./base-action
107125 id : claude-config-test
108126 with :
109- prompt : " List all available tools"
110- anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
111- mcp_config : ' {"mcpServers":{"test-server":{"type":"stdio","command":"bun","args":["simple-mcp-server.ts"],"env":{}}}}'
127+ prompt : " Call the test_tool tool and report its response."
128+ anthropic_federation_rule_id : ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
129+ anthropic_organization_id : ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
130+ anthropic_service_account_id : ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
131+ claude_args : |
132+ --allowedTools mcp__test-server__test_tool
133+ --mcp-config '{"mcpServers":{"test-server":{"type":"stdio","command":"bun","args":["simple-mcp-server.ts"],"env":{}}}}'
112134 env :
113135 # Change to test directory so bun can find the MCP server script
114136 CLAUDE_WORKING_DIR : ${{ github.workspace }}/base-action/test/mcp-test
@@ -132,21 +154,29 @@ jobs:
132154 if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE" > /dev/null; then
133155 echo "✓ Found mcp_servers in output"
134156
135- # Check if test-server is connected
136- if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server" and .status == "connected")' "$OUTPUT_FILE" > /dev/null; then
137- echo "✓ test-server is connected"
157+ # MCP servers can connect asynchronously, so the init event may
158+ # report the server as pending — check registration there, then
159+ # verify the tool actually ran.
160+ if jq -e '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers[] | select(.name == "test-server")' "$OUTPUT_FILE" > /dev/null; then
161+ echo "✓ test-server is registered"
138162 else
139- echo "✗ test-server not found or not connected "
163+ echo "✗ test-server not found"
140164 jq '.[] | select(.type == "system" and .subtype == "init") | .mcp_servers' "$OUTPUT_FILE"
141165 exit 1
142166 fi
143-
144- # Check if mcp tools are available
145- if jq -e '.[] | select(.type == "system" and .subtype == "init") | .tools[] | select(. == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then
146- echo "✓ MCP test tool found"
167+
168+ if jq -e '.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use" and .name == "mcp__test-server__test_tool")' "$OUTPUT_FILE" > /dev/null; then
169+ echo "✓ MCP test tool was called"
170+ else
171+ echo "✗ MCP test tool was not called"
172+ jq '[.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name]' "$OUTPUT_FILE"
173+ exit 1
174+ fi
175+
176+ if jq -e '.[] | select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | tostring | contains("Test tool response"))' "$OUTPUT_FILE" > /dev/null; then
177+ echo "✓ MCP test tool returned its response"
147178 else
148- echo "✗ MCP test tool not found"
149- jq '.[] | select(.type == "system" and .subtype == "init") | .tools' "$OUTPUT_FILE"
179+ echo "✗ MCP test tool response not found"
150180 exit 1
151181 fi
152182 else
0 commit comments