NewFacial identity verification

Verifying Brazilian Identities from AI Agents with MCP

How AI agents can verify a Brazilian CPF through an MCP server: setup in Claude and Cursor, the available tools, credits, and guardrails for KYC use.

Lucas Vieira
Lucas Vieira
··7 min read
Verifying Brazilian Identities from AI Agents with MCP

Introduction

An AI agent can verify a Brazilian CPF (Brazil's individual taxpayer ID) by connecting to an MCP server that exposes CPF lookups as tools. With the CPFHub.io MCP server, the agent calls lookup_cpf to get the holder's name, gender and date of birth, or lookup_cpf_realtime to get the registration status at the Receita Federal, without anyone writing HTTP code.

This guide shows how to connect the server, what each tool returns, and the guardrails that keep an agent-driven KYC step safe.


What MCP is, in one paragraph

The Model Context Protocol (MCP) is an open protocol that lets AI applications discover and call external tools in a standard way. A client such as Claude or Cursor connects to an MCP server, reads the list of tools and their parameters, and calls them when the conversation or task needs one. The CPFHub.io server uses the protocol's Streamable HTTP transport, so there is nothing to install locally.


Connecting the CPFHub.io MCP server

The server lives at https://api.cpfhub.io/mcp and authenticates with the same API key as the REST API, sent in the x-api-key header. Most clients accept a block like this:

{
  "mcpServers": {
    "cpfhub": {
      "url": "https://api.cpfhub.io/mcp",
      "headers": { "x-api-key": "YOUR_API_KEY" }
    }
  }
}
  • Claude Code: add the server as described in the Claude Code MCP documentation, using the URL and header above.
  • Cursor: put the same block in .cursor/mcp.json, as described in the Cursor MCP documentation.
  • Your own agent: any MCP client library that supports Streamable HTTP can connect with the same URL and header.

Keep the key out of shared repositories. If the config file is committed, read the key from an environment variable where your client supports it. Full setup details are in the MCP documentation.


The tools the agent gets

ToolParametersWhat it returnsCredits
lookup_cpfcpf (with or without mask)Name, gender and date of birth, the same payload as GET /cpf/{cpf}Only when the CPF is found
lookup_cpf_realtimecpf, birth_dateName, date of birth, registration status, year of death when there is one, and the proof linkOnly on success
lookup_cnpjcnpjCompany name, registration status, address, CNAEs and partnersOnly when the CNPJ is found
bulk_lookup_cpf / bulk_lookup_cnpjlist of up to 10,000 numbersA jobId for the batchOnly for numbers found
get_bulk_jobjobIdStatus and results of a batchNever
create_kyc_linkoptional externalId, cpf, redirectUrlAn Identity Verification link to send to the personPer completed verification
get_kyc_linklink idLink status and the decisionNever
get_quota_infononePlan name and remaining creditsNever

The tools use the same services, credit rules and per-minute limits as the REST API. A CPF that is not found does not use a credit. In the Real-Time Lookup, a date of birth that does not match comes back with the code birth_date_mismatch, and a CPF that the Receita Federal does not know comes back with cpf_not_found, both without a charge.

Errors come back as a normal tool result flagged as an error, with a message the agent can read. When the per-minute limit is reached, the result includes retry_after in seconds, so a well-behaved agent waits instead of hammering the server.

The full list, with parameters and examples, is in the MCP documentation.


What an agent-driven check looks like

A typical use is a back-office assistant that reviews a pending signup. The operator asks: "Check whether the CPF 000.000.000-00 matches Fulano de Tal, born 15/06/1990." The agent:

  1. Calls lookup_cpf with the CPF.
  2. Compares the returned nameUpper and birthDate with the data in the request, after normalizing accents and spacing.
  3. If the case needs it, calls lookup_cpf_realtime with the CPF and date of birth to get the registration status at the Receita Federal (Brazil's federal tax authority).
  4. Writes a short summary for the operator: match or mismatch, status, and the proof link for the record.

The same pattern works in a support copilot, a compliance review queue, or an internal tool that checks a merchant's representative before approval.


Guardrails for KYC with agents

An agent with a lookup tool is still processing personal data. A few rules keep it safe and useful:

  • One identity per request, with a purpose. Use the tools to verify a customer or applicant who is in your flow. Do not let an agent look up lists of people it found elsewhere.
  • Keep a human on the decision. Let the agent gather and compare data. Let your policy or an operator approve, reject or escalate, and log who decided.
  • Do not paste lookups into long-lived chat history. Store the outcome in your own system, with the retention you define.
  • Restrict who can use the key. Give the agent a key tied to your account and monitor usage with get_quota_info or the dashboard.
  • State the legal basis. Under the LGPD (Brazil's data protection law), fraud prevention and legal obligations are common bases for identity checks. Confirm your setup with Brazilian counsel.

MCP or REST?

You are buildingUse
A signup or checkout flow in your productREST API from your backend
A back-office or support assistantMCP
A coding agent that writes your integrationMCP for exploring, REST in the final code
Batch checks of your own customer baseREST bulk endpoints (or the bulk tools, for small jobs)

For the REST path, the Node.js guide and the Python guide show complete examples. The same request from the command line:

curl --max-time 10 \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Accept: application/json" \
  https://api.cpfhub.io/cpf/00000000000

Frequently asked questions

Which AI clients work with the CPFHub.io MCP server?

Any client that supports MCP over Streamable HTTP with custom headers, including Claude, Cursor and Windsurf. The connection is the same: the server URL plus your API key in the x-api-key header.

Does an MCP lookup cost the same as a REST lookup?

Yes. The tools use the same services and credit rules as the REST API, from the same balance. A CPF that is not found does not use a credit, and get_quota_info is free. See pricing.

Can the agent check the CPF registration status?

Yes, with lookup_cpf_realtime, which needs the CPF and the holder's date of birth. It returns the registration status at the Receita Federal, the year of death when there is one, and the proof link.

Can an agent run document and selfie verification through MCP?

Partly. The agent can create the link with create_kyc_link and read the decision with get_kyc_link, but the person always takes the selfie and photographs the document on their own device, through the hosted flow.


Read also

Conclusion

MCP lets AI agents verify Brazilian identities with the same data and rules as the REST API: lookup_cpf for name, gender and date of birth, lookup_cpf_realtime for the registration status, plus tools for CNPJ, batches and Identity Verification links. Connect the server with one URL and your API key, keep a human on the decision, and log what the agent checked.

Connect your agent with 50 free credits and no credit card at cpfhub.io.

CPFHub.io

Ready to integrate the API?

50 free credits to test now. No credit card. Instant access to the documentation.

WhatsApp