mountable.io

LLM provider starters

Give OpenAI, Anthropic, Gemini and Grok agents a shared filesystem with a hard monthly spend cap per end user, SDK access and signed webhooks.

All four starters use the same backend workflow: create one capped filesystem per end user, use its files through mountable-sdk, and receive signed files.changed webhooks when a backend or sandbox changes them. The provider tools also create tickets to mount those files in a sandbox. Tested modules live in examples/llm-providers in the public CLI repository.

Get the starters

Use Python 3.10 or newer. Run the Python snippets below from the starters' directory so imports such as workspace and handoff resolve:

git clone https://github.com/writeitai/mountable.git
cd mountable/examples/llm-providers
python -m venv .venv
. .venv/bin/activate
pip install mountable-sdk==0.2.0

The SDK installs httpx, which the backend helpers use for provisioning and webhook registration. Install your provider's library separately when calling a model. Mounting also needs the CLI and FUSE in the sandbox; follow Mount from a sandbox. SDK file access needs neither.

Keep MOUNTABLE_API_KEY (an API key created by an owner or admin, not limited to one filesystem) and MOUNTABLE_MANAGEMENT_KEY (a management key) in your backend environment. Provisioning needs the management key and a saved payment method. Your backend chooses the end user, filesystem and cap. Store that mapping and validate tool calls against it before dispatch: model arguments must not select another user's filesystem or raise a cap. Keep provisioning and webhook secrets out of model messages.

Create a capped workspace

Create the workspace once per end user, before any provider tool runs. The shared workspace.py helper creates it with the management key, sets the limits in the create request, and gives the backend's API key read-write access:

import os
import httpx
from workspace import create_workspace
 
 
def client(key):
    return httpx.Client(
        base_url="https://mountable.io", timeout=30, follow_redirects=False,
        headers={"Authorization": "Bearer " + os.environ[key]},
    )
 
 
admin = client("MOUNTABLE_MANAGEMENT_KEY")  # creates filesystems
backend = client("MOUNTABLE_API_KEY")  # works with files and webhooks
key = backend.get("/api/v1/me").raise_for_status().json()["api_key"]
org_id = key["org_id"]  # the API key's organisation, used below too
fs_id = create_workspace(admin, org_id, "user-42", 500, key["id"])
admin.close()
# Save fs_id against your authenticated user before dispatching their tools.

500 means 500 cents per UTC calendar month in your organisation's billing currency ($5 or €5). This helper also sets 60 changes per minute, 1 GiB storage and 10,000 entries. Your organisation's cap still applies on top. This helper sets them through REST; with the management key, the SDKs' create_filesystem / createFilesystem and the CLI's fs create take the same limits. See limits per end user for changing them later and how reserved usage counts toward a cap.

After a create timeout, inspect the filesystem list before retrying: the workspace may already exist. Do not create a new filesystem on every model call.

Read and write with mountable-sdk

The backend can prepare a task and read results without mounting. Reuse one filesystem handle across calls so they share a token session:

from mountable_sdk import Mountable
 
with Mountable(base_url="https://mountable.io") as client:
    fs = client.filesystem(fs_id, mode="rw")
    fs.write("task.md", "Write a short report.")
    task = fs.read("task.md").data.decode("utf-8")
    # Dispatch your provider here and read its output with this same handle.

TypeScript backends use the same files. After npm install mountable-sdk@0.2.0, with fsId taken from your stored user mapping:

import { Mountable } from "mountable-sdk";
 
const client = new Mountable({ baseUrl: "https://mountable.io" });
const fs = client.filesystem(fsId, "rw");
await fs.write("task.md", "Write a short report.");
const task = new TextDecoder().decode((await fs.read("task.md")).data);

Open a separate "ro" handle for a reader that must not write. A sandbox mount sees task.md at /mnt/work/task.md. The SDK reference covers conditional writes, following changes and ticket creation.

When an SDK call raises MountableError with status 402 and code filesystem_spending_cap_reached, stop that user's billable work. Other users' filesystems keep working. spending_cap_reached means the organisation cap was reached. On 429 rate_limited, wait retry_after seconds in Python or retryAfter in TypeScript. A write timeout has an unknown outcome: read back or use a conditional write before trying again.

Receive signed file changes

