From d921724eb184b19328ff8f7c18bd453795a51a5e Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sun, 18 Oct 2026 05:04:54 -0500 Subject: [PATCH 1/2] mcpx: give mcpx-agy an examples/ subdir so sep-2640 is testable (#268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The conformance suite's sep-2640 directory check samples the first skill skills/list returns (mcpx-agy, sorted by URI) and counts its 'unttestable' result as FAILURE because mcpx-agy had no subdirectory — server-all was permanently red at 271/1. Port of dezren39/nix#395 (nix#389): genuine examples/ for mcpx-agy, SKILL.md pointer, and a guard test replicating the suite's sampling. --- pkgs/mcpx/internal/mcpserver/skills_test.go | 33 +++++++++++++++++++ .../plugin/opencode/skills/mcpx-agy/SKILL.md | 3 ++ .../skills/mcpx-agy/examples/README.md | 15 +++++++++ .../mcpx-agy/examples/chain-docs-and-code.ts | 29 ++++++++++++++++ .../skills/mcpx-agy/examples/compact-call.ts | 19 +++++++++++ 5 files changed, 99 insertions(+) create mode 100644 pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md create mode 100644 pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/chain-docs-and-code.ts create mode 100644 pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/compact-call.ts diff --git a/pkgs/mcpx/internal/mcpserver/skills_test.go b/pkgs/mcpx/internal/mcpserver/skills_test.go index 71fa6aabd1..1a988cd475 100644 --- a/pkgs/mcpx/internal/mcpserver/skills_test.go +++ b/pkgs/mcpx/internal/mcpserver/skills_test.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "os" "path/filepath" + "strings" "testing" "github.com/dezren39/mcpx/internal/mcpserver" @@ -276,6 +277,38 @@ func TestDirectoryReadListsEveryDirectoryOnDisk(t *testing.T) { } } +// The conformance suite's sep-2640 directory check samples the first +// skill skills/list returns (handleSkills sorts by URI) and requires a +// subdirectory child to exercise the inode/directory case (#268). If that +// skill has no subdirectory, the suite records the check as FAILURE +// ("not testable"), keeping server-all permanently red. Guard the exact +// sampling the suite does so renaming or reordering skills cannot +// silently re-break it. (Same defect as dezren39/nix#389, fixed there by +// dezren39/nix#395; this copy predates that fix.) +func TestFirstServedSkillHasSubdirectory(t *testing.T) { + s := mcpserver.New(newBackend(), "mcpx", "test") + list := resultOf(t, handle(t, s, "skills/list", modernParams(nil))) + entries, _ := list["skills"].([]any) + if len(entries) == 0 { + t.Fatal("skills/list returned no skills") + } + firstURI, _ := entries[0].(map[string]any)["uri"].(string) + if firstURI == "" { + t.Fatalf("first skills/list entry has no uri: %v", entries[0]) + } + if !strings.HasSuffix(firstURI, "/SKILL.md") { + t.Fatalf("first skill uri %q does not end in /SKILL.md", firstURI) + } + root := firstURI[:len(firstURI)-len("/SKILL.md")] + res := resultOf(t, handle(t, s, "resources/directory/read", modernParams(map[string]any{"uri": root}))) + for _, r := range res["resources"].([]any) { + if m, _ := r.(map[string]any); m["mimeType"] == "inode/directory" { + return + } + } + t.Fatalf("first served skill %s has no subdirectory child in %v; the sep-2640 directory check samples this skill and counts it untestable as FAILURE (#268)", root, res["resources"]) +} + func TestUpstreamSkillsRelayedInListAndGet(t *testing.T) { s := mcpserver.New(newBackend(), "mcpx", "test") s.UpstreamSkills = func() []*mcpserver.UpstreamSkill { diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md index 218a5a31f2..59af79e1df 100644 --- a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md @@ -10,6 +10,9 @@ description: >- In Antigravity, agents can communicate with MCP servers through the centralized `mcpx` daemon. This keeps the agent's MCP tool count low while providing full access to all developer tools (Codedb, FFF, Chrome DevTools, Context7, Jules, Neon, Desktop Commander, etc.). +`examples/` holds runnable scripts for the patterns below; +`examples/README.md` says what each one shows. + --- ## 1. Context Efficiency in AGY diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md new file mode 100644 index 0000000000..386310b7cf --- /dev/null +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md @@ -0,0 +1,15 @@ +# Example scripts for Antigravity (AGY) + +Each script is run from AGY's `run_command`, the way `SKILL.md` describes: +point `mcpx run` at a copy of the file, or copy one into +`.mcpx/scripts/` to run it by name. `mcpx run` writes the generated +client (`mcpx-client.ts`) beside the script it runs, so run a copy +rather than the file inside a checkout of mcpx. + +| script | what it shows | try it | +| --- | --- | --- | +| `compact-call.ts` | calling one tool and printing only a bounded summary, so a large result does not bloat the AGY transcript | `mcpx run compact-call.ts codedb.status '{}'` | +| `chain-docs-and-code.ts` | chaining two servers in one script — library docs plus the local code index — and printing only the answer from each | `mcpx run chain-docs-and-code.ts react "useCallback dependencies"` | + +Both exit 2 with a usage line when called without arguments, like the +`mcpx-basics` examples. diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/chain-docs-and-code.ts b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/chain-docs-and-code.ts new file mode 100644 index 0000000000..61e108084d --- /dev/null +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/chain-docs-and-code.ts @@ -0,0 +1,29 @@ +// Chain two servers in one script: library docs plus the local code index. +// +// mcpx run chain-docs-and-code.ts "" +// +// This is the chaining pattern from SKILL.md section 2, kept in a single +// invocation so neither server's full result crosses into the AGY +// transcript: the script prints the indexed-file count and only the +// first documentation snippet. Promise.allSettled, so a server that is +// not configured reports its failure without hiding the other answer. +const [libraryId, query] = Deno.args; +if (!libraryId || !query) { + console.error('usage: mcpx run chain-docs-and-code.ts ""'); + Deno.exit(2); +} +const [status, doc] = await Promise.allSettled([ + tools.codedb.status({}), + tools.context7.query_docs({ libraryId, query }), +]); +if (status.status === "fulfilled") { + console.log("Indexed files:", (status.value as any)?.fileCount ?? "unknown"); +} else { + console.log("codedb status failed:", (status.reason as Error).message); +} +if (doc.status === "fulfilled") { + const results = (doc.value as any)?.results; + console.log(results?.[0]?.snippet ?? "Not found"); +} else { + console.log("context7 query failed:", (doc.reason as Error).message); +} diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/compact-call.ts b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/compact-call.ts new file mode 100644 index 0000000000..8fad207d4b --- /dev/null +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/compact-call.ts @@ -0,0 +1,19 @@ +// Call one tool from AGY and print only a bounded summary. +// +// mcpx run compact-call.ts . '{"arg":"value"}' +// +// In Antigravity every byte a tool returns lands in transcript.jsonl, so +// the point of running through `mcpx exec` / `mcpx run` instead of a +// direct MCP call is that only what this script prints comes back. +// Measure the result first, then print a slice of it. +const [target, json = "{}"] = Deno.args; +const dot = target?.indexOf(".") ?? -1; +if (dot < 1) { + console.error("usage: mcpx run compact-call.ts . [json-args]"); + Deno.exit(2); +} +const r = await call(target.slice(0, dot), target.slice(dot + 1), JSON.parse(json)); + +const text = typeof r === "string" || r instanceof String ? String(r) : JSON.stringify(r); +console.log(`${text.length} chars`); +console.log(text.slice(0, 500)); From aee00020af89843e7d1ca78b14bbeba43261b07c Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sun, 18 Oct 2026 05:16:37 -0500 Subject: [PATCH 2/2] =?UTF-8?q?style(mcpx):=20treefmt=20=E2=80=94=20pretti?= =?UTF-8?q?er=20blank=20lines/table=20padding=20in=20mcpx-agy=20docs,=20go?= =?UTF-8?q?fmt=20trailing=20line=20in=20skills=5Ftest.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/mcpx/internal/mcpserver/skills_test.go | 1 - pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md | 6 ++++++ .../mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/mcpx/internal/mcpserver/skills_test.go b/pkgs/mcpx/internal/mcpserver/skills_test.go index 1a988cd475..834791bdab 100644 --- a/pkgs/mcpx/internal/mcpserver/skills_test.go +++ b/pkgs/mcpx/internal/mcpserver/skills_test.go @@ -373,4 +373,3 @@ func TestUpstreamSkillsRelayedInListAndGet(t *testing.T) { t.Fatalf("resources/directory/read for upstream skill returned 0 items") } } - diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md index 59af79e1df..d3f9743aaa 100644 --- a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/SKILL.md @@ -20,6 +20,7 @@ In Antigravity, agents can communicate with MCP servers through the centralized Calling individual MCP tools that return large JSON responses causes transcripts (`transcript.jsonl` / `transcript_full.jsonl`) to grow rapidly. Instead of calling verbose MCP tools directly: + - Use `run_command` with `mcpx exec` to execute TypeScript that transforms and aggregates data on the daemon side before returning output. --- @@ -27,6 +28,7 @@ Instead of calling verbose MCP tools directly: ## 2. Using mcpx via `run_command` ### Discovery + ```bash # Check running servers mcpx ls @@ -37,6 +39,7 @@ mcpx types context7 ``` ### Executing Code Mode Scripts + ```bash mcpx exec ' const status = await tools.codedb.status({}); @@ -45,6 +48,7 @@ mcpx exec ' ``` ### Chaining Across Multiple Servers + ```bash mcpx exec ' const doc = await tools.context7.query_docs({ @@ -60,11 +64,13 @@ mcpx exec ' ## 3. Daemon REST / Socket Access The `mcpx` daemon publishes an HTTP API on its local unix socket or localhost port: + - `GET /v1/namespaces`: List active namespaces - `POST /v1/exec`: Run TypeScript against tools - `GET /v1/log`: Inspect durable execution log When debugging a failing tool without re-running destructive operations: + ```bash mcpx log --since 10m ``` diff --git a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md index 386310b7cf..3bc2c30c47 100644 --- a/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md +++ b/pkgs/mcpx/plugin/opencode/skills/mcpx-agy/examples/README.md @@ -6,9 +6,9 @@ point `mcpx run` at a copy of the file, or copy one into client (`mcpx-client.ts`) beside the script it runs, so run a copy rather than the file inside a checkout of mcpx. -| script | what it shows | try it | -| --- | --- | --- | -| `compact-call.ts` | calling one tool and printing only a bounded summary, so a large result does not bloat the AGY transcript | `mcpx run compact-call.ts codedb.status '{}'` | +| script | what it shows | try it | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | +| `compact-call.ts` | calling one tool and printing only a bounded summary, so a large result does not bloat the AGY transcript | `mcpx run compact-call.ts codedb.status '{}'` | | `chain-docs-and-code.ts` | chaining two servers in one script — library docs plus the local code index — and printing only the answer from each | `mcpx run chain-docs-and-code.ts react "useCallback dependencies"` | Both exit 2 with a usage line when called without arguments, like the