Skip to content

Add thv client connector for Claude Desktop - #6840

Merged
jerm-dro merged 4 commits into
mainfrom
claude-desktop-connectors
Oct 16, 2026
Merged

jerm-dro merged 4 commits into
mainfrom
claude-desktop-connectors

Conversation

@jerm-dro

@jerm-dro jerm-dro commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Claude Desktop in third-party mode (inference through an LLM gateway, configured by thv llm setup --client claude-desktop) only takes remote MCP servers from the managedMcpServers key of its applied configuration. Users cannot add remote servers from the app itself. Desktop connects to each entry directly and runs the server's OAuth sign-in (401 → protected-resource metadata → dynamic client registration → PKCE browser login), so no local proxy is needed. Until now ToolHive had no way to write these entries, so connecting Desktop to a remote MCP gateway meant hand-editing its config.

  • Add thv client connector add|list|rm --client claude-desktop. add NAME URL writes {name, transport: "http", url, oauth: true} into managedMcpServers; a second add with the same name updates the URL.
  • Connectors are written into the same configuration document thv llm setup --client claude-desktop owns, because Desktop applies exactly one document at a time; a separate document would displace the LLM gateway configuration. All other keys and entries ToolHive didn't write are preserved, under the same file lock setup and teardown use.
  • The commands fail with a hint to run thv llm setup --client claude-desktop first when there is no ToolHive document, since without the inference settings Desktop ignores managedMcpServers.
  • thv llm teardown now logs a warning naming the connectors removed along with the document.
  • Re-running thv llm setup --client claude-desktop keeps existing connectors when it rewrites the document.
  • connector add warns when Desktop won't load the connector: an MDM profile overrides local config, or a different saved configuration is applied in the app.

Type of change

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

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

E2E was run with E2E_LABEL_FILTER="llm && clients" (22 specs, including the new connector spec). Manually, a managedMcpServers entry of this exact shape in a real Claude Desktop third-party config connected to a remote MCP gateway alongside the LLM gateway: Desktop ran the OAuth sign-in, listed the gateway's tools, and tool calls worked end to end. thv client connector list --client claude-desktop against that config shows the entry.

Changes

File Change
pkg/client/claude_desktop_connectors.go Add/remove/list connectors in ToolHive's Claude Desktop config document
pkg/client/claude_desktop_connectors_test.go Unit tests
pkg/client/llm_gateway_credential_helper.go Setup keeps connectors; teardown warning
pkg/client/config.go Comment updates
cmd/thv/app/client_connector.go thv client connector CLI
test/e2e/cli_llm_all_clients_test.go E2E spec for add/list/rm and teardown
docs/cli/ Generated CLI docs

Does this introduce a user-facing change?

Yes. New thv client connector add|list|rm --client claude-desktop commands. Before: remote MCP servers had to be added to Claude Desktop's third-party config by hand (or via MDM). After: thv client connector add --client claude-desktop NAME https://... adds one; fully quit and reopen Desktop, then click Connect under Customize → Connectors. thv llm teardown now also warns when it removes connectors, and re-running thv llm setup --client claude-desktop keeps them.

Special notes for reviewers

  • Deliberate choice: when a different saved configuration is applied in Desktop, connector add warns instead of failing, because the connector takes effect once the user switches back to the ToolHive configuration.
  • Known limitation, tracked in Claude Desktop config and detection paths are wrong on Linux #6847: on Linux, ToolHive resolves the wrong Claude Desktop config and detection paths (missing the ~/.config prefix). This affects thv llm setup too, so it's fixed separately.
  • Only --client claude-desktop is supported; other clients return ErrConnectorsUnsupported. Optional fields (headers, tool policy, pre-registered OAuth clients) are deliberately left out.
  • Non-test, non-doc changes are ~430 lines, slightly over the 400-line guideline; it is one feature and most of it is the new pkg/client file.

🤖 Generated with Claude Code

Knowledge workers using Claude Desktop in third-party mode need to reach
remote MCP servers such as the Connector Gateway without a local proxy.
Desktop reads these from managedMcpServers in its applied configuration
and runs each server's OAuth sign-in itself.

