Build with / MCP or CLI
Codex
Connect AgentServe to Codex as an MCP server or through the CLI, so it can deploy what it builds and give you a claim link.
Codex can use AgentServe as an MCP server or run the agentserve CLI in its shell. Either way, it can
deploy a project, read its logs when something breaks, and hand you a claim link, all from the same session.
What you get#
- Five tools:
deploy_stack,stack_status,get_logs,extend_ttlanddestroy_stack. Each takes the project directory aspath. - Or the
agentserveCLI, if you'd rather the agent run shell commands:deploy,status,logs,extendanddestroy. - Multi-service stacks from an
agentserve.yaml, with URLs wired between services. - Redeploys to the same URLs. The stack id and token are kept in
.agentserve/stack.jsonin the project, shared with the CLI.
Set up with MCP#
You need uv. The MCP server runs on your machine over stdio, because it
reads and packs your project directory; it deploys to https://agentserve.sh.
Add the server to config.toml#
[mcp_servers.agentserve] command = "uvx" args = ["--from", "agentserve[mcp]", "agentserve-mcp"] # deploy_stack waits for the build; give it room tool_timeout_sec = 600uvxfetches the package on first start.Check it#
Start
codexand run/mcp.agentserveshould be listed with its five tools.Tell Codex the rules (optional)#
The tool descriptions cover the basics. For the manifest format,
$DATA_DIRand what to tell you after a deploy, add the AgentServe skill to the project'sAGENTS.md:curl -s https://agentserve.sh/skill.md >> AGENTS.md
Set up with the CLI#
Codex runs shell commands natively, so the agentserve CLI works without any MCP config. The one
thing to sort out is network access, since deploy uploads to AgentServe.
Install the CLI#
Put
agentserveon yourPATH, and check it installed:uv tool install agentserve agentserve --helpLet commands reach AgentServe#
Codex's default sandbox blocks network access, so
agentserve deploywould fail to connect. Allow it in the sandbox, or approve the command when Codex asks to run it outside:[sandbox_workspace_write] network_access = trueCodex leaves variables with
KEY,SECRETorTOKENin the name out of commands by default, so anAGENTSERVE_API_KEYin your shell won't reach the CLI. To deploy into your account, pass it explicitly:[shell_environment_policy] set = { AGENTSERVE_API_KEY = "as_live_…" }Tell Codex the rules#
Append the skill to the project's
AGENTS.md, as in step 3 above. Its examples are CLI commands, so Codex knows what to run.
The CLI and the MCP server share .agentserve/stack.json, so you can set up both and mix them: a stack
deployed with one is redeployed by the other, at the same URLs. Every command is in the CLI
reference.
A first prompt to try#
Build a tiny link shortener: a FastAPI service that stores links in SQLite under $DATA_DIR
and redirects /<code> to the target, plus a static page with a form. Deploy it with the
agentserve tools, passing this project's absolute path, and give me the URLs and the
claim link.
Codex should write an agentserve.yaml with two services, call deploy_stack, and reply with
the URLs and the claim link. If the build fails, it should call get_logs with build set,
fix the problem and deploy again.
Using the CLI? Ask for it "with the agentserve CLI"; Codex runs agentserve deploy and reads the URLs and
claim link from the output.
How the claim link reaches you#
deploy_stack returns a claim_url, and Codex should give it to you along with the expiry
time. Anonymous stacks run for 1 hour. Open the link, sign up or sign in, and the stack becomes yours at the same URLs,
with its data. If it already expired, claiming restores it from the snapshot. See Claiming.
With the CLI, agentserve deploy prints the claim URL with the expiry, and agentserve status
shows it again.
Missed it? It's saved as claim_url in .agentserve/stack.json in the project.
To skip the claim step entirely, add your key to the MCP server's environment in config.toml, and
deploys go straight into your account with no clock:
env = { AGENTSERVE_API_KEY = "as_live_…" }
Troubleshooting#
- The server doesn't start. Run the command by hand:
uvx --from 'agentserve[mcp]' agentserve-mcp. Ifuvxisn't found, setcommandto its absolute path (which uvx). - Deploys time out but show up later. The build kept going on AgentServe. Raise
tool_timeout_sec, then ask Codex to callstack_status. If no stack got linked, deploy again. - The wrong directory got deployed, or "no stack linked to …". A relative
pathis resolved from wherever the MCP server was started, which may not be your project. Codex needs to pass the project's absolute path. - Connection errors. Commands can't reach
https://agentserve.sh. With the CLI, checknetwork_accessabove; otherwise check your network or proxy settings. - Result has
deploy_error. The redeploy failed and the previous version is still serving. Logs first, then a fix.
More: Connect your agent, MCP tools, Manifest.