# AI Agents & MCP

Membl is the agentic datacenter: infrastructure built to make shipping easier for coding agents and optimize spend. Assistants like Claude Code, Codex, Cursor, and Antigravity get self-sizing Liquid Runners, structured failure diagnostics instead of raw log dumps, deployment status checks, and per-job cost receipts.

<Cards>
  <Card title="Workflow Schema" href="/docs/workflow-schema">
    Authoritative v1 JSON schema and syntax specification.
  </Card>

  <Card title="1-Click Setup" href="/docs/one-click-setup">
    Automated stack scanning and blueprint generation.
  </Card>

  <Card title="Pipelines Overview" href="/docs/pipelines">
    Managed runner architecture and 4 core pillars.
  </Card>

  <Card title="llms.txt Index" href="/llms.txt">
    Machine-readable index of Membl features and docs.
  </Card>
</Cards>

## Agent discovery & Markdown-native docs

Coding agents discover and ingest Membl documentation through open standards:

### 1. `llms.txt` and full bundles

* **Index**: [`https://membl.io/llms.txt`](/llms.txt) provides a compact, structured summary of Membl features, quickstart instructions, and tool commands.
* **Full bundle**: [`https://membl.io/llms-full.txt`](/llms-full.txt) (aliased at [`/llms-all.txt`](/llms-all.txt)) concatenates all public documentation pages into a single Markdown file for rapid LLM context-window ingestion.

### 2. URL `.md` twins and content negotiation

Every public documentation page on `membl.io` has an identical plain Markdown twin:

* Append `.md` to any documentation path (e.g., [`/docs/pipelines.md`](/docs/pipelines.md), [`/docs/workflow-schema.md`](/docs/workflow-schema.md)).
* Or send `Accept: text/markdown` in HTTP request headers. Membl automatically responds with a `307 Temporary Redirect` to the corresponding `.md` twin.
* Human users can click **Copy markdown** or **View as Markdown** at the top and bottom of every documentation article.

## Official Membl MCP Server (`@membl/mcp`)

The official Membl Model Context Protocol (MCP) server (`@membl/mcp` v0.3.0) is a lightweight Node.js JSON-RPC 2.0 server (using `ajv` for JSON Schema validation and `yaml` for workflow parsing) that works with any MCP-compliant agent. It supports two transports:

* **Stdio (default):** `npx -y @membl/mcp` (newline-delimited JSON-RPC 2.0 on stdin/stdout).
* **Streamable HTTP:** `npx -y @membl/mcp --http --port 3333 --host 127.0.0.1` (exposes `POST /mcp`, `POST /`, and `GET /healthz`, with optional `MCP_HTTP_AUTH_TOKEN` enforcing `Authorization: Bearer <token>`).

### Authentication, Scopes & Direct Agent Connections