Start a public HTTPS receiver before registering the webhook. Register before the agent writes its outputs. This uses the same fs_id as the SDK and provider tools:

from workspace import register_webhook
 
hook = register_webhook(
    backend, org_id, fs_id,
    "https://your-app.example/hooks/mountable",
)
backend.close()  # also close these clients on errors in your application
# Store hook["id"] and the one-time hook["secret"] in your backend secret store.

Do not log the registration or send it to a model. Until the secret and ID are stored, the receiver should return 503 so the initial files.resync can be retried. Your HTTP handler authenticates the untouched request bytes before processing JSON:

from workspace import verify_webhook
 
# raw_body (bytes) and request_headers come from your HTTP framework.
# Load hook and fs_id from your backend's stored registration.
message = verify_webhook(
    hook["secret"], request_headers, raw_body,
    filesystem_id=fs_id, webhook_id=hook["id"],
)
# On ValueError, reject with 400/401 and do not process the request.
# Otherwise durably enqueue message, then answer 2xx within 10 seconds.

The helper checks the HMAC signature, a five-minute timestamp window, the filesystem ID and the webhook ID. Your application supplies the HTTP server, durable queue and cursor storage. In the worker, apply a message only when int(message["data"]["cursor"]) is greater than the last stored cursor for that webhook. Store the cursor with the applied result to discard retries and late deliveries.

For files.changed, reconcile each path in data.events[] to its file value. A new file is created, a write is updated, and a rename produces deleted for the old path plus created for the new one. Mount writes can produce several events. Treat these as current-state invalidations, not a history to replay.

For files.resync, list the files you track through the SDK. Queue messages arriving during the listing and apply them by cursor afterward. Ignore types you do not handle while still recording their cursor and acknowledging the delivery. See webhooks for the payload, signature format, delivery retries and secret rotation.

What crosses the boundary

MOUNTABLE_API_KEY stays in the orchestrator environment. The mount process reads the one-time ticket on stdin. In a shell, that looks like this, where MOUNTABLE_TICKET is the ticket and not the API key:

mkdir -p /mnt/work
printf '%s\n' "$MOUNTABLE_TICKET" | mountable mount --ticket-stdin --json /mnt/work &

The & leaves mount running so it can keep renewing the session certificate. Wait for the JSON line with event mounted before using /mnt/work. The ticket is single-use and must be exchanged within five minutes. Keep the session id on the orchestrator and revoke with mountable sessions revoke SESSION_ID. A revoked mount stops admitting new operations within fifteen seconds. Retry rules for a lost ticket are on Agents. Do not mount when the response has no ticket.

When the orchestrator calls prepare, start the child with mount.env, which already has the API key removed. When it only has the tool result, use sandbox_env instead of passing os.environ through unchanged. In the sandbox, run mkdir -p /mnt/work before starting sandbox.argv, write sandbox.stdin to that child's stdin, and leave the process running. Do not wait for it to exit. A remote sandbox does not inherit the orchestrator environment; send it sandbox.argv and sandbox.stdin only.

Shared handoff

Use the capped fs_id from your stored user mapping for every provider. Prepare task files through the SDK and register the webhook before dispatching the tool. All four modules return the same mount instructions:

ProviderModuleRegistration
OpenAI Responses API / Agents SDKopenai_responses.pyTOOL / function_tool(create_mount_session)
Anthropic Messages API / Claude Codeanthropic_tools.pyTOOL / MCP create_mount_ticket
Gemini function calling / ADKgemini_adk.pyFUNCTION_DECLARATION / tools=[create_mount_session]
xAI Grokxai_grok.pyTOOL with the xAI API client

The mount helpers use only the Python standard library. On the orchestrator, with MOUNTABLE_API_KEY set:

from handoff import prepare
 
mount = prepare(fs_id, "job-42-mount-1", read_only=False)
# In the sandbox, run mkdir -p /mnt/work before starting mount.argv.
# Start that child and leave it running. Write mount.stdin to its stdin,
# using mount.env so the API key is absent. Read stdout until the mounted
# event. Do not wait for the process to exit.

