Repository navigation
Add thv client connector for Claude Desktop - #6840
Conversation
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 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.
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]>
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
aponcedeleonch
left a comment
There was a problem hiding this comment.
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.
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]>
|
@aponcedeleonch I opened #6847 for the Linux path issue (config library and detection both missing the |


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 themanagedMcpServerskey 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.thv client connector add|list|rm --client claude-desktop.add NAME URLwrites{name, transport: "http", url, oauth: true}intomanagedMcpServers; a secondaddwith the same name updates the URL.thv llm setup --client claude-desktopowns, 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.thv llm setup --client claude-desktopfirst when there is no ToolHive document, since without the inference settings Desktop ignoresmanagedMcpServers.thv llm teardownnow logs a warning naming the connectors removed along with the document.thv llm setup --client claude-desktopkeeps existing connectors when it rewrites the document.connector addwarns 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
Test plan
task test)task test-e2e)task lint-fix)E2E was run with
E2E_LABEL_FILTER="llm && clients"(22 specs, including the new connector spec). Manually, amanagedMcpServersentry 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-desktopagainst that config shows the entry.Changes
pkg/client/claude_desktop_connectors.gopkg/client/claude_desktop_connectors_test.gopkg/client/llm_gateway_credential_helper.gopkg/client/config.gocmd/thv/app/client_connector.gothv client connectorCLItest/e2e/cli_llm_all_clients_test.godocs/cli/Does this introduce a user-facing change?
Yes. New
thv client connector add|list|rm --client claude-desktopcommands. 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 teardownnow also warns when it removes connectors, and re-runningthv llm setup --client claude-desktopkeeps them.Special notes for reviewers
connector addwarns instead of failing, because the connector takes effect once the user switches back to the ToolHive configuration.~/.configprefix). This affectsthv llm setuptoo, so it's fixed separately.--client claude-desktopis supported; other clients returnErrConnectorsUnsupported. Optional fields (headers, tool policy, pre-registered OAuth clients) are deliberately left out.pkg/clientfile.🤖 Generated with Claude Code