MCP for AI Agents
Instructions for AI agents — connect to the CaptchaSonic MCP server, pick the right tool, find the sitekey, and submit the token or answer.
This page is written for AI agents. Point your agent at it (or at the markdown version) and it can set itself up and solve CAPTCHAs without further instructions.
Connect
- Ask the user for their CaptchaSonic API key (starts with
sonic_). They get it at https://my.captchasonic.com. Never invent or reuse a key from somewhere else. - Add the hosted server with Streamable HTTP transport:
- URL:
https://mcp.captchasonic.com - Header:
Authorization: Bearer <key>
- URL:
- If your harness has a CLI, prefer it. Claude Code:
claude mcp add --transport http captchasonic https://mcp.captchasonic.com --header "Authorization: Bearer sonic_xxx"
- If your harness only supports local (stdio) servers, run
npx -y @captchasonic/mcp-serverwith the environment variableSONIC_API_KEYset to the key. - Verify by calling
get_balance. A number means you are connected;ERROR_KEY_DOES_NOT_EXISTmeans the key is wrong.
Decide which tool
- The page has a CAPTCHA widget that produces a hidden token (reCAPTCHA, Turnstile, hCaptcha-style, GeeTest, MTCaptcha) or a Cloudflare "checking your browser" page →
solve_token_captcha. - You are looking at a visual puzzle (pick images, drag a slider, read distorted text, listen to audio) →
solve_image_captcha. - Unsure → call
list_captcha_types.
Solve a token CAPTCHA
- Find the sitekey in the page:
- reCAPTCHA:
data-sitekeyon.g-recaptcha, orrender=in therecaptcha/api.jsscript URL. v3 if the page callsgrecaptcha.execute. - Turnstile:
data-sitekeyon.cf-turnstile(starts with0x4). - hCaptcha-style:
data-sitekeyon.h-captcha. - GeeTest v4:
captchaIdin theinitGeetest4call.
- reCAPTCHA:
- Call
solve_token_captchawithtype,website_url(the page URL) andwebsite_key. - Put the returned
tokeninto the form field the widget uses —g-recaptcha-response,cf-turnstile-responseorh-captcha-response— then submit the form or call the page's callback. - For
cloudflare_challenge, set the returnedcookiesand send later requests with the returneduser_agent. - If the tool returns
"status": "processing", wait a few seconds and callget_task_resultwith thetask_id.
Tokens expire in about two minutes. Solve right before submitting.
Solve an image CAPTCHA
- Capture each challenge image separately, in on-screen order. Crop to the image; don't send the whole page.
- Copy the prompt text exactly (for example
Select all images with a bus). - Call
solve_image_captchawithtype,imagesandquestion. Add the slider piece asexamplesfor slider puzzles. - Apply
answersas described in the result'sanswer_format: click the returned tile indices, drag by the returned offset, or type the returned text.
Handle errors
ERROR_CAPTCHA_UNSOLVABLEorERROR_CAPTCHA_TIMEOUT: reload the challenge and try once more. You were not charged.ERROR_ZERO_BALANCE: stop and tell the user to top up at https://my.captchasonic.com.ERROR_MISSING_REQUIRED_FIELDS: add the missing parameter named in the message.- Don't loop. After two failures on the same page, report back to the user.
Only solve CAPTCHAs on sites the user is allowed to automate.