W1: Document user-scope MCP config location in ~/.claude/CLAUDE.md —
adds verification and re-registration commands, warns against
settings.json (saves ~12K tokens per registration session).
W2: scripts/register_project.sh + make register-project —
5-step automation: API health → topic lookup → MCP check →
CLAUDE.md from template → progress event.
W3: state-hub/scripts/project_claude_md.template —
parameterised CLAUDE.md with {PROJECT_NAME}/{DOMAIN}/{TOPIC_ID}
placeholders; used by register_project.sh.
W4: Add custodian_topic_id + domain to all 6 canon project charters —
lets agents grep for topic IDs without touching the API.
W5: state-hub/mcp_server/TOOLS.md — compact 30-line tool reference
card; replaces reading the full server.py (~350 lines).
W6: Switch .mcp.json to absolute path + PYTHONPATH env so cwd is not
required; add scripts/patch_mcp_cwd.py for post-registration fix.
Update ~/.claude.json to match (cwd kept for belt-and-suspenders).
W7 (SessionStart hook) deferred: no SessionStart hook type in Claude
Code; PreToolUse with empty matcher fires before every tool call.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Patch ~/.claude.json to add the cwd field to the state-hub MCP entry.
|
|
|
|
claude mcp add-json silently drops the cwd field. Run this script after
|
|
any claude mcp add-json call to restore it.
|
|
|
|
Usage: python3 scripts/patch_mcp_cwd.py
|
|
"""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
CLAUDE_JSON = Path.home() / ".claude.json"
|
|
STATE_HUB_DIR = Path(__file__).resolve().parent.parent # state-hub/
|
|
|
|
def main() -> None:
|
|
if not CLAUDE_JSON.exists():
|
|
print(f"ERROR: {CLAUDE_JSON} not found. Run 'claude mcp add-json' first.")
|
|
raise SystemExit(1)
|
|
|
|
config = json.loads(CLAUDE_JSON.read_text())
|
|
servers = config.setdefault("mcpServers", {})
|
|
|
|
if "state-hub" not in servers:
|
|
print("ERROR: 'state-hub' not found in ~/.claude.json. Run 'claude mcp add-json' first.")
|
|
raise SystemExit(1)
|
|
|
|
entry = servers["state-hub"]
|
|
cwd_str = str(STATE_HUB_DIR)
|
|
|
|
if entry.get("cwd") == cwd_str:
|
|
print(f"OK: cwd already set to {cwd_str}")
|
|
return
|
|
|
|
entry["cwd"] = cwd_str
|
|
CLAUDE_JSON.write_text(json.dumps(config, indent=2) + "\n")
|
|
print(f"Patched: ~/.claude.json state-hub.cwd = {cwd_str}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|