feat: import servers from .mcp.json, format JSON, clickable cards, values after create #32

Merged
marti merged 4 commits from feature/open-issues-29-31 into develop 2026-11-06 19:40:37 +01:00
Owner

Closes #29, closes #30, closes #31. Also adds importing a server from .mcp.json config.

Summary

 <NewServerPage>
   <ServerForm mode="create">
+    Import JSON button -> <ImportJsonModal>    # paste mcpServers config, pick a server
+      parseMcpJson()                            # mcpJson.ts: npx/uvx/remote -> form values
+    <Callout> "Filled in from <key>"            # plus notes, e.g. literal env values skipped
     Server type / Basics / Package | Endpoint / Variables
-      Instance value input                      # #31: values go on the Variables tab
   onSubmit
-    navigate tab=overview
+    navigate tab = has instance variables ? "variables" : "overview"

How .mcp.json maps onto the form:

key "miniflux"             -> name "Miniflux", slug "miniflux"
command npx | uvx          -> runtime; anything else is refused ("only npx and uvx run in the sandbox")
args  -y / --yes           -> dropped
      pkg@1.2.3, pkg==1.2  -> package + version (git+https#ref / @ref too)
      -p | --from pkg bin  -> package + command
      rest                 -> args, ${VAR} -> {{VAR}}
env   KEY: "${KEY}"        -> instance variable KEY, secret if KEY|TOKEN|SECRET|PASSWORD...
env   KEY: "literal"       -> variable KEY; value not carried, note says set it on the Variables tab
url / type http|sse        -> remote server, headers ${VAR} -> {{VAR}} + secret variable

Accepts {"mcpServers": ...}, VS Code's {"servers": ...}, or a single server entry.

  • #29: lib/json.ts formatJsonText() indents JSON bodies and JSON at the end of a log line. Used in server logs, the install log, last error, test errors, runner details and tool test output. Audit metadata objects are indented too. Copy buttons still copy the raw text.
  • #30: the portal server card's title link now stretches over the whole card (the pattern the dashboard stat tiles already use). The footer switch and action sit above it.

Evidence

  • Before: the create form had an "Instance value" input; logs showed {"level":"info","msg":...} on one line; only a card's title opened the server; there was no import.
    After: nix develop -c ./scripts/ci.sh passes: lint, typecheck, API 310 tests, runner 46, web 135, build, audit with 0 vulnerabilities.
mcpJson.test.ts            7 tests: npx + env, versions/args/literal env (value never in form),
                           uvx --from, remote sse + headers, bare entry, unsupported command, bad input
ServerForm.test.tsx        "fills the form from a pasted .mcp.json": paste -> Name, Slug, Package, Keys filled
                           create form has no "Instance value" input
json.test.ts               body, log-prefix line, non-JSON left alone

No screenshots: the dev API port is taken by the running mcphub container on this machine, so the UI was checked through tests only. Worth a look in the browser at the card hover and the import dialog.

Merge Danger

Door: two-way

SPA only, no API, schema or migration change. The API still accepts instance values on create (the admin MCP tools use it), so reverting restores the old form as it was.

Blast Radius: small

Admins can no longer type instance values while creating a server; they land on the Variables tab instead. On the portal, a click anywhere on a server card now navigates, apart from the footer controls.

🤖 Generated with Claude Code

Closes #29, closes #30, closes #31. Also adds importing a server from `.mcp.json` config. ## Summary ```diff <NewServerPage> <ServerForm mode="create"> + Import JSON button -> <ImportJsonModal> # paste mcpServers config, pick a server + parseMcpJson() # mcpJson.ts: npx/uvx/remote -> form values + <Callout> "Filled in from <key>" # plus notes, e.g. literal env values skipped Server type / Basics / Package | Endpoint / Variables - Instance value input # #31: values go on the Variables tab onSubmit - navigate tab=overview + navigate tab = has instance variables ? "variables" : "overview" ``` How `.mcp.json` maps onto the form: ```text key "miniflux" -> name "Miniflux", slug "miniflux" command npx | uvx -> runtime; anything else is refused ("only npx and uvx run in the sandbox") args -y / --yes -> dropped pkg@1.2.3, pkg==1.2 -> package + version (git+https#ref / @ref too) -p | --from pkg bin -> package + command rest -> args, ${VAR} -> {{VAR}} env KEY: "${KEY}" -> instance variable KEY, secret if KEY|TOKEN|SECRET|PASSWORD... env KEY: "literal" -> variable KEY; value not carried, note says set it on the Variables tab url / type http|sse -> remote server, headers ${VAR} -> {{VAR}} + secret variable ``` Accepts `{"mcpServers": ...}`, VS Code's `{"servers": ...}`, or a single server entry. - **#29:** `lib/json.ts` `formatJsonText()` indents JSON bodies and JSON at the end of a log line. Used in server logs, the install log, last error, test errors, runner details and tool test output. Audit metadata objects are indented too. Copy buttons still copy the raw text. - **#30:** the portal server card's title link now stretches over the whole card (the pattern the dashboard stat tiles already use). The footer switch and action sit above it. ## Evidence - **Before:** the create form had an "Instance value" input; logs showed `{"level":"info","msg":...}` on one line; only a card's title opened the server; there was no import. **After:** `nix develop -c ./scripts/ci.sh` passes: lint, typecheck, API 310 tests, runner 46, web 135, build, audit with 0 vulnerabilities. ```text mcpJson.test.ts 7 tests: npx + env, versions/args/literal env (value never in form), uvx --from, remote sse + headers, bare entry, unsupported command, bad input ServerForm.test.tsx "fills the form from a pasted .mcp.json": paste -> Name, Slug, Package, Keys filled create form has no "Instance value" input json.test.ts body, log-prefix line, non-JSON left alone ``` No screenshots: the dev API port is taken by the running `mcphub` container on this machine, so the UI was checked through tests only. Worth a look in the browser at the card hover and the import dialog. ## Merge Danger **Door:** two-way SPA only, no API, schema or migration change. The API still accepts instance values on create (the admin MCP tools use it), so reverting restores the old form as it was. **Blast Radius:** small Admins can no longer type instance values while creating a server; they land on the Variables tab instead. On the portal, a click anywhere on a server card now navigates, apart from the footer controls. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The create form only defines variables now. A new server with instance
variables opens on its Variables tab, where the values are filled in.

Closes #31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title link stretches over the card; the footer switch and action
stay above it and keep their own behaviour.

Closes #30

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Server and install logs, errors, runner details, tool test output and
audit metadata show JSON indented, including JSON at the end of a log
line. Copy buttons keep the raw text.

Closes #29

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(web): import a server from .mcp.json config
All checks were successful
CI / check (pull_request) Successful in 5m49s
13af7d4e66
The Add a server form takes a pasted mcpServers config (Claude Code,
Claude Desktop, Cursor, VS Code shapes) and fills in its fields: npx and
uvx packages with version, binary and args, or remote servers with URL,
transport and headers. Env entries and ${VAR} references become
variables; literal env values are not carried over and are set on the
Variables tab. Configs listing several servers let the admin pick one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marti merged commit ad0c872553 into develop 2026-11-06 19:40:37 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marti/mcphub!32
No description provided.