Create scoped organization API tokens (`mbl_...`) or configure direct coding agent connections (for **Send to coding agent** on failed runs) under **Settings -> Connections** in [app.membl.io](https://app.membl.io). Pass `MEMBL_API_TOKEN` at runtime via 1Password `op run` or your client secret store (optional env vars: `MEMBL_ORG` or `MEMBL_TENANT`, and `MEMBL_API_URL`):

* **`read` scope (default):** Grants read access (`GET`, `HEAD`, `OPTIONS`) scoped to the token's organization, including headerless org discovery (`GET /api/v1/orgs`).
* **`write` scope (opt-in):** Must be created by an organization owner or admin. Organization administration endpoints (members, invites, billing, providers, and token management) always require an interactive browser session.
* **Public OpenAPI 3.1 spec:** [`https://app.membl.io/docs/openapi.yaml`](https://app.membl.io/docs/openapi.yaml) documents Customer Public API v1 endpoints, `BearerAuth` scopes, and schemas.
* **Workflow JSON Schema v1:** [`https://membl.io/schemas/membl-workflow.v1.json`](https://membl.io/schemas/membl-workflow.v1.json).

### Client configuration

Configure `@membl/mcp` across your agent environments:

<Tabs items={["Claude Code", "Cursor", "Codex", "Antigravity"]}>
  <Tab value="Claude Code">
    Add to `~/.claude.json` or `.mcp.json` in your repository root:

    ```json
    {
      "mcpServers": {
        "membl": {
          "command": "npx",
          "args": ["-y", "@membl/mcp"],
          "env": {
            "MEMBL_ORG": "your-org",
            "MEMBL_API_TOKEN": "${MEMBL_API_TOKEN}"
          }
        }
      }
    }
    ```

    Or install via the CLI:

    ```bash
    claude mcp add membl -- npx -y @membl/mcp
    ```
  </Tab>

  <Tab value="Cursor">
    Add to `.cursor/mcp.json`:

    ```json
    {
      "mcpServers": {
        "membl": {
          "command": "npx",
          "args": ["-y", "@membl/mcp"],
          "env": {
            "MEMBL_ORG": "your-org",
            "MEMBL_API_TOKEN": "${env:MEMBL_API_TOKEN}"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab value="Codex">
    Add to `~/.codex/config.toml`:

    ```toml
    [mcp_servers.membl]
    command = "npx"
    args = ["-y", "@membl/mcp"]

    [mcp_servers.membl.env]
    MEMBL_ORG = "your-org"
    MEMBL_API_TOKEN = "${MEMBL_API_TOKEN}"
    ```

    Or install via the CLI:

    ```bash
    codex mcp add membl -- npx -y @membl/mcp
    ```
  </Tab>

  <Tab value="Antigravity">
    Add to `~/.gemini/antigravity/mcp_config.json`:

    ```json
    {
      "mcpServers": {
        "membl": {
          "command": "npx",
          "args": ["-y", "@membl/mcp"],
          "env": {
            "MEMBL_ORG": "your-org",
            "MEMBL_API_TOKEN": "${MEMBL_API_TOKEN}"
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

### Active MCP tools (`@membl/mcp` v0.3.0)

#### Workflow Planning & Validation (3 local tools, no API token required)

| Tool                      | Scope | Description                                                                                                                                                                                                                                                                |
| ------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `membl_plan_workflow`     | Local | Analyzes repository marker files (bounded `<= 64 KB`, strictly ignoring `.env*`) and outputs a hardened, parallel DAG workflow blueprint with `CI / ci` gate jobs.                                                                                                         |
| `membl_validate_workflow` | Local | Validates `.membl/workflows/*.yml` against [`https://membl.io/schemas/membl-workflow.v1.json`](https://membl.io/schemas/membl-workflow.v1.json) and `.github/workflows/*.yml` (`format: "github"`) for least-privilege permissions, SHA pinning, timeouts, and DAG cycles. |
| `membl_migrate_workflow`  | Local | Rewrites GitHub-hosted Ubuntu x64 runner labels (`ubuntu-latest`, `ubuntu-24.04`, `ubuntu-22.04`, `ubuntu-20.04`, `ubuntu-slim`) to `membl-x64` and Arm64 labels (`ubuntu-24.04-arm`, `ubuntu-22.04-arm`) to `membl-arm`, while preserving macOS and Windows jobs.         |

#### CI Observability, Triage & Deployments (9 API tools, `read` scope)

| Tool                      | Scope  | Description                                                                                                                                                                                                   |
| ------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `membl_list_orgs`         | `read` | Lists Membl organizations accessible to `MEMBL_API_TOKEN` headerless (`GET /api/v1/orgs`).                                                                                                                    |
| `membl_list_repos`        | `read` | Lists connected repositories for an organization with search, sorting, and cursor pagination (`GET /api/v1/orgs/{tenant}/repositories`).                                                                      |
| `membl_list_runs`         | `read` | Lists recent workflow runs with status/conclusion, repo, workflow, branch, actor, trigger, sort, and cursor filters (`GET /api/v1/orgs/{tenant}/runs`).                                                       |
| `membl_get_run_logs`      | `read` | Fetches structured job logs from native runner logs (`GET /api/v1/orgs/{tenant}/runs/{id}/jobs/{jobId}/logs`) or paginated historical logs (`GET /api/v1/orgs/{tenant}/job-logs`) with plain-text extraction. |
| `membl_get_run_failure`   | `read` | Returns compact failure diagnostics, root-cause hints, `main` baseline regression comparison, and redacted job log excerpts for a failed run or job.                                                          |
| `membl_diagnose_run`      | `read` | Fetches target run/job status and structured logs from `app.membl.io`, redacts secrets, isolates root causes, compares against `main`, and returns concrete remediation steps.                                |
| `membl_deployment_status` | `read` | Checks release verification gates and merge confidence for a single repository (with optional `ref`) or org-wide when `repo` is omitted (`GET /api/v1/orgs/{tenant}/releases/status`).                        |
| `membl_list_deployments`  | `read` | Lists recorded GitHub Deployments with environment, repository, status, and cursor filters (`GET /api/v1/orgs/{tenant}/deployments`).                                                                         |
| `membl_get_deployment`    | `read` | Returns full detail, status history, and linked CI runs for a single deployment (`GET /api/v1/orgs/{tenant}/deployments/{id}`).                                                                               |

Legacy v0.2.0 tool names (`membl_plan_pipeline`, `membl_validate_pipeline`, and `membl_ship_status`) remain accepted as deprecated aliases in v0.3.0 and are scheduled for removal in v0.4.0.

## Official Membl agent skills

Install the public Membl agent skills from `Palmetto-Interactive-LLC/membl-website`:

```bash
npx skills add Palmetto-Interactive-LLC/membl-website
```

This installs two focused skills compatible with Claude Code, Cursor, Codex, and Antigravity:

* **`membl-general`** (`skills/membl-general/SKILL.md`): Product overview, account creation, Markdown-native public docs discovery (`/llms.txt`, `.md` twins, `Accept: text/markdown`), and pricing/security references.
* **`membl-github-runners`** (`skills/membl-github-runners/SKILL.md`): Minimal `runs-on` migration onto `membl-x64` / `membl-arm`, billing/receipts rules, and safe fallback to `ubuntu-latest`.

## The autonomous build-fix loop

Membl enables an autonomous preflight and verification loop for coding agents:

<Steps>
  <Step>
    ### 1. Plan or migrate workflow

    The agent calls `membl_plan_workflow` (or `membl_migrate_workflow`) to generate an optimized workflow definition tailored to the repository's detected stack and tooling.
  </Step>

  <Step>
    ### 2. Validate against schema

    Before staging changes, the agent calls `membl_validate_workflow` to verify that all syntax, cache presets, permissions, and compute attributes conform strictly to [`https://membl.io/schemas/membl-workflow.v1.json`](https://membl.io/schemas/membl-workflow.v1.json) (or GitHub Actions security best practices with `format: "github"`).
  </Step>

  <Step>
    ### 3. Push branch and trigger CI

    The agent pushes the working branch and opens or updates a pull request. Managed sandboxes and in-place block-overlay cache mounts on Membl runners start execution without cold-queue stalls.
  </Step>

  <Step>
    ### 4. Structured failure diagnosis

    If a check fails, the agent calls `membl_list_runs`, `membl_diagnose_run`, `membl_get_run_failure`, or `membl_get_run_logs` over `@membl/mcp` (or queries the Customer Public API documented at [`https://app.membl.io/docs/openapi.yaml`](https://app.membl.io/docs/openapi.yaml)). The structured response redacts secrets, isolates failing tests and root causes, and compares against the `main` baseline without scraping terminal HTML.
  </Step>

  <Step>
    ### 5. Remediation & deployment confidence

    The agent implements the targeted code fix, pushes to re-run CI, and calls `membl_deployment_status` (or `membl_list_deployments` and `membl_get_deployment`) to verify that required gates (`CI / ci`) and environment deployments succeeded.
  </Step>
</Steps>

