Connect a coding agent on your laptop, such as Claude Code or Codex, to an instance. The agent reads and operates the instance through MCP tools, one for each operator API operation, such as overview, detail, and approve.
Prerequisites
Section titled “Prerequisites”- An instance that your laptop reaches over HTTPS, such as
https://usine.example.com. - An enrolled GitHub identity with role bindings on the projects that the agent works on.
- For the stdio form,
@usine/serverinstalled on the laptop, so that theusinecommand is available.
Procedure
Section titled “Procedure”-
Create a device token for the agent. Run:
Terminal window usine sign-in https://usine.example.comOpen the printed GitHub device page and enter the code. The CLI prints the token once; store it in a secret manager. To create the token from a browser instead, open Tokens and select Create token.
-
Narrow the token. Open Tokens in a browser session and select Edit scopes on the device entry:
- Keep only the scopes that the agent needs, such as Read and Operate on one project.
- Under Operations, list the operation IDs that the agent may call, separated by commas, such as
operator.overview, operator.detail, operator.approve. The Operator API reference lists every operation ID. - Select Save scopes.
A token that you create on Tokens takes the same fields, and also an optional expiry.
-
Add the instance to the client. For Claude Code, run:
Terminal window claude mcp add --transport http usine https://usine.example.com/api/mcp --header "Authorization: Bearer <token>"For Codex, add the server to
~/.codex/config.tomland setUSINE_TOKENto the token in the environment that starts Codex:[mcp_servers.usine]url = "https://usine.example.com/api/mcp"bearer_token_env_var = "USINE_TOKEN"To use stdio instead of HTTP, start
usine mcpas a local command that reads the token fromUSINE_TOKEN:Terminal window claude mcp add usine --env USINE_TOKEN=<token> -- usine mcp --origin https://usine.example.comcodex mcp add usine --env USINE_TOKEN=<token> -- usine mcp --origin https://usine.example.comOn the instance machine,
usine mcpwithout--origin, run in the instance folder, serves the running instance with the local admin token. That token has instance admin access.
Check the result
Section titled “Check the result”In Claude Code, run /mcp and open usine; in Codex, run /mcp. The list contains only the tools that the token’s scopes and operations permit. Ask the agent to read the overview of a project to confirm that the tools work.
How tool calls work
Section titled “How tool calls work”- Each tool call is an operator API request with the token. The instance checks the permission again, including the project in the path, and records the token’s member on approvals and other actions.
- A tool’s input is one object with the operation’s path parameters, query parameters, and
bodyfor a request body. - A result is the JSON response text. A result over 100 KB is cut at that size and followed by a note that names a narrower operation, such as
deskorprojectforoverview. - A refused request returns an error result with the HTTP status and the error body. A tool outside the token’s list is unknown to the server.
- The change stream,
GET /api/changes, has no tool. - The client reads the tool list when it connects. After you change the token’s scopes or operations, reconnect the server in the client.
- A session belongs to the token that opened it. It ends after one hour without a request, or when the token’s tool list changes; the client then starts a new session.
Revoke the device entry under Tokens to end the agent’s access.