Skip to content

Add Windows Claude Desktop credential helper - #6516

Open
stantheman0128 wants to merge 1 commit into
stacklok:mainfrom
stantheman0128:fix/6507-claude-desktop-windows-helper
Open

Add Windows Claude Desktop credential helper#6516
stantheman0128 wants to merge 1 commit into
stacklok:mainfrom
stantheman0128:fix/6507-claude-desktop-windows-helper

Conversation

@stantheman0128

Copy link
Copy Markdown
Contributor

Summary

thv llm setup --client claude-desktop detected Claude Desktop on Windows and then failed with claude-desktop LLM gateway setup is not supported on Windows yet. The helper it would have written is a POSIX /bin/sh script (claude-desktop-helper.sh).

The Windows early return is gone. Setup now writes claude-desktop-helper.cmd. The shim still execs the absolute thv path from os.Executable() (GUI-launched Claude Desktop has no useful PATH). It uses goto instead of a parenthesized if so a ) in the path cannot break the block, and call so a .cmd token helper returns. % and " in the path are escaped for cmd.exe.

Fixes #6507

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (go test ./pkg/client/ -count=1 -timeout 180s -run "CredentialHelper|QuoteFor|WriteCredential")
  • E2E tests (task test-e2e) (suite skips on Windows; POSIX fake-browser)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Isolated %USERPROFILE% on this Win11 box (real Claude store untouched):

thv llm setup --client claude-desktop --lazy --gateway-url https://127.0.0.1:9 --issuer https://127.0.0.1:9 --client-id dummy-self-found --tls-skip-verify

Setup exit 0. Wrote .toolhive\llm\claude-desktop-helper.cmd with call "<abs thv.exe>" llm token. Config document inferenceCredentialHelper pointed at that .cmd. thv llm teardown claude-desktop removed the shim and the config document.

Did not launch Claude Desktop itself, so the GUI helper invoke is untested here.

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

Does this introduce a user-facing change?

Yes. thv llm setup --client claude-desktop now configures Claude Desktop on Windows.

Special notes for reviewers

Assigned on #6507. Direct-mode clients still use the PATH-resolved thv llm token shell string; only Claude Desktop needs the absolute-path shim.

Assisted by Cursor.

Evidence

go test ./pkg/client/ -count=1 -timeout 180s -run "CredentialHelper|QuoteFor|WriteCredential"
ok  	github.com/stacklok/toolhive/pkg/client	1.560s

Live setup/teardown under a temp USERPROFILE: setup exit 0, .cmd present, teardown removed the shim. Real %LOCALAPPDATA%\Claude-3p file count stayed 0.

Setup on Windows used to write a POSIX .sh shim and then refuse. Write a .cmd shim and quote the thv path for cmd.exe instead.

Signed-off-by: Po-Han Shih <stanshih888@gmail.com>
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.24%. Comparing base (e30f1bf) to head (e349867).

Files with missing lines Patch % Lines
pkg/client/llm_gateway_credential_helper.go 25.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6516      +/-   ##
==========================================
- Coverage   78.25%   78.24%   -0.01%     
==========================================
  Files         770      770              
  Lines       75521    75542      +21     
==========================================
+ Hits        59100    59111      +11     
- Misses      16416    16426      +10     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

thv llm setup --client claude-desktop fails on Windows (POSIX credential-helper shim)

1 participant