AI agents (MCP)

Connect Claude Code, Cursor or any MCP client to Hangar so your AI agent can deploy, read build and runtime logs, metrics and traces, and change settings.

Updated

Hangar has an MCP server, so an AI agent working on your code can also ship it. From Claude Code, Cursor, VS Code or any client that speaks the Model Context Protocol, the agent can find the service your repository deploys to, deploy it, follow the build, read the logs when something fails, and check metrics and traces once it is live.

The server is hosted by Hangar: there is nothing to install.

Connect your agent

  1. Add Hangar to your client. For Claude Code:
claude mcp add --transport http --scope user hangar https://tryhangar.io/api/mcp

For Cursor (~/.cursor/mcp.json), VS Code (.vscode/mcp.json) and other clients, Settings → AI agents has the configuration to paste. Any client needs only the URL https://tryhangar.io/api/mcp and the Streamable HTTP transport.

  1. Sign in. In Claude Code, run /mcp, pick hangar and authenticate; other clients ask on their own the first time. Your browser opens Hangar, you choose the organization the agent will act in, and you allow it.

  2. In your project, ask: "Deploy this to Hangar and check the logs for errors."

Connecting an agent needs the same role as creating API keys: owner or admin, or a custom role with API access.

Without a browser

On a CI runner or a machine where nobody can sign in, use an API key instead: Settings → AI agents → No browser? Use an API key instead creates one and gives the command with the key in it, sent as Authorization: Bearer <your-api-key>.

What the agent can do

AreaTools
Find thingswhoami, list_projects, get_service, find_services_by_repo, list_regions
Deploydeploy_service, wait_for_deployment, list_deployments, get_deployment, get_deployment_logs, cancel_deployment, rollback_service
Runstart_service, stop_service, restart_service
Observeget_service_logs, get_service_metrics, get_traffic, list_requests, get_trace
Configureget_env, set_env, add_domain, remove_domain, get_database_connection, connect_database
Createcreate_project, create_environment, create_app_from_github, create_database
Local codeprepare_upload

The agent finds the service for the code in front of it with find_services_by_repo, passing the repository's Git remote. A service built from GitHub, GitLab, Bitbucket, Gitea or a Git URL is matched by its repository.

Deploying

A service deploys from its branch, so the agent commits and pushes before calling deploy_service. If the service deploys on every push, the push already started a deployment and the agent follows that one instead. wait_for_deployment returns once the build finishes, with the end of the build log when it failed.

rollback_service puts an application back on the image of an earlier deployment without rebuilding, when rollbacks are enabled on it.

Observing

get_service_logs reads the service's log history with a text search and a minimum level, so "errors in the last hour" is one call. list_requests lists the requests the service handled, with status and duration, and get_trace opens one of them as a tree of spans across your services, with exception messages, database statements and the log lines written under each span. See Observability for how traces are collected.

Security

  • The agent acts as you. Every call runs with your role and project permissions in the organization you chose for it, and appears in the audit log as yours, marked with the agent and the tool it used.
  • You approve every agent. Hangar always shows who is asking and where it will send you back before an agent gets access. Its access lasts an hour at a time and renews while you keep using it, for up to 30 days without use.
  • Secrets stay hidden by default. get_env and get_database_connection mask values unless the agent asks to reveal them. connect_database writes a database's connection URL, password included, into an app's variables on Hangar's side, so the password never passes through the conversation.
  • Nothing is deleted. The agent can stop services and remove domains, but it cannot delete services, databases or volumes.
  • Agents are rate limited. An agent can make 120 calls a minute, and a person 300 across all their agents. Past that, Hangar answers with HTTP 429 and how many seconds to wait.
  • Upload links are short-lived. A link from prepare_upload deploys one application, once, within 10 minutes.

Disconnect an agent in Settings → AI agents, or revoke its key in Profile → API/CLI Keys.

Frequently asked questions

Does my AI agent get more access than I have on Hangar?
No. When you connect an agent you sign in to Hangar and pick one organization, and every action runs as you there, with your role and project permissions. Disconnecting it in Settings, AI agents cuts its access right away.
Do I need to install anything to use Hangar with Claude Code?
No. Hangar's MCP server is hosted at your dashboard's address under /api/mcp. You add it to your agent with one command, and the agent opens your browser to sign in to Hangar.
Can the agent deploy code that is not pushed to Git?
Yes, for an application that is not connected to a repository. The agent asks Hangar for an upload link that works once, for 10 minutes, zips the working tree with git archive and sends it. Uploading to an app connected to a repository switches it to uploads, so the agent asks you first.

Deploy your app on Hangar

Connect a repository and it is live in minutes.

Start deploying