Skip to content

How bindings work

A binding wires a service to your server once. Every sandbox you create on that server gets the connection details in its env. Skip the section entirely if you don't need any services.

The flow

You: agentry service bind mongodb  (paste your connection URL)

agentry: stores the URL on this server

Next sandbox you create automatically gets:

  MONGODB_URL=mongodb://<the-exact-url-you-pasted>
  in its env

Your AI agent's code reads MONGODB_URL — done

Three things matter:

  1. Server-scoped. The bind lives on a specific server. Bindings don't auto-replicate across servers; you bind separately on each one.
  2. Inherited automatically. Sandboxes created after the bind get the env. Sandboxes created before don't — see retrofit below.
  3. The URL is used verbatim — no automatic isolation. agentry stamps the exact connection string you supplied into every sandbox. Every sandbox (and the deployment built from it) points at the same database. If you want prototypes not to collide, ask the agent to namespace — a Postgres schema, a Mongo database name, a Redis key prefix. See Add a database.

What gets bound

Three categories:

CategoryExamplesWhat you get
Databasesmongodb, postgres, redis, mysqlYour connection URL in env
AI providersanthropic, openai, openrouter, groqAPI key in env (e.g. ANTHROPIC_API_KEY)
Object storages3Bucket + access creds in env
Vector storespinecone, weaviateEndpoint + key in env
Emailsendgrid, smtpAPI key + sender details
Customanything you defineYou pick the env var names

In every case agentry stores the values you supply and stamps them, unchanged, into each new sandbox's env. Don't have a database yet? See Get a free database. See the services list for everything available.

Binding from the CLI

The fastest way:

bash
agentry service bind <service-name>

agentry prompts for whatever credentials it needs (API key, connection string, etc.), then confirms the binding.

Examples:

bash
agentry service bind mongodb       # prompts for connection URL
agentry service bind anthropic     # prompts for API key
agentry service bind openrouter    # prompts for API key

Binding from the dashboard

app.agentry.run/clusters → click your server → Services tab → Add binding.

Same options as the CLI. The dashboard is friendlier for first-time setup; the CLI is friendlier for scripting / automation.

What the AI sees

The bound env appears in every new sandbox under the standard variable names code libraries already expect:

Bound serviceEnv var(s) in sandbox
mongodbMONGODB_URL
postgresDATABASE_URL, POSTGRES_URL
redisREDIS_URL
anthropicANTHROPIC_API_KEY
openaiOPENAI_API_KEY
openrouterOPENROUTER_API_KEY
s3AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET
pineconePINECONE_API_KEY, PINECONE_INDEX

This means: your AI's generated code reads process.env.MONGODB_URL and finds it already there. No config file to copy. No glue code to write.

sandbox_create response shows bindings

When the AI calls sandbox_create, the response includes a bindings array listing what's wired into that sandbox. A well-prompted agent reads this first and skips redundant setup (no mongodb-memory-server, no fake stubs).

If you see your agent creating a local fake for something that should be bound, the binding wasn't there at sandbox-create time. See retrofit.

Retrofit

If you bound a service after creating a sandbox, the env var won't be there. Two options:

Option A — easier — create a fresh sandbox:

In your harness chat:

Create a new sandbox and re-scaffold the project. The old sandbox is missing the MongoDB binding.

Option B — keep the sandbox, set the env manually:

bash
agentry env set --sandbox <sandbox-id> MONGODB_URL <connection-url>

The variable becomes available immediately to new processes started in the sandbox. Existing processes need a restart.

Removing a binding

bash
agentry service unbind <service-name>

Or in the dashboard, click the binding → Remove. New sandboxes won't inherit it; existing sandboxes keep their already-stamped env.

Bindings + deployments

When you deploy, the bound env carries through to the production container — your deployed app reads the same MONGODB_URL it used in dev. The connection points at the same database the sandbox was using.

Same connection in dev and prod

The deployment inherits the exact bound URL the sandbox used, so production points at the same database as your prototype. Sometimes that's what you want. If not, override the var at deploy time — see Environment variables.

Next

agentry — run AI-built apps on your own hardware.