prepare runs mountable ticket create FS_ID --idempotency-key KEY --json (and --ro when read_only is true). The API key is an environment variable of that process, not a command argument. The same create_mount_session function is what each provider tool calls. Its return value is the tool result: session_id for a later revoke, and sandbox for the mount. Choose a fresh idempotency key for each new mount; reuse it only when retrying that ticket creation. Keep the tool result out of model messages if the model does not need it: dispatch the sandbox instructions directly.

OpenAI Agents SDK and Responses API

examples/llm-providers/openai_responses.py exports TOOL and create_mount_session.

The shared SDK, cap and webhook steps above run on your backend before the Agents SDK function tool or Responses API tool dispatch.

Agents SDK, in the orchestrator process:

from agents import Agent, function_tool
from openai_responses import create_mount_session
 
agent = Agent(
    name="orchestrator",
    instructions="Mint a mountable.io ticket before starting a sandbox. Pass only sandbox.stdin into the sandbox.",
    tools=[function_tool(create_mount_session)],
)

Responses API: send TOOL in tools. TOOL is a strict function named create_mount_session with filesystem_id, idempotency_key and read_only. On a function_call, run create_mount_session on the orchestrator and return its JSON. Start the sandbox from sandbox, not from the orchestrator's environment.

Anthropic Claude Code and tool use

For a complete CLI-to-SDK file handoff, see Claude Code and Claude Agent SDK.

Claude Code on the trusted machine should use the MCP server. MOUNTABLE_API_KEY belongs in the MCP server environment. Call create_mount_ticket. The result includes ticket and mount_command. Pass the ticket to the sandbox on stdin. Do not copy the MCP env block into the sandbox.

For the Messages API, examples/llm-providers/anthropic_tools.py exports TOOL (name, description, input_schema) and the same create_mount_session function. Run that function on the orchestrator when the model calls the tool. The SDK file access, cap provisioning and webhook receiver stay on your backend for both Messages tool use and Claude Code.

Gemini ADK and function calling

examples/llm-providers/gemini_adk.py exports create_mount_session. After your backend creates the capped workspace and registers its webhook, ADK turns that function into a function tool:

from google.adk.agents.llm_agent import Agent
from gemini_adk import create_mount_session
 
root_agent = Agent(
    name="orchestrator",
    model="gemini-flash-latest",
    instruction="Mint a mountable.io ticket before starting a sandbox. Pass only sandbox.stdin into the sandbox.",
    tools=[create_mount_session],
)

A researcher agent and a coder agent can share one filesystem: mint rw for the writer and read_only=True for the reader. Raw function calling uses FUNCTION_DECLARATION in the same file. The function still runs on the orchestrator.

xAI Grok

examples/llm-providers/xai_grok.py uses the same flat Responses tool as OpenAI. Use the shared SDK, cap and webhook workflow on your backend, then point the client at xAI and handle the function call with create_mount_session on the orchestrator:

import os
from openai import OpenAI
from xai_grok import TOOL
 
client = OpenAI(base_url="https://api.x.ai/v1", api_key=os.environ["XAI_API_KEY"])
# client.responses.create(model="grok-4.7", input=messages, tools=[TOOL])

XAI_API_KEY is the Grok credential. It is separate from MOUNTABLE_API_KEY, and neither one goes into the sandbox. The xAI SDK's xai_sdk.chat.tool accepts the same name, description and parameters.

Mastra file tools

Run the Mastra community example to save a note in a deterministic workflow and read it from a fresh process. Maintained by mountable.io.

Semantic Kernel native functions

Run the Semantic Kernel community example to save a note with a native function and read it in a fresh process. It uses Kernel.invoke without a model call. Maintained by mountable.io separately from Microsoft.

Strands Agents tools

Run the Strands Agents community example to save a note with a @tool function and read it in a fresh process. It uses the validated tool-use stream without a model call. Maintained by mountable.io separately from AWS and the Strands project.

Deno

Run the Deno example to save a note with the released TypeScript SDK and read it in a fresh process. The script asks only for the API key, filesystem id, note path and mountable.io. Maintained by mountable.io. It is a local Deno script, not a Deno Deploy app.

After the mount

Wait for the JSON line with event mounted before reading or writing /mnt/work. Unmount with mountable unmount /mnt/work so pending writes finish. The sandbox needs FUSE (/dev/fuse) and the mountable CLI; see Mount from a sandbox.