Use Legion with AI agents
Let an AI agent find GPU offers, rent and manage GPUs, and check spend on Legion, with the Legion skill, the MCP server, or both.
After this page you know what Legion offers an AI agent, which of the two ways to connect one to use, how to connect Claude by signing in, and how to get an agent renting its first GPU, with you approving every step that costs money.
Legion gives an agent two things:
The Legion skill is a folder of instructions in the open Agent Skills format. It teaches an agent how Legion works: how to find an offer, rent it, connect over SSH, expose a service, read your spend and clean up. It also gives the agent its safety rules: ask before it spends, expose or deletes.
The MCP server gives an agent Legion as tools:
list_,catalog list_,offers create_,rental get_and the rest. The tools use the same API as the app. Claude connects by signing in to Legion, and other clients and scripts use an API key. Its address is:billing_ account
https://api.legion.ambient.xyz/v1/mcpWhich one to use
| You have | Use |
|---|---|
| An agent that supports MCP servers, such as Claude, Cursor, VS Code or Codex | The MCP server. Add the skill too, for the workflow and the safety rules. |
| An agent with a shell and network access but no MCP support | The skill alone. It uses the Legion API with curl. |
| A sandbox with no network access from the agent's shell | The MCP server. The tools run on Legion's side. |
| Only a wish to try it | The MCP server, connected read-only with an API key. The agent can look but not change anything. |
The skill and the server work together. The server does the work and asks for confirmation on anything that costs money. The skill tells the agent how to plan the work and what to say to you.
Quick start
Connect Claude. In Claude, open Customize, then Connectors, then Add custom connector, and enter the server's address above. Click Add, then Connect, sign in to Legion in your browser, choose Agent or Agent + hosts, and approve. In Claude Code, run
claude mcp add --transport http legion https:/, then/ api. legion. ambient. xyz/ v1/ mcp /. The steps for each plan are in Connect Claude. You can install the skill too.mcp Ask. Start with something that only reads, such as:
Which GPUs can I rent on Legion right now, and how much credit do I have?When you are ready, ask for a rental. The agent shows you the price and what it is about to do, and waits for your yes. See Examples.
Use an API key instead
An API key is for scripts, CI and clients without OAuth, such as Cursor, VS Code and Codex.
Create a key for the agent. In the Legion app, open Settings, then API keys, and create a key named for the agent: choose Agent access and an expiry. Use a key from a member of your organization rather than an owner if you can. See Safety.
Connect the agent. Connect the MCP server for your client, and install the skill. Put the key in an environment variable, never in the chat.
Then ask, as above.
What an agent can do
An agent can search the market, rent a GPU, wait for it to run and give you the SSH command, read your services, and, with a Full access API key, expose a port of a rental or serve an autoscaled model as a service, with keys, show your balance and what each rental has cost, and stop, start or delete rentals. Tools reference lists every tool.
An agent cannot add credit, change payouts, create API keys, invite people, enroll a host or change a host's blocked networks. Those stay in the app. It can manage your existing hosts only if you choose Agent + hosts when you connect it, or give it a key with provider tools.
Go further
Install the skill: for Claude Code, Claude, and other agents that read Agent Skills.
Connect the MCP server: sign in with Claude, or copy-paste setup with a key for each client.
Tools reference: every tool, what it changes, and which ask first.
Safety: what the agent asks before, and how to limit the damage of a mistake.
Examples: five conversations and the tool calls behind them.
The legion CLI: an agent with a shell can run
legionwith-o json --yes. See Scripting and automation.llms.txt: the docs index for agents.