Skip to main content
Glama
README.md
<p align="center">
  <img src="assets/logo.png" alt="Cooperage" width="420">
</p>

---

Cooperage gives an LLM a fully observable sandbox with a registry of AI-ready tools, each running in its own isolated container with dedicated CPU/memory and a shared workspace volume.

<p align="center">
  <img src="assets/cooperage_screenshot.png" alt="Cooperage in action — Web UI session monitor alongside Claude Desktop" width="820">
</p>

## The problem

Most AI tool infrastructure assumes tools are REST APIs. But the tools that actually matter at companies with big systems engineering — simulation engines, data pipelines, sensor processors, analysis libraries — are heavyweight compute systems. They can't be stateless. They can't live behind an HTTP endpoint.

Cooperage is built for those tools.

Every company with serious systems engineering has institutional knowledge locked inside heavyweight compute tools. Cooperage connects them and lets AI orchestrate across all of them.

## How it works

The LLM orchestrates tools across isolated containers. Data flows through a shared `/workspace` volume, not context windows. Each tool gets its own container with dedicated resources, spun up on demand.

**The key idea:** multiple containers per session, one shared `/workspace` volume. A generator writes a file, an analyzer reads it, a report writer summarizes it — all orchestrated by the LLM, all passing data through the same volume.

## Quick start

**Prerequisites:** Python 3.11+, [uv](https://docs.astral.sh/uv/getting-started/installation/)

```bash
git clone https://github.com/cooperage-io/cooperage.git && cd cooperage
uv sync
```

### Register a tool

**Option A — Docker image** (full control):

```bash
docker buildx build --load -t my-analyzer:latest my-server/
uv run cooperage register \
  --name my-analyzer \
  --image my-analyzer:latest \
  --description "Analyze data in /workspace"
```

**Option B — Wrap an existing API** (no Docker needed):

```yaml
# weather-api.yaml
name: weather
type: rest-api
base_url: https://api.weather.com/v1
auth:
  type: bearer
  token: ${WEATHER_API_KEY}
tools:
  - name: get_forecast
    description: Get weather forecast
    method: GET
    path: /forecast
    params:
      latitude: {type: number, description: "Latitude"}
      longitude: {type: number, description: "Longitude"}
```

```bash
uv run cooperage register --from weather-api.yaml --env WEATHER_API_KEY=sk-xxx
```

**Option C — Wrap LangChain tools**:

```yaml
# my-tools.yaml
name: my-tools
type: langchain
source: /workspace/tools.py
```

```bash
uv run cooperage register --from my-tools.yaml
```

### Connect to Claude Desktop

Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "cooperage": {
      "command": "/Users/YOU/.local/bin/uv",
      "args": ["--directory", "/path/to/cooperage", "run", "--no-active", "cooperage", "start"]
    }
  }
}
```

Restart Claude Desktop. The hammer icon appears — Cooperage is connected.

### HTTP mode

```bash
uv run cooperage start --sse
```

Starts the gateway on `http://localhost:8080/mcp`.

### Remote gateway (cloud deployment)

```bash
uv run cooperage start --proxy http://your-server:8080/mcp --api-key sk-your-key
```

Bridges your local Claude Desktop to a remote gateway over HTTP.

## What the LLM can do

| Tool | Purpose |
|------|---------|
| `cooperage_list_servers` | Discover available tools |
| `cooperage_create_session` | Start a workspace session |
| `cooperage_call_tool` | Call a tool on any server |
| `cooperage_list_tools` | See what a server offers |
| `cooperage_workspace_read/write/list` | Read and write files in the shared workspace |
| `cooperage_run_script` | Execute Python with numpy/pandas/scipy |
| `cooperage_run_bash` | Execute shell commands |
| `cooperage_get_container_logs` | View a container's stdout/stderr |
| `cooperage_set_session_expiry` | Extend a session (up to 72 hours) |
| `cooperage_end_session` | Tear down and clean up |

## Multi-tool pipelines

This is the core use case. Containers share `/workspace`:

```
1. cooperage_call_tool(session, "web-scraper", "scrape_table",
     {url: "https://example.com/data", output: "sales.csv"})
     → fetches HTML table, saves /workspace/sales.csv

2. cooperage_call_tool(session, "csv-analyzer", "analyze_csv", {path: "sales.csv"})
     → reads sales.csv, returns statistics

3. cooperage_call_tool(session, "csv-analyzer", "plot_column",
     {path: "sales.csv", column: "revenue", chart_type: "bar", output: "chart.png"})
     → generates /workspace/chart.png

4. cooperage_call_tool(session, "pdf-report", "generate_report", {
     title: "Sales Analysis",
     sections: [
       {heading: "Data", file: "sales.csv"},
       {heading: "Revenue by Region", file: "chart.png"},
     ],
     output: "report.pdf"
   })
     → compiles /workspace/report.pdf
```

