Connect Claude or Codex to your app
This guide connects an AI coding assistant on your own computer (Claude Code, Claude Desktop, Codex or another Model Context Protocol client) to one of your TenancyEngine applications, so it can inspect and configure that application for you. The assistant gets a key that is limited to that application. It cannot reach your other applications, other organizations or the platform administration console.
Everything below uses placeholders. You never paste a real key into a chat, a ticket, a prompt or a source file.
Two kinds of MCP, and which one this is
| Developer-management MCP (this guide) | Tenant runtime MCP | |
|---|---|---|
| Who uses it | You, building your application | Your own customers' assistants |
| What it does | Inspect and configure your application: environments, features, offerings, settings | Reads and changes your customers' data inside your application |
| Credential | A developer key limited to your application | A connector key your customers hold |
| Guide | This page | Connect an AI assistant (MCP) |
A developer key is also not an OAuth client ID and not an end-user sign-in. The public client identifier your application shows to browsers and apps is not a secret. The developer key is a secret. A signed-in end user is a person who uses your application. Never put a developer key in browser code, in a mobile app or in your application's source.
Lane and environment are different things
- A lane is which TenancyEngine deployment you talk to:
production,stagingorlab. Your key belongs to exactly one lane. - An environment is a stage of your application on that deployment: Development, Staging or Production. A key can be limited to some environments, and the default is Development only.
Do not confuse them. An application's Development environment on the production deployment is not the lab deployment. A key made on the lab lane does not work on the production lane, and the other way round. The key itself is an opaque te_ value: it does not say which lane it is for. Safety comes from the lane in the file name, the lane you name in the command, the check te makes after connecting, and the platform refusing a key it does not know.
Choose how to connect
| Connect this machine (recommended) | Create a key for CI or another machine | |
|---|---|---|
| Where the key travels | Straight from the platform to a private file on this computer | Through your browser, once, for you to store |
| You copy it | No | Yes, once |
| Needs a browser on this computer | Yes (or on any computer that can show the code) | No |
| Use it for | Your own computer with Claude or Codex | CI jobs and servers with no browser |
Hosted assistants (for example connectors inside a chat website) are not supported yet for this purpose. They use a different sign-in that is still being rolled out. Use a local assistant as described here.
Connect this machine
You need the te command-line tool (install and sign-in details) and an application you can manage.
- Find your application's slug (its short name in the console) and decide which lane you are connecting to.
- Run this in a terminal on the computer where the assistant runs:
te login --app <your-app-slug> --lane lab --key-fileUse --lane production or --lane staging for those deployments. The command prints a short user code and the console address. The code is shown on purpose: you will compare it with the console screen. It is not a secret on its own, but approve only a code you just saw in your own terminal.
Open the address (te opens it for you unless you pass
--no-browser). Sign in if asked. The console shows who asked (address, client, time) and which application and lane the command asked for. Check the code matches your terminal, then choose:- a preset (MCP session is the default),
- the environments (Development is the default; Staging and Production each need your explicit confirmation).
The key lasts 7 days unless you choose otherwise when you create keys by hand. Nothing in the address selects the application, preset or environments for you.
Approve the connection, or deny it. Denying is just as available.
Back in the terminal,
tereceives the key, asks the platform who the key is and checks it is for the organization and application you approved. Only then does it write the key to a file. It prints the file path, what the key can do and when it expires. It never prints the key.
The file is te-api-key.<lane> in te's configuration folder unless you give a path. te creates a missing folder private to your account (mode 700) and refuses an existing folder that other users can write to; it does not change an existing folder's permissions. The key file itself is private from its first byte (on Windows, te restricts the file to your account and checks that before the key is written). Where the file system has no hard links, te installs the file by renaming it into place. te never overwrites an existing key file: it tells you the path and asks for --replace. After the key arrives, te checks it against the application you asked for. The application name is checked against what you typed; --app-id and --org-id are the only checks that do not rely on the platform's own answer, so pin them when you know them. A key approved for a whole organization rather than for the one application is not saved.
Point your assistant at the file
Give the assistant's MCP server the path, not the key.
| Lane | Variable for the MCP server |
|---|---|
| production | TE_API_KEY_FILE |
| staging | TE_API_KEY_FILE_STAGING |
| lab | TE_API_KEY_FILE_LAB |
For example, in a Claude Code or Codex MCP server entry, set the variable to the absolute path of the file in the server's env block. The details of the server, its tools and the SDK helper (get_key_context, get_sdk_bootstrap) are in the MCP server's README. The assistant lists only the tools your key may use. Hiding a tool is a convenience; the platform checks the key on every call.
A starter prompt you can paste
Use the TenancyEngine MCP server to inspect my application. First call
get_key_contextand tell me which application, lane, environments and permissions this connection has. Then callget_sdk_bootstrapand follow it. Do not ask me for keys, do not print any key, and do not write a key into any file. If a tool says a permission is missing, tell me which one and stop.
Create a key for CI or another machine
In the console, open the application, then its API keys, choose a preset, limit the environments, choose an expiry and create the key. The value is shown once. Store it straight into your secret store or a private file named for the lane (for example te-api-key.lab), in a folder only your account can use. Do not put it in chat, an issue, a mailbox, a screenshot, shell history or your repository. A lab key must never sit in a production file, or the reverse.
What the connection can and cannot do
- It can do only what its scopes allow, within the application and environments it is limited to, and never more than the person who approved it may do.
- It cannot spend money, change prices, publish to production, change DNS, create other keys or delegate access on its own. These stay with you in the console.
- Asking for an application or organization that is not the key's returns "not found". That is deliberate and does not tell the caller whether the other one exists.
Revoke, expiry and rotation
- Revoke from the application's key list. The next request with that key is refused.
- Expiry is a date. A key with no expiry stays valid until you revoke it and is flagged in the key list and the audit view. Prefer a date.
- Rotation by you, in the console, can keep the old key working for a grace period you choose (none, 15 minutes, 1 hour or 24 hours); the old value is never shown again. A key may renew itself only if you allowed it when approving and your organization and application policy permit it. The key list shows that state read-only.
- If the person who created a key loses the access it was built on, the key is marked Needs review in the key list. Filter the list by Needs review, No expiry, Production enabled or Connection not confirmed to find keys that need a decision.
When something goes wrong
| What you see | What it means | What to do |
|---|---|---|
401 or "did not accept this key" | The key is expired, revoked, mistyped or belongs to another lane | Check the lane in the command and the file name. If the key is revoked or expired, connect again |
402 | The action is not part of your plan | Check the plan in the console |
403 with a permission name | The key lacks that permission | Connect again with a preset that includes it, or ask an organization admin |
404 | The application or item is not one this key can reach | Check the application slug and the lane |
429 | Too many requests | Wait a minute and retry |
| "This connection does not match what you asked for" | The approved application or organization is not the one named in the command | Nothing was saved. Revoke the connection it names and connect again with the right application |
| "A key file already exists" | te does not overwrite keys | Choose another path, or use --replace |
Recovery: revoke and reconnect
The approval code works once, and the platform never hands the same key out twice. So if the terminal stops before the key is saved (a crash, a lost connection, a full disk), the connection exists on the platform but you hold no key. In the application's key list it shows as Connection not confirmed, for as long as the key exists. Select Revoke and reconnect, or revoke it and run the command again. Nothing is deleted from your application and no administrator credential is ever used as a fallback.
The same applies to a lost or leaked key: revoke it, then connect again.
What is out of scope here
Hosted assistants and third-party clients that sign in with a metadata document are a separate, not yet enabled track. Production changes that need your decision (money, publishing, security settings) are made by you in the console.