# Init MCP

> Use when setting up the plugin for the first time, installing dependencies, configuring MCP servers, or when the user says '初始化', 'init', 'setup', '装环境', '配置', 'install', 'configure', 'first time', '首次使用'. Handles both dependency marketplace installation and MCP server setup.

- Skill: `ldm2060/init-mcp` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add ldm2060/init-mcp`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ldm2060/init-mcp/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: ldm2060 (https://skillmd.com/u/ldm2060)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ldm2060/init-mcp

---


# Init MCP

One-shot plugin setup: install dependency marketplaces → install Python deps → write `.mcp.json` → register hooks → regenerate skill.json metadata → verify each server → report optional secrets.

## Step 1: Install dependency marketplaces

This plugin depends on skills from 5 third-party marketplaces. If they are not added, plugin dependencies will stay unresolved (skills from those sources will be missing). The `superpowers` dependency uses Claude Code's built-in `claude-plugins-official` marketplace.

Check whether each marketplace is already added by looking at the user's installed plugins. For each missing marketplace, instruct the user to run:

```
/plugin marketplace add Imbad0202/academic-research-skills
/plugin marketplace add Lylll9436/Paper-Polish-Workflow-skill
/plugin marketplace add multica-ai/andrej-karpathy-skills
/plugin marketplace add anthropics/skills
/plugin marketplace add Orchestra-Research/AI-Research-SKILLs
```

These are `/plugin` commands that must be typed by the user in the Claude Code prompt — they cannot be run via Bash. After the user adds all marketplaces, proceed to Step 2.

If all marketplaces are already present, skip this step.

## Step 2: Run the installer script

`self/install.py` is a cross-platform Python script that handles MCP and hook setup.

```bash
python self/install.py
```

Supported flags:
- `--target /path` install to a non-default workspace
- `--dry-run` print plan without writing files
- `--skip-deps` skip pip install
- `--skip-verify` skip the MCP startup handshake

## What the script does

1. **Report dependency marketplaces** — print the prerequisite `plugin marketplace add` commands.
2. **Install Python deps** — read `self/mcp/requirements.txt`, run `pip install` (default: `pdfplumber`).
3. **Write `.mcp.json`** — scan `self/mcp/servers/` for every `server.py`, generate a Claude-Code-style `.mcp.json` with **absolute paths** to avoid `${workspaceFolder}`-expansion failures.
4. **Register hooks** — inject SessionStart, PreToolUse, UserPromptSubmit, and PostToolUse hooks into `.claude/settings.json`. Idempotent; no duplicates.
5. **Register conductor agent** — set `agent: copilot-conductor` in `.claude/settings.json`.
6. **Regenerate skill.json metadata** — required by Claude Code 2.1.142+. Calls `self/scripts/generate-skill-json.py` to walk every skill and write a sibling `skill.json` from its SKILL.md frontmatter.
7. **Verify MCP startup** — send `initialize` JSON-RPC to each server and confirm a response.
8. **Report optional secrets** — check `ARXIVSUB_SKILL_KEY`; if unset, warn but do not block install.

## Trigger scenarios

- First-time use after a fresh clone → `/init-mcp`
- An MCP server is unresponsive → `/init-mcp` (the script rewrites config and re-verifies)
- After adding a new dependency marketplace → `/init-mcp` to re-verify everything

## Servers currently under `self/mcp/servers/`

The repo-root `.mcp.json` is generated by scanning `self/mcp/servers/` — there is no static `self/mcp/mcp.json`.

| Server | Deps | Description |
|---|---|---|
| `ai-scientist` | stdlib only | runtime check, experiment directory browsing (non-model) |
| `arxiv-search` | stdlib only | arXiv search, 3-second rate-limit + 429 retry |
| `arxivsub-search` | stdlib + `ARXIVSUB_SKILL_KEY` | arXiv + top-venue joint search |
| `dblp-bib` | stdlib only | DBLP BibTeX query, 1.5-second rate-limit |
| `google-scholar` | stdlib only | Scholar metadata / citation formats |
| `pdf-text` | `pdfplumber` (preferred) / `PyPDF2` (fallback) | Local PDF text extraction |

## After installation

1. **Restart Claude Code** (or run `/clear`) so the new MCP config takes effect.
2. In a fresh session, verify: call `arxiv-search.search_arxiv` or `dblp-bib.search_dblp_bibtex` to confirm tool registration.
3. If `ARXIVSUB_SKILL_KEY` is unset, `arxivsub-search` returns `missing_api_key`; configure via env var or `.env` as the warning suggests.

## Notes

- **Idempotent**: the script can run multiple times; existing hooks are not duplicated; existing `.mcp.json` is overwritten to stay in sync with `self/mcp/servers/`.
- **Does not touch global settings**: writes only project-level `.claude/settings.json`; never touches `~/.claude/settings.json`.
- **Other MCP entries**: the current implementation overwrites `.mcp.json`; if the user has non-`self/` MCP entries there, they must be merged manually. Use `python self/install.py --dry-run` to inspect the planned write.

