Skip to content

setup.sh: fix MCP-caching install hang and wire skills/MCP into the engine#31

Open
strandline wants to merge 6 commits into
beita6969:mainfrom
strandline:fix/setup-hang-and-wiring
Open

setup.sh: fix MCP-caching install hang and wire skills/MCP into the engine#31
strandline wants to merge 6 commits into
beita6969:mainfrom
strandline:fix/setup-hang-and-wiring

Conversation

@strandline

Copy link
Copy Markdown

Summary

Two fixes to setup.sh, both found while installing ScienceClaw on macOS.

1. Install hangs on MCP server caching

The Phase 4 cache-warming loop runs uvx <server> --help, but the stdio MCP servers ignore --help and start their JSON-RPC loop, which blocks reading stdin forever (no EOF, no timeout). In an interactive terminal the installer hangs at the first such server (arxiv-mcp-server).

Fix:

  • Redirect each invocation's stdin from /dev/null so the server gets an immediate EOF and exits cleanly.
  • Add a portable run_with_timeout backstop (a default macOS has no GNU timeout).
  • Run openclaw doctor from $HOME instead of the repo dir, where npx openclaw otherwise resolves the repo's own (unbuilt) openclaw package and the config-validation step silently no-ops with "command not found".

2. Skills + MCP servers are never wired into the engine

setup.sh copies the skills and MCP servers into ~/clawd and caches the MCP packages via uvx, but nothing registers them with OpenClaw: onboarding sets the agent workspace to ~/.openclaw/workspace, and the MCP servers never appear in ~/.openclaw/openclaw.json. The result is a fresh install that runs as vanilla OpenClaw with the science content orphaned on disk.

Fix: a wire_research_stack step (Phase 5) that

  • registers ~/clawd/skills via skills.load.extraDirs,
  • adds the arxiv, semantic-scholar, biomcp, deep-research, chembl, and arxiv-latex MCP servers with openclaw mcp add (probe-validated; each non-fatal so one failure never aborts the install),
  • prints the zotero command, which needs the user's API credentials.

All openclaw calls run from $HOME (to avoid the local-bin trap above) and are bounded by run_with_timeout.

Validation

  • Hang fix: re-ran ./setup.sh on macOS — Phase 4 no longer hangs, all MCP servers cache, install completes (exit 0).
  • Wiring: ran the exact openclaw config set + openclaw mcp add commands the step emits against the published engine (2026.6.1). openclaw mcp probe reports all 6 servers connecting (132 tools); openclaw skills check shows the science skills loading via the extra dir.
  • bash -n setup.sh passes; a dry-trace confirms wire_research_stack emits exactly the intended commands.

No behavior change for users who already have a working setup — the new step is additive and re-runnable (config set is idempotent; a duplicate mcp add just warns).

🤖 Generated with Claude Code

strandline and others added 2 commits June 5, 2026 10:51
The MCP cache-warming loop ran `uvx <server> --help`, but stdio MCP
servers ignore --help and start their JSON-RPC loop, blocking on the
terminal's stdin forever (no EOF, no timeout). This hung the installer
at arxiv-mcp-server.

- Redirect each invocation's stdin from /dev/null so servers get an
  immediate EOF and exit cleanly
- Add a portable run_with_timeout wrapper (default macOS lacks GNU
  timeout) as a backstop
- Run `openclaw doctor` from $HOME instead of the repo dir, where npx
  otherwise resolves to this local package's unbuilt bin and silently
  no-ops the config validation

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
setup.sh staged the skills and MCP servers under ~/clawd but never
registered them with OpenClaw, so a fresh install produced a vanilla
OpenClaw with the science content orphaned on disk.

Add a wire_research_stack step (Phase 5) that:
- registers ~/clawd/skills via skills.load.extraDirs
- adds the arxiv, semantic-scholar, biomcp, deep-research, chembl, and
  arxiv-latex MCP servers (probe-validated, each non-fatal so one
  failure never aborts the install)
- prints the zotero command, which needs the user's API credentials

All openclaw calls run from $HOME (not the repo) to avoid resolving the
repo's own unbuilt `openclaw` bin, and are bounded by run_with_timeout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

wire_research_stack now installs SCIENCE.md (the ScienceClaw operating
protocol and persona) as the workspace AGENTS.md, so the agent boots as
ScienceClaw instead of OpenClaw's generic default. Previously the installer
staged skills + MCP servers but left the agent with the stock OpenClaw
identity, so it described itself generically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@strandline

Copy link
Copy Markdown
Author

Added a commit that deploys SCIENCE.md as the agent's instructions (workspace AGENTS.md). Same root cause as the skills/MCP wiring: the installer staged SCIENCE.md but never made it the agent's persona, so a fresh install booted with OpenClaw's generic identity instead of ScienceClaw.

strandline and others added 3 commits June 5, 2026 15:59
The deployed SCIENCE.md (as AGENTS.md) conflicted with OpenClaw's generic
SOUL.md ("be a friendly general assistant"), so the agent treated the
research protocol as optional. wire_research_stack now writes a SOUL.md that
defers to AGENTS.md/SCIENCE.md as authoritative, so the agent fully adopts
the research persona.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Last change deployed the full 30KB SCIENCE.md as the workspace AGENTS.md.
OpenClaw bootstraps AGENTS.md into every session under a per-file budget
(agents.defaults.bootstrapMaxChars, default 20000), so ~1/3 of the protocol
was silently truncated each session — and sub-agents, which see only
AGENTS.md, got a cut-off persona.

Split the two roles the engine expects:
  - SCIENCE.bootstrap.md (new, ~13KB) -> workspace AGENTS.md: the lean,
    every-session persona + protocol (critical sections verbatim; the
    database/visualization/LaTeX catalog condensed to a pointer). Fits the
    budget, no truncation.
  - SCIENCE.md -> workspace SCIENCE.md: the full operating manual, which
    AGENTS.md instructs the agent to read on demand (kept out of the
    bootstrap budget).

Fallback keeps the old behavior (SCIENCE.md as AGENTS.md) but raises
bootstrapMaxChars to 32000 so it is not truncated. Clears the
core/doctor/bootstrap-size lint warning.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SCIENCE.md's project-directory example still pointed outputs at
~/clawd/projects/ — the same orphaned dir this PR removes elsewhere, and
not the engine workspace. It also disagreed with the corrected
workspace-relative path in the lean AGENTS.md. Make it workspace-relative
so the every-session bootstrap and the on-demand manual agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant