From f0a1a93b718c415e0b1fed4879b3a1ff2e831683 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 20 Sep 2026 11:09:11 +0000 Subject: [PATCH] =?UTF-8?q?[fork=20demo=20=E2=80=94=20not=20for=20upstream?= =?UTF-8?q?]=20Wire=20stdio=20diffusers-docs=20MCP=20for=20Cloud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default mcp.json is search_docs over stdio, not Hub HTTP. Cloud dropdown is diffusers-docs-mcp; the launcher finds ramp-kit from any cwd. Co-authored-by: ale93.moro --- .cursor/commands/search-docs.md | 12 +++------ .cursor/environment.json | 3 ++- .cursor/mcp-diffusers-docs.py | 42 ++++++++++++++++++++++++----- .cursor/mcp.json | 11 +++++++- .cursor/mcp.optional.json | 2 +- .cursor/skills/search-docs/SKILL.md | 10 +++---- OVERLAY.md | 9 +++++-- 7 files changed, 63 insertions(+), 26 deletions(-) diff --git a/.cursor/commands/search-docs.md b/.cursor/commands/search-docs.md index 9bfe92bf0..92b618bbf 100644 --- a/.cursor/commands/search-docs.md +++ b/.cursor/commands/search-docs.md @@ -2,13 +2,8 @@ Usage: `/search-docs ` -Prefer source + gate first (MCP is opt-in; `.cursor/mcp.json` is empty): - -- `src/diffusers/schedulers/scheduling_euler_discrete.py` -- `src/diffusers/schedulers/scheduling_ddpm.py` -- `ramp-kit/conventions/rules.yaml` - -Then, optional CLI (same server as MCP, no OAuth): +Prefer `ramp-kit/conventions/rules.yaml` + the gate. MCP is stdio +`diffusers-docs` (Cloud dropdown: `diffusers-docs-mcp`). No Hub HTTP. ```bash python3 ramp-kit/tools/docs_mcp_server.py --query $1 @@ -20,5 +15,4 @@ If `$1` is empty: python3 ramp-kit/tools/docs_mcp_server.py --query "scheduler set_timesteps step SchedulerMixin register_to_config" ``` -Provenance should say `diffusers checkout`, not `bundled snapshot`. If the -MCP tool `search_docs` is in your list, call that instead. +If the MCP tool `search_docs` is in your list, call that instead. diff --git a/.cursor/environment.json b/.cursor/environment.json index 1f7395a6a..5117351f3 100644 --- a/.cursor/environment.json +++ b/.cursor/environment.json @@ -1,5 +1,6 @@ { - "install": "if [ ! -d ramp-kit/.git ]; then git clone --depth 1 https://github.com/alex-16moro/diffuser_agent.git ramp-kit; fi && pip install -r ramp-kit/requirements.txt && python3 ramp-kit/tools/docs_mcp_server.py --selftest", + "install": "if [ ! -d ramp-kit/.git ]; then git clone --depth 1 https://github.com/alex-16moro/diffuser_agent.git ramp-kit; fi && pip install -r ramp-kit/requirements.txt && bash ramp-kit/.cursor/install-docs-mcp.sh && python3 ramp-kit/tools/docs_mcp_server.py --selftest", + "start": "bash ramp-kit/.cursor/install-docs-mcp.sh", "repositoryDependencies": [ "github.com/alex-16moro/diffuser_agent" ] diff --git a/.cursor/mcp-diffusers-docs.py b/.cursor/mcp-diffusers-docs.py index 2b6aa4f7f..9da6c2916 100755 --- a/.cursor/mcp-diffusers-docs.py +++ b/.cursor/mcp-diffusers-docs.py @@ -2,9 +2,13 @@ """Launch diffusers-docs MCP from any cwd. Cloud Agent stdio cannot set `cwd` and does not expand `${workspaceFolder}`. -This launcher walks cwd, git root, /workspace, and its own path until it finds -`tools/docs_mcp_server.py`, then execs it. Desktop and Cloud then share one -command: `python3 -u .cursor/mcp-diffusers-docs.py`. +The dashboard command is often `python3 -u .cursor/mcp-diffusers-docs.py`, +spawned from the workspace root (e.g. `/agent`), not the git repo. This +launcher walks cwd, git root, `/agent/repos/*`, `/workspace`, and its own +path until it finds `tools/docs_mcp_server.py`, then execs it. + +Desktop and Cloud share: `python3 -u .cursor/mcp-diffusers-docs.py`. +Cloud PATH fallback after install: `diffusers-docs-mcp`. """ from __future__ import annotations @@ -14,6 +18,17 @@ from pathlib import Path +def _children(base: Path): + try: + if not base.is_dir(): + return + for child in base.iterdir(): + if child.is_dir(): + yield child + except OSError: + return + + def _candidates(): out: list[Path] = [] here = Path(__file__).resolve().parent @@ -25,7 +40,19 @@ def _candidates(): val = os.environ.get(key) if val: out.append(Path(val)) - out.append(Path("/workspace")) + out.append(Path(val) / "ramp-kit") + for base in ( + Path("/agent"), + Path("/agent/repos"), + Path("/workspace"), + Path("/workspace/repos"), + here.parent / "repos", + cwd / "repos", + ): + out.append(base) + for child in _children(base): + out.append(child) + out.append(child / "ramp-kit") try: top = subprocess.check_output( ["git", "rev-parse", "--show-toplevel"], @@ -34,6 +61,7 @@ def _candidates(): ).strip() if top: out.append(Path(top)) + out.append(Path(top) / "ramp-kit") except (OSError, subprocess.CalledProcessError): pass seen: set[Path] = set() @@ -55,12 +83,12 @@ def main(argv: list[str] | None = None) -> int: if script.is_file(): os.chdir(root) sys.argv = [str(script), "--serve", *extra] - # runpy would work; exec keeps stdin/stdout as the MCP pipes. os.execv(sys.executable, [sys.executable, "-u", str(script), "--serve", *extra]) sys.stderr.write( "diffusers-docs MCP: could not find tools/docs_mcp_server.py " - f"(cwd={Path.cwd()}). From the repo root run: " - "python3 -u .cursor/mcp-diffusers-docs.py\n" + f"(cwd={Path.cwd()} file={Path(__file__).resolve()}). " + "Install the PATH shim: bash .cursor/install-docs-mcp.sh " + "then spawn `diffusers-docs-mcp`.\n" ) return 1 diff --git a/.cursor/mcp.json b/.cursor/mcp.json index da39e4ffa..cbf2bc837 100644 --- a/.cursor/mcp.json +++ b/.cursor/mcp.json @@ -1,3 +1,12 @@ { - "mcpServers": {} + "mcpServers": { + "diffusers-docs": { + "type": "stdio", + "command": "python3", + "args": ["-u", ".cursor/mcp-diffusers-docs.py"], + "env": { + "PYTHONUNBUFFERED": "1" + } + } + } } diff --git a/.cursor/mcp.optional.json b/.cursor/mcp.optional.json index ba79ce1a4..9080a649d 100644 --- a/.cursor/mcp.optional.json +++ b/.cursor/mcp.optional.json @@ -3,7 +3,7 @@ "diffusers-docs": { "type": "stdio", "command": "python3", - "args": ["-u", "/workspace/.cursor/mcp-diffusers-docs.py"], + "args": ["-u", ".cursor/mcp-diffusers-docs.py"], "env": { "PYTHONUNBUFFERED": "1" } diff --git a/.cursor/skills/search-docs/SKILL.md b/.cursor/skills/search-docs/SKILL.md index 75fd9c762..ebcd8c2e3 100644 --- a/.cursor/skills/search-docs/SKILL.md +++ b/.cursor/skills/search-docs/SKILL.md @@ -1,6 +1,6 @@ --- name: search-docs -description: Optional docs CLI for this diffusers checkout. Prefer scheduler source + the gate; MCP is opt-in. +description: Optional docs CLI for this diffusers checkout. Prefer the gate; MCP is stdio search_docs. --- # Search this library's docs @@ -9,7 +9,7 @@ description: Optional docs CLI for this diffusers checkout. Prefer scheduler sou python3 ramp-kit/tools/docs_mcp_server.py --query "" ``` -Cite provenance (`diffusers checkout` vs bundled snapshot). Prefer reading -`src/diffusers/schedulers/scheduling_euler_discrete.py` and -`scheduling_ddpm.py` first. `ramp-kit/conventions/rules.yaml` is the gate. -`.cursor/mcp.json` is empty by default. +Cite provenance (`diffusers checkout` vs bundled snapshot). +`ramp-kit/conventions/rules.yaml` is the gate. +`.cursor/mcp.json` is stdio `diffusers-docs` only (no Hub HTTP). +Cloud dropdown: `diffusers-docs-mcp`. diff --git a/OVERLAY.md b/OVERLAY.md index cada42df5..150386a4e 100644 --- a/OVERLAY.md +++ b/OVERLAY.md @@ -22,8 +22,13 @@ The first contribution is what `ramp-kit/conventions/rules.yaml` checks: Docs search and reading `scheduling_euler_discrete.py` / `scheduling_ddpm.py` are how the *kit* verified the YAML. They are not part of the first PR. -`.cursor/mcp.json` is **empty by default** so Cloud launches do not hit Hub -OAuth or stdio cwd failures. Opt-in servers: `.cursor/mcp.optional.json`. +`.cursor/mcp.json` ships **stdio `diffusers-docs` only** (`python3 -u +.cursor/mcp-diffusers-docs.py`). Do not enable Hub HTTP MCP (OAuth). Cloud +dropdown: `diffusers-docs-mcp` (PATH shim from `install-docs-mcp.sh`) or the +same python3 command. The launcher finds `ramp-kit/tools/docs_mcp_server.py` +from `/agent` as well as the repo root. + +Hub HTTP and extra servers stay in `.cursor/mcp.optional.json`. ## Demo (Cloud Agent)