diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 6265409..da1321e 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,12 +10,17 @@ "plugins": [ { "name": "floci", - "description": "Run, wire up and troubleshoot the Floci local cloud emulators with floci-cli, docker run or Docker Compose", + "description": "Run, wire up and troubleshoot the Floci local cloud emulators with floci-cli, docker run or Docker Compose, with the Floci MCP server for agent tools", "source": "./", "strict": false, "skills": [ "./skills/floci" - ] + ], + "mcpServers": { + "floci": { + "command": "${CLAUDE_PLUGIN_ROOT}/skills/floci/scripts/floci-mcp.sh" + } + } } ] } diff --git a/README.md b/README.md index 091b76f..02ebaf7 100644 --- a/README.md +++ b/README.md @@ -1155,7 +1155,9 @@ Codex, Cursor, Kiro, Gemini CLI and others) to work with Floci: install and driv `oci` and the SDKs to the emulators without touching real cloud, write `docker run` commands and Compose files, run several instances side by side, and look things up in the published documentation of each emulator ([AWS](https://floci.io/floci/), [Azure](https://floci.io/floci-az/), [GCP](https://floci.io/floci-gcp/), -[OCI](https://floci.io/floci-oci/)) instead of guessing. +[OCI](https://floci.io/floci-oci/)) instead of guessing. It also sets up the +[Floci MCP server](https://github.com/floci-io/floci-ui#mcp-server-for-ai-agents), which gives the agent tools over +every emulator service. ```sh # Any supported agent (asks which ones to install it for) @@ -1166,6 +1168,11 @@ npx skills add floci-io/floci-cli /plugin install floci@floci ``` +The Claude Code plugin also starts the Floci MCP server: its `scripts/floci-mcp.sh` runs the `floci/floci-mcp` image +with Docker or Podman, or the `@floci/mcp` npm package with Node, whichever your machine has (the first start pulls +the image or the package). Turn it off in `/mcp` if you do not want it. With any other agent, the skill's +`scripts/ensure-mcp.sh` installs and registers it, or prints the configuration for your client. + In [Kiro](https://kiro.dev), install it as a power: Powers panel, **Add Custom Power**, **Import power from GitHub**, and enter `https://github.com/floci-io/floci-cli`. The `plugin.json` at the repository root is the [Agent Plugins](https://agent-plugins.org) manifest Kiro reads. Kiro also loads plain Agent Skills, so copying @@ -1178,7 +1185,8 @@ Or copy the `skills/floci/` directory into your agent's skills directory (for ex | `SKILL.md` | Lifecycle, safety rules (fake credentials only, verify the endpoint, explicit product tree) and when to read what | | `references/` | One page per cloud, plus Docker and Compose, multiple instances and namespaces, CI, troubleshooting, and how to find a page in the docs | | `assets/compose/` | Compose templates for each emulator and for all four together | -| `scripts/` | `install-floci.sh` and `ensure-running.sh` (bash) | +| `references/mcp.md` | Installing and registering the Floci MCP server in each client, instances on other ports, troubleshooting | +| `scripts/` | `install-floci.sh`, `ensure-running.sh`, `ensure-mcp.sh` and `floci-mcp.sh`, the MCP launcher the plugin runs (bash) | The skill follows the CLI: `SkillDocsTest` checks every `floci` command it quotes against the real command tree. @@ -1223,7 +1231,8 @@ The only network requests they make are the ones needed to do what you asked: |---|---|---| | Release check | `api.github.com` | At most once every 24 hours from an interactive terminal, and on `floci update`. Turn it off with `FLOCI_NO_UPDATE_CHECK=1`; it is off in CI and for piped output | | Binary download | `github.com` (release assets) | Only when you run `floci update` or the install script | -| Image pull | Your container registry (Docker Hub by default) | When `docker` pulls an emulator image on `floci start` | +| Image pull | Your container registry (Docker Hub by default) | When `docker` pulls an emulator image on `floci start`, or the `floci/floci-mcp` image for the MCP server (the Claude Code plugin's launcher and `ensure-mcp.sh`) | +| Package download | `registry.npmjs.org` | Only when the MCP server runs with `npx -y @floci/mcp` (set up that way, or the plugin's launcher on a machine with Node but no Docker or Podman) | | Name lookup | DNS for `localhost.floci.io`, which answers `127.0.0.1` | When a tool uses the endpoint that `floci env` prints for AWS | | Documentation pages | `floci.io` and `raw.githubusercontent.com` | When an agent using the skill looks something up | diff --git a/plugin.json b/plugin.json index 2670a81..c38ef81 100644 --- a/plugin.json +++ b/plugin.json @@ -1,8 +1,8 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "floci", - "version": "1.0.10", - "description": "Run, wire up and troubleshoot Floci, the free local emulators for AWS, GCP, Azure and OCI: floci-cli lifecycle, safe wiring of aws, gcloud, az, oci and the SDKs, docker run and Docker Compose files, several instances side by side, and lookups in the published docs.", + "version": "1.1.0", + "description": "Run, wire up and troubleshoot Floci, the free local emulators for AWS, GCP, Azure and OCI: floci-cli lifecycle, safe wiring of aws, gcloud, az, oci and the SDKs, docker run and Docker Compose files, several instances side by side, lookups in the published docs, and the Floci MCP server for agent tools.", "author": { "name": "Floci", "url": "https://floci.io" diff --git a/skills/floci/SKILL.md b/skills/floci/SKILL.md index ef72d84..27cd07a 100644 --- a/skills/floci/SKILL.md +++ b/skills/floci/SKILL.md @@ -1,6 +1,6 @@ --- name: floci -description: Run, wire up and troubleshoot Floci, the free local emulators for AWS (floci), GCP (floci-gcp), Azure (floci-az) and OCI (floci-oci), driven by floci-cli, docker run or Docker Compose. Use when the user wants to run cloud code or tests locally, mentions floci, localhost:4566/4577/4588/4599, a LocalStack or Azurite alternative, local S3/DynamoDB/Pub/Sub/Blob/Object Storage, asks for a docker-compose.yml or compose.yaml with a cloud emulator, emulator namespaces, or several emulator instances side by side. +description: Run, wire up and troubleshoot Floci, the free local emulators for AWS (floci), GCP (floci-gcp), Azure (floci-az) and OCI (floci-oci), driven by floci-cli, docker run or Docker Compose. Use when the user wants to run cloud code or tests locally, mentions floci, localhost:4566/4577/4588/4599, a LocalStack or Azurite alternative, local S3/DynamoDB/Pub/Sub/Blob/Object Storage, asks for a docker-compose.yml or compose.yaml with a cloud emulator, emulator namespaces, several emulator instances side by side, or wants their agent to manage local emulator resources through MCP (connect Claude, Cursor or Codex to the local AWS, Azure, GCP or OCI emulator, the Floci MCP server, floci-mcp). Use it even when the user does not say Floci but wants to run or test cloud code with no real account. --- # Floci @@ -20,18 +20,37 @@ creates cloud resources itself. All paths in this skill (`references/`, `scripts/`, `assets/`) are relative to the directory that holds this file, not to the user's working directory. -When to read what: +## Where to start -- The cloud's reference, before the first resource command for that cloud. +Pick the integration first; each names the page to read before going on: + +- **Ad-hoc commands, a dev server or a quick test**: the floci-cli lifecycle below. +- **`docker run`, a Compose file (`docker-compose.yml`), an app that itself runs in a container, or no CLI wanted**: + [references/docker.md](references/docker.md). Start from the templates in `assets/compose/` + rather than writing YAML from memory: they already carry the health checks and variables + each image needs. +- **Integration tests in code or a CI pipeline**: [references/ci.md](references/ci.md). A + Testcontainers module where one exists (AWS in Java, Node, Python, Go and .NET; Azure in Java + only; none for GCP or OCI); otherwise start the emulator with the CLI or Compose before the + tests. +- **Agent tools over the emulators (MCP)**: the "Agent tools" section below. When those tools + are already available, use them to look around and for one-off changes (list resources, read + an object, send a test message, invoke a function), and the native CLI (`aws`, `gcloud`, `az`, + `oci`) when the user asked for those commands, wants a script to keep, or needs an operation + the tools do not offer (`describe_service` lists what each service supports). + +Then, as the work needs them: + +- The cloud's reference (table above), before the first resource command for that cloud: it + has the wiring and the ways a command can leak to real cloud. - [references/docs.md](references/docs.md), before writing code against a service you have not used in this session, and whenever an operation looks unsupported. It tells you how to fetch the right page of the published documentation. -- [references/docker.md](references/docker.md), when the user wants `docker run`, a - `docker-compose.yml`, or an app container that talks to the emulator. - [references/namespaces.md](references/namespaces.md), when running more than one instance, sharing a Docker host, or cleaning up containers. -- [references/ci.md](references/ci.md) for pipelines and Testcontainers. -- [references/troubleshooting.md](references/troubleshooting.md) when anything fails. +- [references/troubleshooting.md](references/troubleshooting.md), when anything fails. +- [references/mcp.md](references/mcp.md), when the `floci` MCP server is missing, fails, or + must reach a non-default port. ## Prerequisites (check first) @@ -63,37 +82,58 @@ floci-cli does not install Docker. If the daemon is missing, tell the user; do n Docker yourself. The native cloud CLIs (`aws`, `gcloud`, `az`, `oci`) are only needed for the clouds the user works with; suggest installing them, do not install them unasked. +## Agent tools (MCP server) + +The Floci MCP server, `floci-mcp`, gives you tools over every emulator service (`floci_status`, +`list_resources`, `create_resource`, `run_action`, ...). The floci Claude Code plugin starts it +for you; other setups register it once. + +Before offering to install it, check whether you already have it: its tools carry a client +prefix (`mcp__floci__floci_status`, `mcp__plugin_floci_floci__floci_status`, ...), and some +clients load tools only on demand, so search your tools for `floci_status` rather than reading +the visible list. If it is there, call `floci_status` to see which emulators answer. If it is +not and the user wants MCP tools, **ask before installing**, because it pulls an image (or an +npm package) and changes their agent configuration. Then run: + +```sh +scripts/ensure-mcp.sh # Docker or Podman image; --npx for the npm package +``` + +It registers the server with Claude Code for every project, or prints the configuration for +other clients. The tools load in a new session. Ports, instances, other clients and fixes: +[references/mcp.md](references/mcp.md). + ## Hard rules +These protect the user's real cloud accounts and their other work, so they hold even when the +user's request seems to point the other way; ask instead. + 1. **Never touch real cloud.** Use only the fake credentials the emulators accept (`test`/`test` for AWS, the dev identities `floci az setup` and `floci oci setup` create). - Never read, export or reuse the user's real cloud credentials or profiles. + Never read, export or reuse the user's real cloud credentials or profiles: one wrong + endpoint would then create or delete real, billed resources. 2. **Verify the endpoint before every mutating command.** It must point at the emulator (`localhost`, `127.0.0.1`, `localhost.floci.io`, or a Compose service name). If a command might reach public cloud (see each reference's "leaks" section), stop and fix the wiring. + With the MCP tools, `floci_status` shows the endpoint each cloud is reached at: the + emulators by default, or whatever an endpoint variable in the server's registration says. 3. **Always name the tree explicitly**: `floci aws start`, not `floci start`. Bare commands follow `floci config default-product`, which the user may have changed. -4. **Parse with `-o json`**, never scrape text output. Use `-q` to silence noise in scripts. -5. **Do not remove containers, volumes or snapshots you did not create** in this session. - Scope any cleanup to a namespace (see namespaces.md) and confirm with the user first. +4. **Parse with `-o json`**, never scrape text output: the text layout is for people and + changes between releases, the JSON fields do not. Use `-q` to silence noise in scripts. +5. **Do not remove containers, volumes or snapshots you did not create** in this session: they + may hold the user's data. Scope any cleanup to a namespace (see namespaces.md) and confirm + with the user first. 6. **State is ephemeral** unless the instance was started with `--persist ` or a profile - with `persistDir`. Both `start` on a stopped container and `restart` remove the container - and create a new one: `restart` keeps the settings (port, image, services, persist dir, - namespace, bind address) but not in-memory state, and on Azure the new container has a new - certificate, so `floci az setup` must be run again. `start` on a running container fails; - on a stopped one it uses only its own flags and profile, so a bind address meant to last - belongs in the profile. Say so before recreating anything. If restart fails after removal, - follow stderr: a start command that retries with the same settings, or `logs` and `wait` - when the new container is up but not ready. Neither restores in-memory state. -7. **Never add `-q` to `env`**: it suppresses the exports themselves. Follow-up command hints - keep the instance's flags; keep them when retrying. -8. **Do not guess what an emulator supports.** Check `floci services -o json` and the - published docs ([references/docs.md](references/docs.md)) instead of answering from memory. -9. **With a profile, start and wait before `env`.** Until the container is running, `env` - warns on stderr. A profile with a `port` resolves to that port; a named container with - neither a port nor an endpoint has `"endpoint": null` in `status -o json` and `env` exits 1 - rather than describe the default instance. Trust `"state": "running"` in `status -o json`, - not `reachable`. + with `persistDir`, and recreating a container loses it (see "Starting again" below). Say so + before recreating anything. +7. **Do not guess what an emulator supports.** Coverage differs per service: some are full + engines, some are in-process, some answer with canned responses. Check + `floci services -o json` and the service's page in the published docs + ([references/docs.md](references/docs.md)) instead of answering from memory. If an + operation is missing, say so plainly, suggest a workaround, and point the user to the + emulator's issue tracker (`https://github.com/floci-io//issues`) + instead of retrying variations. ## Lifecycle (same for every tree) @@ -119,19 +159,37 @@ exports="$(scripts/ensure-running.sh [profile])" && eval "$expo Keep the two steps: `eval "$(...)"` in one go succeeds even when the helper fails, and the commands after it would run with missing or stale wiring. The helper exits 3 without touching anything when the container exists but is stopped, because starting it replaces -it (rule 6). Tell the user, and re-run with `FLOCI_REPLACE_STOPPED=1` once they agree. +it (see "Starting again"). Tell the user, and re-run with `FLOCI_REPLACE_STOPPED=1` once they +agree. One-time per instance, before using the native CLI: - Azure: `floci az setup` (trusts the emulator cert, registers an az cloud, logs in). - OCI: `floci oci setup` (writes a throwaway key and a `[FLOCI]` profile in `~/.oci/config`). -`eval` only affects the current shell. If each tool call runs in a fresh shell, prefix every -command: `eval "$(floci aws env -o text)" && aws s3 ls`. +### Starting again -The examples are written for bash. In zsh (the macOS default) an unquoted variable is not -split into words, so `flags="--profile aws-b"; floci aws status $flags` passes one argument -and fails. Write the flags out, or use an array: `flags=(--profile aws-b)` and -`"${flags[@]}"`. +Both `start` on a stopped container and `restart` remove the container and create a new one. +`restart` keeps the settings (port, image, services, persist dir, namespace, bind address) but +not in-memory state, and on Azure the new container has a new certificate, so `floci az setup` +must be run again. `start` on a running container fails; on a stopped one it uses only its own +flags and profile, so a bind address meant to last belongs in the profile. If restart fails +after removal, follow stderr: a start command that retries with the same settings, or `logs` +and `wait` when the new container is up but not ready. Neither restores in-memory state. + +### Wiring pitfalls + +- **Never add `-q` to `env`**: it suppresses the exports themselves. Follow-up command hints + keep the instance's flags; keep them when retrying. +- **With a profile, start and wait before `env`.** Until the container is running, `env` + warns on stderr. A profile with a `port` resolves to that port; a named container with + neither a port nor an endpoint has `"endpoint": null` in `status -o json` and `env` exits 1 + rather than describe the default instance. Trust `"state": "running"` in `status -o json`, + not `reachable`. +- **`eval` only affects the current shell.** If each tool call runs in a fresh shell, prefix + every command: `eval "$(floci aws env -o text)" && aws s3 ls`. +- **zsh** (the macOS default) does not split an unquoted variable into words, so + `flags="--profile aws-b"; floci aws status $flags` passes one argument and fails. Write the + flags out, or use an array: `flags=(--profile aws-b)` and `"${flags[@]}"`. ## Inspecting state @@ -162,23 +220,3 @@ eval "$(floci aws env -o text --profile aws-b)" floci-cli keeps its own files under `~/.floci` (profiles in `~/.floci/profiles/`, per-instance state in `~/.floci///`), so instance data goes there too, as `~/.floci/data/`. - -## Choosing the right integration - -- **Ad-hoc commands or a dev server**: the CLI lifecycle above. -- **The user asks for `docker run` or a Compose file, or the app itself runs in a container**: - [references/docker.md](references/docker.md). Start from the templates in - `assets/compose/` instead of writing YAML from memory. -- **Integration tests in code**: a Testcontainers module where one exists (AWS in Java, Node, - Python, Go and .NET; Azure in Java only; none for GCP or OCI, see ci.md). Otherwise start - the emulator with the CLI or Compose before the tests. - -## When something is not supported - -Coverage differs per service: some are full engines, some are in-process, some answer with -canned responses. Before writing code against a service, check that it is enabled -(`floci services -o json`) and read its page in the published docs -([references/docs.md](references/docs.md)). If an operation is missing, say so plainly, -suggest a workaround, and point the user to the emulator's issue tracker -(`https://github.com/floci-io//issues`) instead of -retrying variations. diff --git a/skills/floci/evals/README.md b/skills/floci/evals/README.md new file mode 100644 index 0000000..d4f7c9c --- /dev/null +++ b/skills/floci/evals/README.md @@ -0,0 +1,20 @@ +# Evals for the floci skill + +Each folder is one test case in the layout `claude plugin eval` reads: `prompt.md` (run +settings, then the prompt), `case.yaml` (the expected outcome) and `graders/` (one checked +statement per file). + +The MCP cases depend on the machine's state, which neither the prompt nor the CLI sets up. +Prepare it before a run, and keep the agent away from your real Claude Code configuration by +putting a stand-in `claude` command first on its PATH that records `claude mcp add` instead of +applying it. + +| Case | Machine state | +|------|---------------| +| `mcp-setup-podman-only` | Docker not reachable (a stand-in `docker` that fails as if the daemon were stopped), Podman running, the `floci/floci-mcp` image available to Podman, no floci MCP server registered | +| `mcp-setup-plugin-present` | The floci plugin's MCP server connected, so its tools are `mcp__plugin_floci_floci__*`, and `claude mcp list` shows `plugin:floci:floci` | +| `mcp-tools-list-buckets` | A `floci` MCP server registered (tools `mcp__floci__*`), and the AWS emulator running with one bucket: `floci aws start`, then `aws s3 mb s3://eval-bucket-1` against it | + +First run (2026-12-03, against the skill before and after the MCP review fixes): 9 of 9 checks +passed with the fixes, 8 of 9 without. Only the Podman case told the two apart: without the +fixes the helper did not know Podman and registered for one project only. diff --git a/skills/floci/evals/mcp-setup-plugin-present/case.yaml b/skills/floci/evals/mcp-setup-plugin-present/case.yaml new file mode 100644 index 0000000..1eaeb3a --- /dev/null +++ b/skills/floci/evals/mcp-setup-plugin-present/case.yaml @@ -0,0 +1,6 @@ +schema_version: "1.1" +name: mcp-setup-plugin-present +expected_outcome: | + The floci Claude Code plugin already provides the server (its tools are + named `mcp__plugin_floci_floci__*`). The agent finds those tools, calls `floci_status` to + confirm the server works, registers nothing, and tells the user it is already set up. diff --git a/skills/floci/evals/mcp-setup-plugin-present/graders/01-no-second-registration.md b/skills/floci/evals/mcp-setup-plugin-present/graders/01-no-second-registration.md new file mode 100644 index 0000000..5b3060e --- /dev/null +++ b/skills/floci/evals/mcp-setup-plugin-present/graders/01-no-second-registration.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The agent does not run `claude mcp add` or otherwise register a second floci server. diff --git a/skills/floci/evals/mcp-setup-plugin-present/graders/02-calls-a-floci-tool.md b/skills/floci/evals/mcp-setup-plugin-present/graders/02-calls-a-floci-tool.md new file mode 100644 index 0000000..16a2a39 --- /dev/null +++ b/skills/floci/evals/mcp-setup-plugin-present/graders/02-calls-a-floci-tool.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The agent calls a floci MCP tool (such as `floci_status`) to confirm the server works. diff --git a/skills/floci/evals/mcp-setup-plugin-present/graders/03-says-already-set-up.md b/skills/floci/evals/mcp-setup-plugin-present/graders/03-says-already-set-up.md new file mode 100644 index 0000000..d20c9dc --- /dev/null +++ b/skills/floci/evals/mcp-setup-plugin-present/graders/03-says-already-set-up.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The final answer tells the user the floci MCP server is already set up. diff --git a/skills/floci/evals/mcp-setup-plugin-present/prompt.md b/skills/floci/evals/mcp-setup-plugin-present/prompt.md new file mode 100644 index 0000000..54e4be0 --- /dev/null +++ b/skills/floci/evals/mcp-setup-plugin-present/prompt.md @@ -0,0 +1,8 @@ +--- +tags: [floci, mcp] +max_turns: 40 +timeout_seconds: 600 +allowed_tools: [Read, Glob, Grep, Skill, Bash, ToolSearch, mcp__plugin_floci_floci__floci_status, mcp__plugin_floci_floci__list_services] +--- + +Set up the floci MCP server for me please, install it if it is missing. diff --git a/skills/floci/evals/mcp-setup-podman-only/case.yaml b/skills/floci/evals/mcp-setup-podman-only/case.yaml new file mode 100644 index 0000000..eed7394 --- /dev/null +++ b/skills/floci/evals/mcp-setup-podman-only/case.yaml @@ -0,0 +1,6 @@ +schema_version: "1.1" +name: mcp-setup-podman-only +expected_outcome: | + Docker is not running and Podman is. The agent sets up the Floci MCP server + with Podman (or npx), registers it with Claude Code for every project (user scope) with a + single `claude mcp add`, and tells the user the tools load in a new session. diff --git a/skills/floci/evals/mcp-setup-podman-only/graders/01-registers-the-server.md b/skills/floci/evals/mcp-setup-podman-only/graders/01-registers-the-server.md new file mode 100644 index 0000000..2a47e25 --- /dev/null +++ b/skills/floci/evals/mcp-setup-podman-only/graders/01-registers-the-server.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +A floci MCP server is registered with Claude Code by running `claude mcp add`. diff --git a/skills/floci/evals/mcp-setup-podman-only/graders/02-uses-podman-or-npx.md b/skills/floci/evals/mcp-setup-podman-only/graders/02-uses-podman-or-npx.md new file mode 100644 index 0000000..40a4c3b --- /dev/null +++ b/skills/floci/evals/mcp-setup-podman-only/graders/02-uses-podman-or-npx.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The registered command runs `podman` or `npx`, not `docker`, because Docker is not running. diff --git a/skills/floci/evals/mcp-setup-podman-only/graders/03-user-scope.md b/skills/floci/evals/mcp-setup-podman-only/graders/03-user-scope.md new file mode 100644 index 0000000..2a82f2b --- /dev/null +++ b/skills/floci/evals/mcp-setup-podman-only/graders/03-user-scope.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The server is registered for every project: the `claude mcp add` call passes `--scope user` or `-s user`. diff --git a/skills/floci/evals/mcp-setup-podman-only/prompt.md b/skills/floci/evals/mcp-setup-podman-only/prompt.md new file mode 100644 index 0000000..141bdfa --- /dev/null +++ b/skills/floci/evals/mcp-setup-podman-only/prompt.md @@ -0,0 +1,8 @@ +--- +tags: [floci, mcp] +max_turns: 40 +timeout_seconds: 600 +allowed_tools: [Read, Glob, Grep, Skill, Bash, ToolSearch] +--- + +Can you set up the floci MCP server so my coding agent can work with my local emulators? Go ahead and install whatever it needs, I'm fine with that. diff --git a/skills/floci/evals/mcp-tools-list-buckets/case.yaml b/skills/floci/evals/mcp-tools-list-buckets/case.yaml new file mode 100644 index 0000000..d6d9831 --- /dev/null +++ b/skills/floci/evals/mcp-tools-list-buckets/case.yaml @@ -0,0 +1,6 @@ +schema_version: "1.1" +name: mcp-tools-list-buckets +expected_outcome: | + The floci MCP server is registered (tools `mcp__floci__*`) and the AWS + emulator holds one bucket, `eval-bucket-1`. The agent reads the buckets with the MCP tools, + installs and registers nothing, and names `eval-bucket-1`. diff --git a/skills/floci/evals/mcp-tools-list-buckets/graders/01-reads-with-mcp-tool.md b/skills/floci/evals/mcp-tools-list-buckets/graders/01-reads-with-mcp-tool.md new file mode 100644 index 0000000..b4512cb --- /dev/null +++ b/skills/floci/evals/mcp-tools-list-buckets/graders/01-reads-with-mcp-tool.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The buckets are read with the floci MCP `list_resources` tool. diff --git a/skills/floci/evals/mcp-tools-list-buckets/graders/02-installs-nothing.md b/skills/floci/evals/mcp-tools-list-buckets/graders/02-installs-nothing.md new file mode 100644 index 0000000..7e96bf1 --- /dev/null +++ b/skills/floci/evals/mcp-tools-list-buckets/graders/02-installs-nothing.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The agent installs or registers nothing: no `claude mcp add`, no `ensure-mcp.sh`, no image pull, no npm install. diff --git a/skills/floci/evals/mcp-tools-list-buckets/graders/03-names-the-bucket.md b/skills/floci/evals/mcp-tools-list-buckets/graders/03-names-the-bucket.md new file mode 100644 index 0000000..06077d0 --- /dev/null +++ b/skills/floci/evals/mcp-tools-list-buckets/graders/03-names-the-bucket.md @@ -0,0 +1,7 @@ +--- +type: llm +focus: trace +weight: 1 +--- + +The final answer names the bucket `eval-bucket-1`. diff --git a/skills/floci/evals/mcp-tools-list-buckets/prompt.md b/skills/floci/evals/mcp-tools-list-buckets/prompt.md new file mode 100644 index 0000000..20b37e9 --- /dev/null +++ b/skills/floci/evals/mcp-tools-list-buckets/prompt.md @@ -0,0 +1,8 @@ +--- +tags: [floci, mcp] +max_turns: 40 +timeout_seconds: 600 +allowed_tools: [Read, Glob, Grep, Skill, Bash, ToolSearch, mcp__floci__floci_status, mcp__floci__list_services, mcp__floci__list_resources] +--- + +What S3 buckets do I have in my local floci right now? diff --git a/skills/floci/references/mcp.md b/skills/floci/references/mcp.md new file mode 100644 index 0000000..cd5c464 --- /dev/null +++ b/skills/floci/references/mcp.md @@ -0,0 +1,129 @@ +# Floci MCP server (agent tools) + +`floci-mcp` gives an agent ten tools over every service of the four emulators: `floci_status`, +`list_services`, `describe_service`, `list_resources`, `get_resource`, `create_resource`, +`update_resource`, `delete_resource`, `update_tags` and `run_action` (a service's own actions: +invoke a function, send and receive messages, upload and download objects, query a table, +encrypt with a key, start an instance, ...). It is the Floci console's backend, without the +console. Source and full docs: https://github.com/floci-io/floci-ui#mcp-server-for-ai-agents + +The MCP tools complement the native CLIs: use them to look around and to drive services the +user has no CLI for; keep using `aws`, `gcloud`, `az` and `oci` (rule 2 of SKILL.md still +applies) when the user asked for those commands or for a script they will run again. + +## Is it there already? + +- Search your tools for `floci_status` (any prefix; some clients load tools on demand). Found: + skip to "Check it works". +- Claude Code: `claude mcp list` shows a `floci` entry, or a `plugin:floci:floci` entry when + the floci plugin provides it. Never add a second one: the agent would see every tool twice. +- Other clients: look for a `floci` entry in the client's MCP configuration (below). + +The floci Claude Code plugin starts the server through `scripts/floci-mcp.sh`, which uses +Docker, then Podman, then Node (`npx`), whichever this machine has. When none is running, the +server shows as failed in `/mcp`: start Docker or Podman and reconnect it there, or turn the +plugin's server off in `/mcp` if the user does not want it. + +## Which way to run it + +| Way | Needs | Pick it when | +|---|---|---| +| Image `floci/floci-mcp` | Docker or Podman (already there for the emulators) | Default | +| npm `@floci/mcp` (`npx -y @floci/mcp`) | Node 20 or later | No Docker for the agent, or the user prefers Node | +| The console's HTTP route `http://localhost:4500/api/mcp` | The Floci console running | The console is already up (`floci-ui` on port 4500) | + +The image reaches the emulators on the host through `host.docker.internal` (Docker Desktop and +Podman machine have that name already; `--add-host=host.docker.internal:host-gateway` adds it +elsewhere). On native Linux, Docker Engine or Podman, that name is the bridge address, which does +not reach ports published on `127.0.0.1` (how the compose templates publish them), so there the +container shares the host's network instead: `--network=host -e FLOCI_EMULATOR_HOST=localhost`. +The ports stay loopback-only. The plugin's launcher and `ensure-mcp.sh` choose this by themselves +(`FLOCI_MCP_NETWORK=host` or `bridge` overrides it). The npm package reaches the emulators on +`localhost`. + +**Podman.** Use `podman` where the commands below say `docker`; the helper and the plugin's +launcher pick Podman by themselves when Docker is not reachable. + +## Install and register + +Ask the user before registering a server or pulling an image, as for installing the CLI. Then +the helper does it in one step: it checks Docker (or Node with `--npx`), pulls the image, checks +that the server answers, and registers it with Claude Code when the `claude` CLI is present +and has no `floci` server yet. For any other client it prints the configuration to add: + +```sh +scripts/ensure-mcp.sh # container image, Docker or Podman +scripts/ensure-mcp.sh --npx # npm package +scripts/ensure-mcp.sh --read-only # only the tools that change nothing +scripts/ensure-mcp.sh --scope local # this project only (default: user, every project) +``` + +By hand, Claude Code: + +```sh +claude mcp add -s user floci -- docker run -i --rm --add-host=host.docker.internal:host-gateway floci/floci-mcp +claude mcp add -s user floci -- npx -y @floci/mcp +claude mcp add -s user --transport http floci http://localhost:4500/api/mcp +``` + +Most other clients take an `mcpServers` block: Cursor (`.cursor/mcp.json`, or +`~/.cursor/mcp.json` for every project), Claude Desktop (`claude_desktop_config.json`), Windsurf, +and Kiro (`.kiro/settings/mcp.json` for the workspace, `~/.kiro/settings/mcp.json` for the user). +Show the user the snippet and the file; do not edit another client's configuration without +asking: + +```json +{ + "mcpServers": { + "floci": { + "command": "docker", + "args": ["run", "-i", "--rm", "--add-host=host.docker.internal:host-gateway", "floci/floci-mcp"] + } + } +} +``` + +Codex and the remaining clients: the floci-ui README keeps their snippets, +https://github.com/floci-io/floci-ui#mcp-server-for-ai-agents + +A client loads MCP servers when it starts: after registering, tell the user the tools appear +in a new session (Claude Code: `/mcp` shows the server and can reconnect it). + +## Check it works + +Call `floci_status`. Each cloud reports its endpoint and `runtime`: `reachable` means the +emulator answered. `unavailable` for a cloud the user has not started is expected; start it +with `floci start --detach` and call `floci_status` again. + +## Non-default ports, instances and namespaces + +The server looks for each emulator on its default port. For an instance on another port, read +its endpoint from `floci status -o json --profile ` (the `endpoint` field) and pass +it in. With the image on Docker Desktop or Podman machine, replace `localhost` by +`host.docker.internal`; on native Linux, keep `localhost` and use `--network=host`: + +```sh +claude mcp add -s user floci-b -- docker run -i --rm --add-host=host.docker.internal:host-gateway \ + -e FLOCI_ENDPOINT=http://host.docker.internal:14566 floci/floci-mcp +``` + +| Variable | For | +|---|---| +| `FLOCI_ENDPOINT` | The AWS emulator (or the cloud named by `FLOCI_CLOUD`) | +| `FLOCI_AZURE_ENDPOINT`, `FLOCI_GCP_ENDPOINT`, `FLOCI_OCI_ENDPOINT` | The other three emulators | +| `FLOCI_EMULATOR_HOST` | The host of all four default endpoints (`localhost`; `host.docker.internal` in the image) | +| `FLOCI_CLOUD` | Offer one cloud only: `aws`, `az`, `gcp` or `oci` | +| `FLOCI_MCP_READ_ONLY` | `true`: only the tools and actions that change nothing | + +One server per instance, each under its own name (`floci`, `floci-b`), keeps them apart. + +## Troubleshooting + +| Symptom | Fix | +|---|---| +| `floci_status` shows the endpoint but `unavailable` | The emulator is not running, or listens on another port: `floci status -o json`, then pass the endpoint as above | +| Linux, image: every cloud `unavailable` | A hand-written registration uses the bridge network: on native Linux register it with `--network=host -e FLOCI_EMULATOR_HOST=localhost` (and `localhost` in any endpoint) instead of `--add-host=host.docker.internal:host-gateway` | +| The server does not appear in the agent | The client loads servers at start: open a new session. Claude Code: `/mcp` lists it with its error | +| `npx` is slow the first time | It downloads the package once; later starts use the npm cache | +| The plugin's server shows as failed in `/mcp` | No Docker, Podman or Node 20+ was running when the session started: start one and reconnect it in `/mcp` | +| The tools appear twice | Both the plugin and a manual registration provide them: remove the manual one (`claude mcp remove -s user floci`) | diff --git a/skills/floci/scripts/ensure-mcp.sh b/skills/floci/scripts/ensure-mcp.sh new file mode 100755 index 0000000..e02f0f8 --- /dev/null +++ b/skills/floci/scripts/ensure-mcp.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +# Install the Floci MCP server and register it with the agent. +# +# Usage: +# /scripts/ensure-mcp.sh [--npx] [--read-only] [--name NAME] [--scope SCOPE] +# +# --npx run the npm package @floci/mcp (needs Node 20+) instead of the container image +# --read-only offer only the tools that change nothing (FLOCI_MCP_READ_ONLY=true) +# --name NAME the server's name in the agent (default: floci) +# --scope SCOPE Claude Code scope: user (default, every project), local (this project only) +# or project (.mcp.json, shared with the repository) +# +# Runs the image with Docker, or with Podman when Docker is not reachable. Pulls the image (or +# warms the npm cache), checks that the server starts, then registers it +# with Claude Code when the `claude` CLI is present and has neither a server of that name nor +# the floci plugin's server (which would offer the same tools twice). +# Otherwise it prints the configuration to add to the user's MCP client. It never edits the +# configuration files of other clients. Progress goes to stderr. +# Env: FLOCI_MCP_IMAGE, the image to run (default floci/floci-mcp; pin one with floci/floci-mcp:). +# FLOCI_MCP_ENGINE, docker or podman, to choose the engine instead of detecting it. +# FLOCI_MCP_NETWORK, host or bridge: how the container reaches the emulators (default: host on +# native Linux, so ports published on 127.0.0.1 are reached; bridge elsewhere). +# Exit 0: registered, already registered, or snippet printed. Exit 69: no container engine, or no Node. +set -euo pipefail + +mode=docker +read_only=0 +name=floci +scope=user +while [[ $# -gt 0 ]]; do + case "$1" in + --npx) mode=npx ;; + --read-only) read_only=1 ;; + --name) name="${2:?--name needs a value}"; shift ;; + --scope) + scope="${2:?--scope needs a value}"; shift + case "$scope" in user|local|project) ;; *) echo "--scope is user, local or project" >&2; exit 64 ;; esac + ;; + -h|--help) sed -n '2,23p' "$0"; exit 0 ;; + *) echo "unknown argument: $1" >&2; exit 64 ;; + esac + shift +done + +image="${FLOCI_MCP_IMAGE:-floci/floci-mcp}" +# A native Linux engine maps host.docker.internal to the bridge address, which does not reach +# ports published on 127.0.0.1 (how the compose templates publish them). There the container +# shares the host's network instead, so the emulators stay loopback-only and are still reached. +# FLOCI_MCP_NETWORK=host or bridge overrides the choice. +host_network() { + case "${FLOCI_MCP_NETWORK:-}" in host) return 0 ;; bridge) return 1 ;; esac + [[ "$(uname -s)" == Linux ]] || return 1 + ! "$1" info --format '{{.OperatingSystem}}' 2>/dev/null | grep -q 'Docker Desktop' +} +engine_up() { command -v "$1" >/dev/null 2>&1 && "$1" info >/dev/null 2>&1; } + +# Nothing to install when the agent already has the server: check before any download. +if command -v claude >/dev/null 2>&1; then + if [[ "$name" == floci ]] && claude mcp list 2>/dev/null | grep -qE '^plugin[:_]floci[:_]'; then + echo "The floci Claude Code plugin already provides this server; not adding a second one (use --name for another instance)" >&2 + exit 0 + fi + if claude mcp get "$name" >/dev/null 2>&1; then + echo "Claude Code already has an MCP server named $name; leaving it as it is" >&2 + exit 0 + fi +fi + +if [[ "$mode" == docker ]]; then + engine="${FLOCI_MCP_ENGINE:-}" + if [[ -z "$engine" ]]; then + if engine_up docker; then engine=docker + elif engine_up podman; then engine=podman + fi + fi + if [[ -z "$engine" ]] || ! engine_up "$engine"; then + echo "No container engine is reachable (Docker or Podman). Start one, or use --npx (needs Node 20+)." >&2 + exit 69 + fi + echo "pulling $image with $engine..." >&2 + if ! "$engine" pull -q "$image" >&2; then + "$engine" image inspect "$image" >/dev/null 2>&1 || { echo "could not pull $image" >&2; exit 1; } + echo "could not pull $image; using the local copy" >&2 + fi + if host_network "$engine"; then + cmd=("$engine" run -i --rm --network=host -e FLOCI_EMULATOR_HOST=localhost) + else + cmd=("$engine" run -i --rm --add-host=host.docker.internal:host-gateway) + fi + [[ "$read_only" == 1 ]] && cmd+=(-e FLOCI_MCP_READ_ONLY=true) + cmd+=("$image") +else + if ! command -v npx >/dev/null 2>&1; then + echo "npx not found. Install Node 20 or later, or use the Docker image." >&2 + exit 69 + fi + node_major="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)" + if (( node_major < 20 )); then + echo "Node $node_major is too old: @floci/mcp needs Node 20 or later." >&2 + exit 69 + fi + cmd=(npx -y @floci/mcp) +fi + +echo "checking that the server starts..." >&2 +printed="$("${cmd[@]}" --version 2>/dev/null || true)" +if [[ -z "$printed" ]]; then + echo "the server did not start: run '${cmd[*]} --help' to see why" >&2 + exit 1 +fi +echo "floci-mcp $printed" >&2 + +if command -v claude >/dev/null 2>&1; then + env_args=() + [[ "$mode" == npx && "$read_only" == 1 ]] && env_args=(-e FLOCI_MCP_READ_ONLY=true) + claude mcp add --scope "$scope" "$name" ${env_args[@]+"${env_args[@]}"} -- "${cmd[@]}" >&2 + echo "registered with Claude Code as $name ($scope scope): start a new session (or run /mcp) to load it" >&2 + exit 0 +fi + +# No Claude Code: print the configuration for the user's client. +json_args="" +for arg in "${cmd[@]:1}"; do + json_args+="${json_args:+, }\"$arg\"" +done +env_json="" +[[ "$mode" == npx && "$read_only" == 1 ]] && env_json=', "env": {"FLOCI_MCP_READ_ONLY": "true"}' +cat <&2 diff --git a/skills/floci/scripts/floci-mcp.sh b/skills/floci/scripts/floci-mcp.sh new file mode 100755 index 0000000..37711e3 --- /dev/null +++ b/skills/floci/scripts/floci-mcp.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# Start the Floci MCP server on stdio with whatever this machine has: Docker, then Podman, +# then Node (npx). The floci Claude Code plugin runs this; any MCP client can too. +# +# Usage (as an MCP server command): +# /scripts/floci-mcp.sh [floci-mcp arguments] +# +# stdout carries the MCP protocol, so every message from this script goes to stderr. +# Env: FLOCI_MCP_ENGINE (docker, podman or npx) to choose instead of detecting; +# FLOCI_MCP_IMAGE (default floci/floci-mcp); +# FLOCI_CLOUD, FLOCI_MCP_READ_ONLY and the endpoint variables FLOCI_ENDPOINT, +# FLOCI_AZURE_ENDPOINT, FLOCI_GCP_ENDPOINT, FLOCI_OCI_ENDPOINT are passed to the server; +# FLOCI_MCP_NETWORK (host or bridge) to choose how the container reaches the host. +# In a container on native Linux the server shares the host's network; elsewhere an +# endpoint on localhost is rewritten to host.docker.internal. +# Exit 69: no Docker, Podman or Node 20+ to run it with. +set -euo pipefail + +image="${FLOCI_MCP_IMAGE:-floci/floci-mcp}" +passed=(FLOCI_CLOUD FLOCI_MCP_READ_ONLY FLOCI_ENDPOINT FLOCI_AZURE_ENDPOINT FLOCI_GCP_ENDPOINT FLOCI_OCI_ENDPOINT) + +# A native Linux engine maps host.docker.internal to the bridge address, which does not reach +# ports published on 127.0.0.1 (how the compose templates publish them). There the container +# shares the host's network instead, so the emulators stay loopback-only and are still reached. +# FLOCI_MCP_NETWORK=host or bridge overrides the choice. +host_network() { + case "${FLOCI_MCP_NETWORK:-}" in host) return 0 ;; bridge) return 1 ;; esac + [[ "$(uname -s)" == Linux ]] || return 1 + ! "$1" info --format '{{.OperatingSystem}}' 2>/dev/null | grep -q 'Docker Desktop' +} +engine_up() { command -v "$1" >/dev/null 2>&1 && "$1" info >/dev/null 2>&1; } +node_ok() { + command -v npx >/dev/null 2>&1 && + (( $(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0) >= 20 )) +} + +engine="${FLOCI_MCP_ENGINE:-}" +if [[ -z "$engine" ]]; then + if engine_up docker; then engine=docker + elif engine_up podman; then engine=podman + elif node_ok; then engine=npx + else + echo "floci-mcp: no Docker, Podman or Node 20+ found. Start Docker or Podman, or install Node, then reconnect the server (/mcp in Claude Code)." >&2 + exit 69 + fi +fi + +if [[ "$engine" == npx ]]; then + exec npx -y @floci/mcp "$@" +fi + +if host_network "$engine"; then + net_args=(--network=host -e FLOCI_EMULATOR_HOST=localhost) + rewrite=0 +else + net_args=(--add-host=host.docker.internal:host-gateway) + rewrite=1 +fi + +env_args=() +for var in "${passed[@]}"; do + value="${!var:-}" + [[ -z "$value" ]] && continue + # On a bridge network, localhost inside the container is the container itself. + if (( rewrite )); then + value="$(sed -E 's#://(localhost|127\.0\.0\.1|localhost\.floci\.io)([:/]|$)#://host.docker.internal\2#' <<<"$value")" + fi + env_args+=(-e "$var=$value") +done + +exec "$engine" run -i --rm "${net_args[@]}" \ + ${env_args[@]+"${env_args[@]}"} "$image" "$@"