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
| Tool | Parameters | What it returns | Credits |
|---|---|---|---|
lookup_cpf | cpf (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_realtime | cpf, birth_date | Name, date of birth, registration status, year of death when there is one, and the proof link | Only on success |
lookup_cnpj | cnpj | Company name, registration status, address, CNAEs and partners | Only when the CNPJ is found |
bulk_lookup_cpf / bulk_lookup_cnpj | list of up to 10,000 numbers | A jobId for the batch | Only for numbers found |
get_bulk_job | jobId | Status and results of a batch | Never |
create_kyc_link | optional externalId, cpf, redirectUrl | An Identity Verification link to send to the person | Per completed verification |
get_kyc_link | link id | Link status and the decision | Never |
get_quota_info | none | Plan name and remaining credits | Never |
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:
- Calls
lookup_cpfwith the CPF. - Compares the returned
nameUpperandbirthDatewith the data in the request, after normalizing accents and spacing. - If the case needs it, calls
lookup_cpf_realtimewith the CPF and date of birth to get the registration status at the Receita Federal (Brazil's federal tax authority). - 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_infoor 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 building | Use |
|---|---|
| A signup or checkout flow in your product | REST API from your backend |
| A back-office or support assistant | MCP |
| A coding agent that writes your integration | MCP for exploring, REST in the final code |
| Batch checks of your own customer base | REST 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
- Brazil Identity Verification API: What Data You Can Get from a CPF
- How to Use a CPF Lookup API in Node.js
- How to Use a CPF Lookup API in Python
- Onboarding Brazilian Customers: A Fraud Prevention Checklist
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.




