@ogygia/cli
AI agents
`ogygia ai` gives a repository the ogygia skill and registers the MCP server, so an AI agent reads how ogygia is meant to be used and checks its work against the real compiler, profiler and devtools.
An AI agent that writes ogygia code from memory tends to reinvent what ogygia already has, and it can’t see what the compiler does with a mark it wrote. Two things fix that. The skill is a document the agent reads before it writes code: the primitives, the rules, and the one-line answer to each common problem. The MCP server gives the agent ogygia’s real compiler, profiler and devtools as tools, so it can compile a component it wrote, read its island map, or load the page and see what woke.
One command sets up both for every agent that works on the repository:
npx ogygia aiSkill
ogygia ai writes the skill to .claude/skills/ogygia/SKILL.md, the place Claude Code reads skills from, and replaces an older copy there. The skill ships inside @ogygia/cli, so running the command again after an upgrade brings it up to date with the version you installed. Commit the file, so everyone’s agent reads the same one.
It also registers the MCP server below in .mcp.json under the name ogygia. Other servers in the file are kept, and an older ogygia entry is replaced. A .mcp.json that isn’t valid JSON stops the command with exit 1, and nothing is written to it. The skill is already written by then: fix .mcp.json and run the command again.
Claude Code picks the server up the next time it starts in the repository, and asks you to approve it.
{
"mcpServers": {
"ogygia": { "command": "npx", "args": ["ogygia", "mcp"] }
}
}MCP server
npx ogygia mcp runs a Model Context Protocol server over standard input and output: JSON-RPC 2.0, one message per line, protocol version 2024-11-05. It answers initialize, tools/list, tools/call and ping, and an unknown method with error -32601. It runs until the client closes its input.
Standard output carries only the protocol. Everything for people goes to standard error, starting with a ready line that names the tools, so starting it by hand is a quick check that it works:
Press Ctrl-C to stop it.
Other clients
npx ogygia ai registers the server for Claude Code. Other MCP clients take the same command in their own configuration file, usually in this shape:
Working folder
Start the server from your app’s root folder. The tools that take a path read it from the server’s working folder, ogygia_flags loads @ogygia/flags from the app’s own install, and the profile tools load @ogygia/devtools/report from there too. ogygia_debug needs Playwright installed (npm i -D playwright && npx playwright install chromium), an optional peer of @ogygia/cli.
npx ogygia mcp
# [ogygia mcp] ogygia MCP server v0.16.2 ready — 10 tools (compile, islands, check, explain, debug, profile, profile_open, scan, flags, fragment){
"mcpServers": {
"ogygia": { "command": "npx", "args": ["ogygia", "mcp"] }
}
}Tools
Each tool answers with text written for an agent: markdown with a JSON block where the data is structured. A tool that can’t do its job answers with an error result that says what to fix, such as a missing argument, a server that isn’t up, or a plugin that isn’t listed. An argument of the wrong type is refused by name.
| Tool | Arguments | What it does |
|---|---|---|
ogygia_compile | source; filename (App.svelte); csr (false) | Runs a component through the real transform. Returns its island map (each marked import, its kind, its render and wake settings and its build id) and the rewritten host module. csr: true compiles the csr = true side, where ogygia steps aside. |
ogygia_islands | source | Only the island map, as JSON. |
ogygia_check | source | Runs the transform for the server and the browser, and reports the first build error either raises, or that the component passes. |
ogygia_explain | source | Explains in prose, per marked component, where its HTML comes from, when its JavaScript runs, and how its props cross. |
ogygia_debug | url; wait (2500 ms, 200 to 8000); scroll (true); click (a selector) | Loads a page of your running app in headless Chromium, scrolls to wake visible islands, clicks click if given, and returns each island’s story from the devtools event stream, with anomalies. |
ogygia_profile | url; runs (5, 1 to 50); key; origin; base (/__profiler) | Profiles the server render of a URL through the profiler and returns a digest: the verdict, the median render, findings, time by category, hot functions and components, network and heap. |
ogygia_profile_open | file; key | Opens a downloaded .ogp report with the key it was exported with, and returns the same digest. No server is involved. |
ogygia_scan | dir (src) | Runs the transform on every .svelte file under a folder (up to 1,500) and returns the app’s island layout by file, the build errors, and soft warnings such as an island inside an island. |
ogygia_flags | dir (.) | Lists every flag() call site under <dir>/src, with the build’s own collector, and compares them with the last build’s node_modules/.ogygia/flags-manifest.json. |
ogygia_fragment | origin | Checks a federated app: whether its page endpoint refuses an unsigned call (a 401 is right, a 200 means it’s open), and what its widget catalog lists. |
A transform that throws inside ogygia_compile, ogygia_islands or ogygia_explain answers with cli_transform_failed, followed by the transform’s own message, which names the rule the component broke. ogygia_check answers the same failure as its verdict rather than as an error.
Debugging a page
ogygia_debug reads the devtools event stream, so the app lists devtools() from @ogygia/devtools/vite beside ogygia() with the dock on, its default. On the dev server the stream is always on. On a build, add ?og-devtools=on to the URL, so the server’s half of the story is in it too. A page that loads without the devtools gets an answer that names the line to add.
Profiling
ogygia_profile needs the app to list devtools({ profiler: true }). Pass key when the profiler has a secret; it’s sent as x-profiler-key. Given a bare path such as /pricing instead of a full URL, the tool doesn’t profile. It asks for the full URL, and lists the local servers it found running a profiler on ports 4173, 5173, 3000, 5174, 4174, 3001, 8080, 4321 and 5175, unless you also pass origin. When another recording holds the profiler, it leaves a live one alone and says the profiler is busy, and clears a stale one and tries again.
Flags
ogygia_flags needs @ogygia/flags installed in the folder the server runs in, and loads its inventory from there, never from dir, so pointing the tool at another folder never runs that folder’s code. It reads .ts and .svelte files under src, and only names written as string literals. Without a manifest it says one appears after a client build. With one, it names the flags that are in the manifest but no longer in the source.