Add "thv client connector add/list/rm --client claude-desktop", which
writes connectors into the configuration document "thv llm setup
--client claude-desktop" already owns, since Desktop applies only one
document at a time. "thv llm teardown" now warns about connectors it
removes along with that document.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Oct 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Connector updates and removals can silently discard existing settings or unrelated local server definitions.

2 open findings
What changed in this PR

Adds direct remote MCP connector management for Claude Desktop, using the configuration document already managed by ToolHive’s LLM gateway setup.

Changes:

  • Adds connector add, list, and remove commands.
  • Adds shared-document updates and teardown warnings.
  • Adds unit tests, end-to-end coverage, and CLI documentation.
File Description
test/​e2e/​cli_llm_all_clients_test.go Tests connector lifecycle alongside LLM setup.
pkg/​client/​llm_gateway_credential_helper.go Warns when teardown removes connectors.
pkg/​client/​config.go Clarifies integration comments.
pkg/​client/​claude_desktop_connectors.go Implements connector management and validation.
pkg/​client/​claude_desktop_connectors_test.go Tests connector operations and configuration preservation.
docs/​cli/​thv_client.md Links connector command documentation.
docs/​cli/​thv_client_connector.md Documents setup requirements and limitations.
docs/​cli/​thv_client_connector_rm.md Documents connector removal.
docs/​cli/​thv_client_connector_list.md Documents listing formats.
docs/​cli/​thv_client_connector_add.md Documents connector creation and updates.
cmd/​thv/​app/​client_connector.go Adds CLI commands and completion.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/client/claude_desktop_connectors.go Resolved
Comment thread pkg/client/claude_desktop_connectors.go Resolved
Re-adding a connector now updates only its URL, keeping fields a user set by hand, and neither add nor rm touches a same-name entry that is not a remote server, matching what list shows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.56604% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.72%. Comparing base (9732005) to head (6dca665).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/client/claude_desktop_connectors.go 90.25% 15 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6840    +/-   ##
========================================
  Coverage   79.71%   79.72%            
========================================
  Files         817      818     +1     
  Lines       83411    83583   +172     
========================================
+ Hits        66492    66637   +145     
- Misses      16914    16941    +27     
  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.

aponcedeleonch
aponcedeleonch previously approved these changes Oct 16, 2026

@aponcedeleonch aponcedeleonch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this. I checked the integration against Claude Desktop's 3P docs and it lines up well. The entry shape matches the documented example. A local configLibrary document is a supported place for managedMcpServers, and the app's own config window writes the key there too. Putting connectors in the same document setup owns is the right call, since _meta.json only applies one at a time. I also confirmed that our embedded auth server accepts Desktop's DCR registration. It registers as a public client on http://127.0.0.1:53280/callback, and we allow loopback http for public clients.

My comments are mostly about cases where a connector gets written but Desktop never loads it, and the user gets no signal. Details are inline.

One more thing, but it's not from this PR. On Linux the Claude Desktop entry has no platform prefix, so we resolve ~/Claude-3p/configLibrary/. The docs put it at ~/.config/Claude-3p/configLibrary/, and detection has the same problem (~/Claude vs ~/.config/Claude). That affects thv llm setup too, so I'll open a separate issue for it.

Comment thread cmd/thv/app/client_connector.go Resolved
Comment thread pkg/client/claude_desktop_connectors.go Resolved
Comment thread cmd/thv/app/client_connector.go Resolved
Re-running "thv llm setup --client claude-desktop" rewrote the config
document and silently dropped connectors; it now carries them over.
"thv client connector add" warns when Claude Desktop will not load the
connector because an MDM profile overrides local config or another
saved configuration is applied, and its help notes that the URL must be
the server's final address since Desktop does not follow redirects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/L Large PR: 600-999 lines changed labels Oct 16, 2026
@jerm-dro

Copy link
Copy Markdown
Collaborator Author

@aponcedeleonch I opened #6847 for the Linux path issue (config library and detection both missing the ~/.config prefix). It also notes that IsManaged doesn't check Linux's /etc/claude-desktop/managed-settings.json.

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Oct 16, 2026
@jerm-dro
jerm-dro merged commit 16ffc0b into main Oct 16, 2026
57 of 58 checks passed
@jerm-dro
jerm-dro deleted the claude-desktop-connectors branch October 16, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants