Skip to content

AI assistants

Call the Qelka MCP server from the Claude API

Give Claude the Qelka validation tools in a Messages API request with the MCP connector: server definition, toolset, response blocks, errors and costs.

Updated 2026-11-26

This recipe gives Claude the Qelka checks inside a Messages API request. You declare the Qelka MCP server in the request, and Anthropic's MCP connector connects to it, lists the tools and runs the calls Claude chooses: verify an email, validate a phone number, look up an IP. Your code sends one request and gets back the tool calls, their results and Claude's answer.

There is nothing to install on the Qelka side. The server at https://mcp.qelka.com/mcp speaks Streamable HTTP, is stateless, and authenticates with your API key as a bearer token. To use the server in Claude.ai, Claude Code or Claude Desktop instead of the API, follow the Claude setup page.

What you need

  • An Anthropic API key, read from ANTHROPIC_API_KEY by the SDK, and a current release of the Anthropic SDK: @anthropic-ai/sdk for Node.js or anthropic for Python.
  • Access to the MCP connector, which is in beta behind the mcp-client-2025-11-20 header. Anthropic lists it for the Claude API, Claude Platform on AWS and Microsoft Foundry, and not for Amazon Bedrock or Google Vertex AI, as far as we know: check their docs.
  • A Qelka API key in the QELKA_API_KEY environment variable of your server. Start with a sk_test_ key: tools return simulated, fixed answers and never spend credits. See Test mode.
  • Preferably a restricted key, since it travels in each request to Anthropic: tick the endpoints Claude should call, plus account for get_account. See restricted keys.

Both keys stay on your server. Never send them to a browser.

Steps

1. Send a request with the server and its toolset

A request needs two parameters together: mcp_servers describes how to reach the server, and tools must contain an mcp_toolset entry that names it. Anthropic rejects a server that no toolset references.

import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({ timeout: 300_000 })

try {
  const response = await client.beta.messages.create({
    betas: ['mcp-client-2025-11-20'],
    model: 'claude-opus-5-5',
    max_tokens: 16000,
    mcp_servers: [
      {
        type: 'url',
        url: 'https://mcp.qelka.com/mcp',
        name: 'qelka',
        authorization_token: process.env.QELKA_API_KEY,
      },
    ],
    tools: [{ type: 'mcp_toolset', mcp_server_name: 'qelka' }],
    messages: [
      {
        role: 'user',
        content: 'Check jane@example.com and +1 415 555 0123. Which one should I not contact, and why?',
      },
    ],
  })

  for (const block of response.content) {
    if (block.type === 'mcp_tool_use') console.log(`called ${block.name}`, block.input)
    if (block.type === 'mcp_tool_result' && block.is_error) console.log('tool refused', block.content)
    if (block.type === 'text') console.log(block.text)
  }
} catch (error) {
  if (!(error instanceof Anthropic.APIError)) throw error
  console.log(`check skipped: Claude API ${error.status ?? 'unreachable'} ${error.message}`)
}
import os

import anthropic

client = anthropic.Anthropic(timeout=300.0)

try:
    response = client.beta.messages.create(
        betas=["mcp-client-2025-11-20"],
        model="claude-opus-5-5",
        max_tokens=16000,
        mcp_servers=[
            {
                "type": "url",
                "url": "https://mcp.qelka.com/mcp",
                "name": "qelka",
                "authorization_token": os.environ["QELKA_API_KEY"],
            }
        ],
        tools=[{"type": "mcp_toolset", "mcp_server_name": "qelka"}],
        messages=[
            {
                "role": "user",
                "content": "Check jane@example.com and +1 415 555 0123. Which one should I not contact, and why?",
            }
        ],
    )
except anthropic.APIError as error:
    print(f"check skipped: {type(error).__name__} {error.message}")
else:
    print("request", response._request_id)
    for block in response.content:
        if block.type == "mcp_tool_use":
            print("called", block.name, block.input)
        elif block.type == "mcp_tool_result" and block.is_error:
            print("tool refused", block.content)
        elif block.type == "text":
            print(block.text)
  • authorization_token is sent to the Qelka server as Authorization: Bearer followed by your key, which is the only authentication it accepts.
  • url must be the HTTPS address of the server, https://mcp.qelka.com/mcp, and name is your label for it: the toolset refers to it with mcp_server_name.
  • The client timeout bounds the whole request, tool calls included. Claude may call several tools before it answers, so give it room, and treat a timeout as "not checked".
  • Claude Opus 5.5 always thinks before answering, so the content can also hold thinking blocks: filter blocks by type, as the loop does.

2. Read the result blocks

The tool loop runs on Anthropic's side, and the response content records it:

Block Fields What to do with it
mcp_tool_use name, server_name, input Log which tool ran with which arguments, for cost tracking
mcp_tool_result tool_use_id, is_error, content content holds the tool's JSON result as text; when is_error is true, it holds the API's message, error type and HTTP status
text text Claude's answer, which you show or parse
thinking Claude's reasoning, which you can ignore

The JSON inside a successful mcp_tool_result is the same as the REST response: status and reason for an email, valid, e164 and line_type for a phone. If your code acts on results, read the tool results rather than the prose, and follow the meaning of each status:

Result What to do
Email undeliverable Do not send to it; show did_you_mean when there is one
Email risky Disposable, catch-all or full mailbox: flag it for review
Email unknown, or an error result Not conclusive: keep the contact and check again later
Phone invalid Ask for the number again
Phone unknown The number has no + and no country was given: say which country it is from
Phone valid Store e164 and use it for calls and messages

See the email reference and the phone reference for every field.

3. Allow only the tools you need

By default the toolset exposes the server's 12 tools. Each tool definition costs input tokens, so for a focused task, turn them all off and enable a few:

tools
[
  {
    "type": "mcp_toolset",
    "mcp_server_name": "qelka",
    "default_config": { "enabled": false },
    "configs": {
      "verify_email": { "enabled": true },
      "validate_phone": { "enabled": true },
      "get_account": { "enabled": true }
    }
  }
]

Anthropic warns but does not fail on a tool name in configs that the server does not have, so check the spelling against the MCP tool list.

4. Check the connection and the key mode

Send the same request with this message:

Prompt
What is my Qelka credit balance, and is this key in test or live mode?

Claude calls get_account, which is free, and answers with your plan, balance and key.mode. Do this once at startup in production: a service that runs with a sk_test_ key by mistake would trust simulated answers.

Credits and limits

Each tool call is one Qelka API request made with your key, billed, cached and rate limited like a REST call:

Tool Credits
verify_email 1
validate_phone 1 at basic, 3 at live
lookup_ip 1
get_account 0

The server tells Claude to prefer the fast email mode, which skips the mailbox check and answers quickly, and the basic phone level. Ask for "check that the mailbox exists" or "the current carrier" in your prompt when you need mode: "full" or level: "live". A request about a long list can trigger one tool call per item, so cap the list size in your code. For thousands of rows, use a bulk job instead.

Handle errors and rate limits

Two layers can fail, and neither should block your product: when the request throws or times out, treat every check as unchecked and retry later.

What happens Cause Fix
The SDK raises an error and nothing ran A Claude API problem: wrong Anthropic key, a missing beta header, a toolset that names no server, or a timeout Log the error class, status and Anthropic request id, then fail open
The request fails while connecting to the server The authorization_token is empty or not sk_live_... or sk_test_...: the server answers 401 Check that QELKA_API_KEY is set where your code runs
mcp_tool_result with is_error and invalid_api_key The key is well formed but revoked or mistyped Create a new key and redeploy
mcp_tool_result with forbidden The key is restricted and the tool's endpoint is not in its list Use a key that allows it, or turn the tool off in configs
mcp_tool_result with insufficient_credits Your balance cannot cover the call Add credits; nothing was billed
mcp_tool_result with rate_limited and "Retry after N seconds." A key allows 200 requests per 10 seconds Send fewer items per request, or wait and resend

Refused tool calls are never billed. See Errors and Rate limits.

Frequently asked questions

Do I need to run any MCP client code myself?
No. With the MCP connector, Anthropic's platform connects to the Qelka server, lists its tools and runs the calls Claude decides to make, all inside one Messages API request. Your code sends the request and reads the result blocks. If you need to run your own logic between tool calls, call the REST API from regular client tools instead.
Can I use this on Amazon Bedrock or Google Vertex AI?
Not as far as we know: Anthropic lists the MCP connector for the Claude API, Claude Platform on AWS and Microsoft Foundry, not for Amazon Bedrock or Vertex AI. Check Anthropic's documentation for the current list. On those platforms, call the Qelka REST API from a client tool.
Who pays for what?
Anthropic bills the tokens of the request, including the tool definitions and results Claude reads. Qelka bills each tool call at the price of the matching API call, and get_account is free. With a sk_test_ key, the tool calls return simulated answers and cost no credits.

More in AI assistants

All integrations

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time