Pin ANTHROPIC_API_KEY empty in the client smoke tests

The client tests drive the path where no key is set: each client prints a
notice and exits. They did not isolate the variable, so a key exported in
the environment or sitting in a local .env sent the client into its
interactive chat loop instead. Observed with a .env in mcp-client-ruby: the
run reached "Query:" and waited on stdin.

Empty rather than unset, because dotenv skips a name already present in ENV.
All three clients check `nil? || empty?`, so an empty value takes the early
exit.

CI never hit this, having no key set. It affects local runs, and a run fed
input rather than /dev/null would issue real API requests.

Applied to the Python and TypeScript client tests too; all three share the
pattern.

Also correct the Ruby version comment: 3.3 is supported until March 2027, so
3.4 is not the oldest supported series. The tested version is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
olaservo 2026-08-18 19:44:09 -07:00
commit ecc1138647
2 changed files with 9 additions and 5 deletions

View file

@ -41,8 +41,8 @@ jobs:
with:
go-version: "1.25"
# 3.4 is the oldest series still supported; 3.2 reached end of life in
# March 2026.
# 3.4 is the current stable series. 3.3 is supported until March 2027; 3.2
# reached end of life in March 2026.
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:

View file

@ -84,11 +84,15 @@ test_weather_server_go() {
node "${TEST_CLIENT}" "${server_bin}"
}
# The client tests drive the no-API-key path, where each client prints a notice
# and exits. Empty rather than unset: dotenv skips a name already present in
# ENV, so a key in the environment or a local .env would start the chat loop.
# Test: Python MCP client
test_mcp_client_python() {
check_dependency uv || return 1
local client_dir="${PROJECT_ROOT}/mcp-client-python"
uv --directory "${client_dir}" run python "${client_dir}/client.py" "${MOCK_SERVER}" >/dev/null 2>&1
ANTHROPIC_API_KEY= uv --directory "${client_dir}" run python "${client_dir}/client.py" "${MOCK_SERVER}" >/dev/null 2>&1
}
# Test: TypeScript MCP client
@ -97,7 +101,7 @@ test_mcp_client_typescript() {
check_dependency npm || return 1
local client_dir="${PROJECT_ROOT}/mcp-client-typescript"
ensure_built "${client_dir}" || return 1
node "${client_dir}/build/index.js" "${MOCK_SERVER}" >/dev/null 2>&1
ANTHROPIC_API_KEY= node "${client_dir}/build/index.js" "${MOCK_SERVER}" >/dev/null 2>&1
}
# Test: Ruby MCP client
@ -106,7 +110,7 @@ test_mcp_client_ruby() {
check_dependency bundle || return 1
local client_dir="${PROJECT_ROOT}/mcp-client-ruby"
ensure_bundled "${client_dir}" || return 1
(cd "${client_dir}" && bundle exec ruby client.rb "${MOCK_SERVER}") >/dev/null 2>&1
(cd "${client_dir}" && ANTHROPIC_API_KEY= bundle exec ruby client.rb "${MOCK_SERVER}") >/dev/null 2>&1
}
# Run all tests