openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Add hand-entered (custom) MCP servers not listed in any registry

Open yh928 opened this issue 4 months ago • 1 comments

Summary

Let users add an MCP server they run themselves — a local stdio command or a remote HTTP(S) endpoint — from the desktop UI, for servers that no registry (mcp_official / Smithery) lists. Surfaces as a "Custom servers" pane on the MCP Servers tab (Connections → MCP Servers).

Problem

The MCP Servers tab today can only install servers a registry lists. There is no way from the UI to connect a server you host yourself: a local npx/uvx command, or a private/internal HTTP MCP endpoint. The only workaround is hand-editing config outside the app, which doesn't integrate with the registry UI, the connection health toolbar, or the OAuth flow. The store schema already carries the needed columns (command, args_json, transport, deployment_url, enabled) — only the add/edit path and UI are missing.

Solution (optional)

Scope: core + app.

  • Core RPCs mcp_clients_add_custom / mcp_clients_update_custom writing an ordinary InstalledServer with a new ServerProvenance (registry vs hand-entered) column, reusing the existing MCP transport / OAuth / tool-safety code paths — no second MCP client.
  • UI: a side pane + add/edit modal on the MCP Servers tab.
  • Credentials are scope-bound (write-only env; stored secrets, including the OAuth bundle, are dropped and must be re-entered when the credential scope changes — transport switch or HTTP origin change — never carried across).

Acceptance criteria

  • [ ] Add local (stdio) server — command + args, launched and connectable
  • [ ] Add remote (HTTP) server — http/https URL, connectable including OAuth
  • [ ] Edit / remove a custom server; identity stable across a rename
  • [ ] Provenance — legacy rows backfill to registry; install cannot clobber a custom row
  • [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/ci-lite.yml).

Related

Implementation ready on a fork; PR to follow. That PR also carries a small, related MCP fix (cancelling the OAuth sign-in wait), tracked separately.

Implementation Plan

Triage Assessment

  • Valid feature request: users need a first-class UI to connect self-hosted MCP servers (local stdio commands or private HTTP endpoints) without hand-editing config files. The database schema already supports the needed columns — only the add/edit/remove UI and core RPCs are missing.
  • Medium-to-high user impact: MCP is a core extensibility surface; the inability to add custom servers from the UI is a significant gap for power users and tinkerers.
  • Not a duplicate: no other issue describes this feature. PR #5033 implements the feature and is currently open for review (also fixes #5032 as a bundled change).

Proposed Scope

  • Core Rust: src/openhuman/mcp_registry/custom.rs — mcp_clients_add_custom / mcp_clients_update_custom RPC handlers writing InstalledServer with ServerProvenance::Custom.
  • Store: additive provenance column (default 'registry', backfills existing installs). Transaction-safe credential-scope writes.
  • UI: app/src/components/channels/mcp/CustomServerFormModal.tsx + CustomServersPanel.tsx — side pane with add/edit modal on MCP Servers tab.
  • i18n: new strings across all 14 locales.

Implementation Steps

  1. Core: implement add_custom/update_custom in custom.rs — validation (reject non-http schemes, reserved env keys, duplicate headers), qualified_name as custom/<slug>.
  2. Store: additive provenance column migration, BEGIN IMMEDIATE transaction for row+env writes; install refuses Custom rows.
  3. UI: CustomServerFormModal.tsx with env editor (write-only contract, scope-bound), CustomServersPanel.tsx side pane. MCP tab widens to xl.
  4. i18n: new strings across locales.

Verification

  • Rust unit tests in custom.rs/store.rs.
  • E2E: mcp_clients_lifecycle steps 8–12 (transport-switch credential drop, suffix path).
  • Vitest: both components (add/edit, env-keep, transport re-scope, duplicate rejection, aria, busy-dismiss).
  • Coverage gate: cargo-llvm-cov diff coverage >= 80%.

Risks and Open Questions

  • Security: adding an RPC that runs a user-typed local command — strictly less exposed than the existing registry install→connect→spawn path, and behind the same tool-policy model. Credentials are scope-bound and never cross transport/origin change.

Acceptance Criteria

  • As listed in the issue body (five acceptance checkboxes).

yh928 avatar Jul 18 '26 01:07 yh928

Verified on main (6be58a9ab) — unimplemented; the schema claim checks out, with one wrinkle worth knowing before implementation

Not implemented. No custom-server path exists:

$ grep -rIn "mcp_clients_add_custom\|mcp_clients_update_custom\|ServerProvenance\|add_custom" --include='*.rs' src/
(no output)

The "schema already carries the columns" claim is accurate — InstalledServer (vendor/tinymcp/crates/tinymcp-bus/src/registry/types.rs:159-208) has:

claimed column present as
command pub command: String (:177) — "The launcher or binary. Empty for HTTP-remote installs."
args_json pub args: Vec<String> (:180)
transport pub transport: Transport (:200), defaulted so pre-existing rows load
enabled pub enabled: bool (:207), defaulted likewise
deployment_url a real DB column, folded into the transport on load

That last one is the wrinkle. deployment_url exists on disk but does not surface as a struct field — it becomes Transport::HttpRemote { url } (types.rs:76-84). The migration test is explicit: crates/tinymcp/tests/opens_an_existing_openhuman_database.rs:7 describes a database "predating the transport, deployment_url, and enabled columns", and :114 notes "deployment_url folded into the transport on the way over: an empty one …".

So acceptance criterion 2 (add a remote HTTP server) writes the URL through Transport::HttpRemote, not through a flat field — a small detail, but it decides the shape of the add/edit RPC payload.

Scope note: ServerProvenance is a vendor change

The plan proposes "a new ServerProvenance (registry vs hand-entered) column". InstalledServer lives in vendor/tinymcp, so that is a tinymcp change plus a submodule bump — not a local edit. Two consequences:

  1. The work is sequenced: tinymcp release → re-pin → openhuman RPC + UI. Worth reflecting in the issue so the estimate isn't read as single-PR.
  2. The provenance backfill criterion ("legacy rows backfill to registry") should use the same #[serde(default = "…")] pattern transport and enabled already use — both were added the same way and the migration test above proves the pattern works against real pre-existing databases. That makes the backfill nearly free and is the strongest argument for doing it in tinymcp rather than layering provenance on the openhuman side.

On the credential-scope rule

stored secrets, including the OAuth bundle, are dropped and must be re-entered when the credential scope changes — transport switch or HTTP origin change — never carried across

This is the right call and worth keeping explicit in review. InstalledServer deliberately stores env_keys (names only, per the type's own note) rather than values, so the discipline already exists in the type; the custom-server path needs to not break it. The related enabled doc is a useful contrast — turning a server off keeps stored credentials by design, so "disabled" and "credential scope changed" must stay distinct, or a user toggling a server off and on would be forced to re-enter secrets.

Status

PR #5033 is open (not draft, unmerged) and is this issue's implementation. It also carries the OAuth-wait cancellation fix tracked as #5032 — where I've noted separately that the PR's backdrop hunk has drifted from main (it patches an onMouseDown handler that closePolicy replaced) and will need a rebase.

Leaving open until #5033 merges.

YellowSnnowmann avatar Sep 11 '26 09:09 YellowSnnowmann