Skip to content

Onboarding: optional MCP-catalog install step - #126

Merged
FMXExpress merged 2 commits into
mainfrom
claude/onboard-mcp
Jun 4, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/onboard-mcp

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

After provider + model + API-key prompts, pasclaw onboard now walks through the 5 built-in MCP catalogue entries (replicate, digitalocean-apps, digitalocean-databases, runpod-docs, huggingface), prompting Enable [y/N]: (default off, picoclaw-style — never preloaded without explicit opt-in) and capturing the API token inline.

What you see

Optional: enable built-in MCP servers
─────────────────────────────────────
These give the agent extra capabilities via the MCP protocol.
Skip what you don't want — you can install later with `pasclaw mcp install <name>`.

  replicate
  Run AI models (text/image/video/audio) on Replicate — 5000+ models.
  https://replicate.com/docs/reference/mcp
  Enable [y/N]: y
  REPLICATE_API_TOKEN (paste, or blank to skip auth): r8_xxxxxxxxxxxxx
  ✓ installed replicate

  digitalocean-apps
  Manage DigitalOcean App Platform deployments.
  …
  Enable [y/N]: n
  …

  runpod-docs
  Search RunPod documentation. No auth required.
  Enable [y/N]: y
  ✓ installed runpod-docs (no auth)

Resulting config.json:

"mcp_servers": [
  { "name": "replicate",   "cmd": "https://mcp.replicate.com/mcp",  "args": "Bearer r8_xxx", "env": "", "enabled": true },
  { "name": "runpod-docs", "cmd": "https://docs.runpod.io/mcp",     "args": "",              "env": "", "enabled": true }
]

Same shape pasclaw mcp install <name> writes today, so list / show / test / remove all work unchanged.

Behaviour notes

  • Already-installed entries print (already installed — skipping) so re-running onboard preserves whatever the user set up via pasclaw mcp install earlier.
  • When the env var is already set (e.g. REPLICATE_API_TOKEN exported in the shell), the prompt is skipped and the env value is used — matches pasclaw mcp install for symmetry.
  • When the env var isn't set, prompt for the token. Blank input installs with no auth and warns to re-run with env set.
  • Auth-less entries (runpod-docs today) skip the token prompt and install with an empty Args.

Wiring

  • New helper FormatAuthHeaderFromToken in PasClaw.MCP.Catalog — sibling to ResolveAuthHeader. The existing function sources the token from the env var; the new one takes it as an argument so onboarding can prompt the user and persist the resulting header directly.
  • UpsertCatalogMCP private helper in Cmd.Onboard.pas mirrors the upsert logic in Cmd.MCP.DoInstall (refresh existing entry by name, otherwise append).
  • PromptMCPInstalls iterates KnownMCPServers and drives the prompts; called between UpsertProvider and SaveConfig.
  • Replicate catalogue Desc updated to mention the 5000+ model count so both pasclaw mcp catalog and the onboarding prompt surface it. README MCP-catalog row follows.

Test plan

  • FPC build clean (443879 lines)
  • make smoke 11/11 OK
  • Live scripted onboarding via stdin: picks Anthropic (default), enables Replicate with a test token + runpod-docs (no auth), declines the others — resulting config.json matches the example above
  • Manual: run pasclaw onboard in a real terminal, walk through interactively, then pasclaw mcp list to confirm both new servers show up enabled

Generated by Claude Code

After provider + model + API-key prompts, `pasclaw onboard` now
walks through the 5 built-in MCP catalogue entries (replicate,
digitalocean-apps, digitalocean-databases, runpod-docs, huggingface),
prompting `Enable [y/N]:` (default off, picoclaw-style — never
preloaded without explicit opt-in) and capturing the API token
inline. Selected entries get upserted into Cfg.MCPServers with a
literal "Bearer <token>" Authorization header in the Args field —
same shape `pasclaw mcp install <name>` writes today, so list /
remove / test / show all keep working.

Behaviour:
  - Already-installed entries print "(already installed —
    skipping)" so re-running onboard preserves whatever the user
    set up via `pasclaw mcp install` earlier.
  - When the env var is already set (e.g. REPLICATE_API_TOKEN
    exported in the shell), the prompt is skipped and the env
    value is used — matches `pasclaw mcp install` for symmetry.
  - When the env var isn't set, prompt for the token. Blank input
    installs with no auth and warns to re-run with env set.
  - Auth-less entries (runpod-docs today) skip the token prompt
    entirely and install with an empty Args.

Wiring:
  - New helper FormatAuthHeaderFromToken in PasClaw.MCP.Catalog —
    sibling to ResolveAuthHeader. ResolveAuthHeader sources the
    token from the env var; the new helper takes it as an
    argument so the onboarding flow can prompt the user and persist
    the resulting header directly without requiring the env var.
  - UpsertCatalogMCP private helper in Cmd.Onboard.pas mirrors the
    upsert logic in Cmd.MCP.DoInstall (refresh existing entry by
    name, otherwise append).
  - PromptMCPInstalls iterates KnownMCPServers, drives the prompts.
  - Replicate catalogue Desc updated to mention the 5000+ model
    count so `pasclaw mcp catalog` and the onboarding prompt both
    surface it. README MCP-catalog table follows.