Three containers. One session. One shared volume. Data flows through files, not context windows.

## Writing your own server

Use the [cooperage-sdk](https://github.com/cooperage-io/cooperage-sdk) (`pip install cooperage-sdk`). It handles workspace path resolution, MCP boilerplate, and server startup. You can build a full Docker image for maximum control, or write plain Python functions and skip the Dockerfile entirely — the SDK wraps them automatically.

Example servers:

| Server | Industry | Tools |
|--------|----------|-------|
| [csv-analyzer](example-servers/csv-analyzer/) | General | Statistics, charts, CSV comparison |
| [web-scraper](example-servers/web-scraper/) | General | URL text extraction, HTML table → CSV |
| [pdf-report](example-servers/pdf-report/) | General | Compile workspace files into PDF reports |
| [sequence-analyzer](example-servers/sequence-analyzer/) | Biotech | FASTA parsing, GC content, motif search, composition charts |
| [finance-toolkit](example-servers/finance-toolkit/) | Finance | Portfolio analysis, risk metrics, correlation matrix |
| [log-analyzer](example-servers/log-analyzer/) | DevOps | Log parsing, error grouping, anomaly detection, incident timeline |
| [image-analyzer](example-servers/image-analyzer/) | Imaging | Image analysis with numpy/PIL |
| [synthetic-image-generator](example-servers/synthetic-image-generator/) | Imaging | Generate test imagery |

## Wrapping existing tools

Don't want to write a Docker image? Use `cooperage register --from` with a YAML config:

| Type | What you provide | What happens |
|------|-----------------|--------------|
| `rest-api` | Base URL, auth, tool definitions | HTTP calls proxied to your API (no container) |
| `langchain` | Python file or pip package with `@tool` functions | Auto-discovered and wrapped |

Auth credentials use `${ENV_VAR}` syntax — secrets are passed via `--env`, never stored in config files.

## Kubernetes

Drop-in backend. Same tools, same config — containers run as Pods.

```bash
COOPERAGE_ORCHESTRATOR=kubernetes uv run cooperage init-k8s
COOPERAGE_ORCHESTRATOR=kubernetes uv run cooperage start
```

## Web UI

Real-time dashboard for monitoring sessions, viewing container logs, and browsing workspace files. Supports file upload and download — bring your own data in, pull results out. Cooperage gives the LLM a URL to share with the user when a session starts.

## Enterprise

[cooperage-enterprise](https://github.com/cooperage-io/cooperage-enterprise) adds auth, multi-tenancy, RBAC, session quotas, and audit logging on top of the open-source core (BSL License).

- **Authentication** — API keys, JWT (HS256), OIDC/SSO (Azure AD, Okta, Auth0)
- **Multi-tenancy** — per-tenant session isolation and RBAC
- **Session quotas** — `max_sessions` per tenant
- **Audit logging** — JSON-lines event log for every tool call

The open-source core includes:
- Per-container CPU and memory limits
- Per-session network isolation
- Private image registry auth
- Container idle timeout and session TTL management

## Configuration

All settings use the `COOPERAGE_` prefix. Can go in `.env`.

| Variable | Default | Description |
|----------|---------|-------------|
| `COOPERAGE_ORCHESTRATOR` | `docker` | `docker` or `kubernetes` |
| `COOPERAGE_SESSION_TTL_SECONDS` | `1800` | Session auto-expiry (30 min) |
| `COOPERAGE_CONTAINER_IDLE_TIMEOUT` | `600` | Stop idle containers (10 min) |
| `COOPERAGE_CONTAINER_STARTUP_TIMEOUT` | `120` | Readiness probe timeout |
| `COOPERAGE_DEFAULT_CPU_LIMIT` | `1.0` | CPU limit per container |
| `COOPERAGE_DEFAULT_MEMORY_LIMIT` | `512m` | Memory limit per container |
| `COOPERAGE_NETWORK_ISOLATION` | `true` | Per-session Docker networks |
| `COOPERAGE_UI_URL` | — | UI URL shown after session creation |

## CLI

```
cooperage register       Register a tool (Docker image or --from config)
cooperage deregister     Remove a tool
cooperage list-servers   List registered tools
cooperage sessions       List active sessions
cooperage start          Start the gateway (stdio, --sse, or --proxy)
cooperage init-k8s       Bootstrap Kubernetes namespace
cooperage ui             Launch the web dashboard
cooperage clear          Stop all containers and reset state
```

## Tests

```bash
uv run pytest -v
```

## License

Public core: [MIT](LICENSE). Enterprise: BSL License