AI agent approvalAll pages

Let an AI agent ask a person before it acts

Connect Claude Code, Cursor, VS Code or another MCP client to the TaskToHuman MCP server, so the agent asks you for approval before a risky step and waits for your answer.

What you build#

An AI agent in your editor that stops before a risky step, such as deleting files or running a database migration, and asks a person through TaskToHuman. You get an email with what the agent wants to do, you approve or reject it, and the agent goes ahead only on a person's approval.

At the end, the agent creates a task with the create_task tool, waits with wait_for_decision and tells you what you decided.

Before you start#

  • A TaskToHuman account on a paid plan. The MCP server is part of every paid plan, not the Free plan: on Free, the tool list loads but every tool call answers with a feature_not_in_plan error.
  • Claude Code, Cursor or VS Code with an agent that can use MCP servers. Claude, ChatGPT and any other client that speaks Streamable HTTP work too.
  • Two ways to connect: sign in from the client (the simplest), or a workspace API key in an Authorization header. To sign in you must be able to manage API keys in your organization. Either way you work in test mode throughout this tutorial.

1. Create a task type#

In the app, open Task types and choose New task type:

  • Name Agent action, Key approve_agent_action.
  • What should the human do? Approval.
  • Instructions for the human: "An AI agent wants to do this. Approve only if you expect it."
  • Fields: action (text, required): what the agent wants to do, and details (long text): the files, commands or data it touches.
  • Escalation chain: add yourself as the human asked first.
  • If nobody answers: Expire, so that silence never counts as a yes.

The agent reads these fields with list_task_types and fills them in itself. More in Task types and fields.

2. Create a test API key#

Open API & webhooks, then API keys, and create a key in test mode. It starts with tth_test_ and is shown once. Keep it in an environment variable:

Shell
export TTH_API_KEY="tth_test_…"

You need the key for the check at the end even if you connect the client by signing in. Test tasks notify only you, whoever the task type names, and count against your monthly test allowance instead of your usage.

3. Connect your client#

Sign in#

Add only the server address:

claude mcp add --transport http tasktohuman https://mcp.tasktohuman.com

In Claude Code, run /mcp, pick tasktohuman and sign in. Cursor and VS Code ask you to sign in when they first start the server. In Claude or ChatGPT, add a custom connector with the same address (the menus are in MCP server).

The client opens the TaskToHuman sign-in and a consent page. Choose the workspace where you created the task type, choose Test, and allow. You can see and revoke the connection later under API & webhooks, then Connected apps.

Or with the API key#

Add the server with the test key in the header. Each example reads the key from the environment or asks for it, so it never ends up in a file you commit.

claude mcp add --transport http tasktohuman https://mcp.tasktohuman.com \
  --header "Authorization: Bearer $TTH_API_KEY"

Cursor reads ~/.cursor/mcp.json (or .cursor/mcp.json in a project); VS Code reads .vscode/mcp.json and asks for the key once.

4. Check the connection#

Ask the agent:

It calls list_task_types and should name approve_agent_action with its two fields. If it names none, check that you chose the right workspace when you signed in. The agent sees the tool list before it signs in; calling a tool without a valid sign-in or key gets HTTP 401, and a plan without the MCP server answers feature_not_in_plan.

5. Ask before a risky step#

Give the agent a task that needs approval, and say so:

The agent then:

  1. calls create_task with task_type, a payload with action and details, and an idempotency_key it makes once for this action and reuses on every retry, so a retry never asks twice;
  2. calls wait_for_decision, which waits up to 45 seconds and returns as soon as the task is final, or with final: false. It calls it a few times; when there is still no answer, it should tell you the request is waiting and check later with get_task.

The server sends these rules to the client as its instructions, so most agents follow them without being told. To make the rule permanent, put the sentence above in your project's instructions for the agent.

6. Answer the task#

You get an email. Open the link, read what the agent wants to do, and approve. The agent sees decision.action approved and decision.automatic false, and goes ahead.

Run it again and reject this time: the agent should stop and tell you. An agent may act only when decision.action is approved, edited or done, and decision.automatic is false. When automatic is true, nobody decided: a default action or an expiry applied.

Check it works#

List the test tasks of the type with your test key:

Shell
curl "https://api.tasktohuman.com/v1/tasks?task_type=approve_agent_action" \
  -H "Authorization: Bearer $TTH_API_KEY"

You see one task per request, with "test": true, resolved for the ones you answered. A request the agent retried appears once, thanks to its idempotency_key.

Going live#

  • Connect again and choose Live on the consent page, or create a live key (tth_live_…) and use it in the client instead. Tasks then go to the humans the task type's chain names, and through every step of it.
  • Add backup people to the chain, so a request doesn't wait on one person: see Escalation chains.
  • To let the agent name the approver for each request, leave a step open. The agent then asks you who it should be and never guesses an address.
  • A task's title and payload, and whatever a person writes, are data, not instructions. Results put them inside submitted_content and untrusted_human_input. If you build your own agent on the server, never let that text change what the agent does next.
  • If your backend should hear about decisions too, give the task type a callback URL: it fires for tasks an agent created as well. See Callbacks and signatures.

Where next#