Verified end-to-end with a scripted stdin run that picks Anthropic
(default), enables replicate (with a test token) + runpod-docs (no
auth), declines the others. Resulting config.json shows the
Replicate entry with `args: "Bearer r8_test_..."` and the runpod
entry with `args: ""`, both `enabled: true`. Build + smoke 11/11
clean.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc82a959c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cmd/PasClaw.Cmd.Onboard.pas Outdated
end
else
begin
Token := Trim(ReadLineEcho(' ' + Entry.EnvVar + ' (paste, or blank to skip auth): '));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Read pasted MCP tokens without terminal echo

When an MCP auth environment variable is absent and the user opts in, this prompt reads the pasted API token with ReadLineEcho, so the credential remains visible in terminal scrollback and can be captured by terminal recording, screen sharing, or shared-session logs. Use a no-echo secret-input helper for MCP tokens before formatting and persisting the authorization header.

Useful? React with 👍 / 👎.

P2 — Codex flagged the MCP token paste during onboarding: pasted
credentials remained visible in terminal scrollback, screen
recordings, and shared-session logs. Fix: new ReadSecretLine
helper in PasClaw.CliUI, used by both the MCP token prompts and
the original provider API-key prompt (which had the identical
exposure pre-existing — extending the fix while we're here).

Implementation:
  - POSIX path uses BaseUnix + TermIO. tcgetattr to snapshot current
    termios, clear the ECHO flag with tcsetattr(TCSANOW), ReadLn
    inside a try/finally, restore termios on the way out. ICANON
    stays on so backspace still works and the line is delivered on
    Enter — only echo is suppressed.
  - Windows path uses GetConsoleMode / SetConsoleMode to disable
    ENABLE_ECHO_INPUT around the ReadLn, with the same try/finally
    restore.
  - Both paths emit a trailing WriteLn when no-echo was in effect
    so the next prompt starts on a fresh line (the user's Enter
    was suppressed visually).
  - When tcgetattr / GetConsoleMode fails — most commonly stdin
    being a pipe in scripted tests — the helper falls through to
    a plain echoing ReadLn so non-interactive automation keeps
    working unchanged. Verified end-to-end with the same scripted
    onboarding from PR #126 description.
  - Unknown-platform branch (neither UNIX nor MSWINDOWS) falls
    through to plain ReadLn — same behaviour as today, just no
    no-echo protection.

Updated Cmd.Onboard.pas to call ReadSecretLine for:
  - the provider API key prompt (originally ReadLineEcho)
  - the MCP env-var token prompt (the one Codex flagged)

Build clean (443958 lines), smoke 11/11 OK.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit 6736d01 into main Jun 4, 2026
FMXExpress pushed a commit that referenced this pull request Jun 9, 2026
Three issues from Codex's review of PR #203, all legit.

1. AV in --no-tools mode (PR #203 review, P2).
   Reg can be intentionally nil ("pasclaw agent --no-tools"); the
   router call evaluated Reg.Names unconditionally and crashed every
   non-offline turn in that mode, even with auto_router.enabled=False.
   Fix: pass a nil tool array when Reg is nil. The classifier already
   tolerates an empty list -- write/run tool-mix gate just doesn't
   fire, which is correct for --no-tools (there ARE no tools).
   Test: TestNilToolsArraySafe.

2. Easy provider sent the primary's model (PR #203 review, P2).
   When auto_router.easy_model was omitted, the caller left
   LoopCfg.Model set to the primary's value from BuildLoopConfig,
   so a routed turn shipped e.g. claude-opus-4-8 to Groq and 4xx'd.
   Fix: RouteProvider now resolves the model itself in three steps
   (explicit override -> per-provider stored Model -> catalog
   DefaultModel) and refuses to route if all three are empty
   rather than handing the loop something it'll fail on. Caller
   no longer needs the empty-string branch -- LoopCfg.Model is
   always set on routed turns.
   Tests: TestRouteProviderFallsBackToProviderStoredModel (step 2),
   TestRouteProviderResolvesCatalogDefault (step 3),
   TestRouteProviderRefusesWithoutResolvableModel (refusal).

3. Fallback API key was echoed (PR #203 review, P2).
   PromptAutoRouter used ReadLineEcho for the API-key prompt, so
   the pasted credential landed in terminal scrollback and screen
   recordings. The primary provider path in the same command uses
   ReadSecretLine for the identical prompt; the fallback prompt
   now does the same. (Same exposure pattern Codex flagged on
   PR #126 for MCP tokens.)
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.

2 participants