# CNJ Datajud API MCP

> CNJ Datajud API provides direct access to Brazil's national judicial records, letting you query lawsuit details and procedural history from the official government database. You can retrieve full case metadata using a unique CNJ number, narrow results by specific legal categories or court offices, or run complex searches across date ranges and parties. It’s essential for legal professionals needing deep visibility into the Brazilian justice system without manual portal navigation.

## Overview
- **Category:** data-management
- **Price:** Free
- **Tags:** judicial-records, brazil-law, procedural-data, public-records, legal-tech, api-integration

## Description

This MCP connects your AI client directly to the Brazilian National Council of Justice (CNJ) Datajud Public API. You can pull detailed records on lawsuits, court movements, and procedural history that used to require navigating multiple government websites. It gives you a single point of access for deep legal data across various courts—TRFs, TJs, and more.

Instead of manually filling out forms or searching through dated portals, your agent executes complex queries using official parameters. Need to know the status of a specific case? Use its unique number. Want to check all cases related to a particular type of law or court office? Filter by those codes. If you need something really detailed, like finding processes that changed hands over the last month, you can run advanced searches.

When your AI client connects through Vinkius, it handles the connection and authentication so you just focus on the query. It’s how you get accurate legal data quickly for compliance checks, research analysis, or simply updating a client on a case status.

## Tools

### search_processes_advanced
Runs flexible, complex queries against the Datajud API by specifying various filtering parameters like dates or parties.

### search_processes_by_class_and_organ
Searches for processes that match a specific legal procedural class and court organ code simultaneously.

### search_process_by_number
Retrieves the full details of a specific lawsuit using only its unique CNJ case number.

## Prompt Examples

**Prompt:** 
```
Search for process number 50012345620234036100 in the TRF3 public API.
```

**Response:** 
```
I found the process in TRF3. It is a 'Procedural' class lawsuit currently assigned to the 1st Federal Court of São Paulo. The last movement was 'Conclusion for Sentence' on October 12th.
```

**Prompt:** 
```
List 5 processes from TJDFT with class code 1116 and organ code 12345.
```

**Response:** 
```
I've retrieved 5 processes from TJDFT matching those criteria. The results include processes related to 'Tax Execution' in the specified organ. Would you like to see the details of the most recent one?
```

**Prompt:** 
```
Run an advanced search in TST for processes moved in the last 7 days.
```

**Response:** 
```
I found 12 processes with movements in the last week. Most are related to 'Labor Appeals'. I can list their numbers and main subjects for you.
```

## Capabilities

### Check Status by Number
Find all detailed information about a single lawsuit using its unique CNJ number.

### Filter by Legal Type and Court Office
Limit your search results to processes that match specific procedural classes or court organ codes.

### Run Complex Data Searches
Execute advanced queries across the entire database, filtering by dates, parties, or other metadata fields.

## Use Cases

### Checking a Client's Case Status
A lawyer needs to know the current status of a client's lawsuit filed years ago. They use `search_process_by_number` with the unique ID and get the last recorded court movement immediately, eliminating phone calls to the court clerk.

### Analyzing Industry Risk
A compliance officer must assess all potential legal exposure for a new client sector. They run `search_processes_advanced` with specific industry keywords and date ranges to build a risk report.

### Researching Specific Legal Procedures
A researcher wants statistics on 'Tax Execution' processes handled by the São Paulo court office. They use `search_processes_by_class_and_organ` to pull only those relevant records for pattern analysis.

## Benefits

- Skip manual portal navigation. You can pull full case history and status updates instantly using `search_process_by_number`.
- Automate complex filtering. Instead of running multiple searches, you use advanced queries to narrow results by dates or parties via `search_processes_advanced`.
- Target specific legal niches. The MCP lets you search for processes matching both a procedural class and a court organ code using `search_processes_by_class_and_organ`.
- Eliminate data silos. Access records from multiple Brazilian courts (TRFs, TJs) through one single API connection.
- Speed up compliance checks. Run background legal risk assessments against the official national database in minutes.

## How It Works

The bottom line is: You ask your AI client to look up legal records by providing context (number, type, or dates), and it gets you the official data back.

1. Subscribe to this MCP and enter your required CNJ Datajud API Key.
2. Instruct your AI client that you need data from the Brazilian judicial system. Specify whether you have a unique case number, a class/organ code, or date parameters for filtering.
3. Your agent executes the query against the national database and returns structured metadata about the lawsuits.

## Frequently Asked Questions

**How do I find a case status using search_process_by_number?**
You provide the unique CNJ number to `search_process_by_number`. The MCP returns all associated metadata, including the current procedural class and court assignment.

**Can I run a complex date search using search_processes_advanced?**
Yes. `search_processes_advanced` is designed for this. You input specific start/end dates along with other filters like parties to pinpoint records that changed during that window.

**Do I need both class and organ codes? (Using search_processes_by_class_and_organ)**
You use `search_processes_by_class_and_organ` when you know two specific things: the procedural type AND the court office. It narrows the scope efficiently.

**Is this MCP for private company records?**
No. This MCP connects exclusively to the public CNJ Datajud API, meaning it only handles official governmental judicial processes in Brazil.

**What credentials do I need before using `search_process_by_number`?**
You must provide a valid CNJ Datajud API Key for authentication. Vinkius handles the secure storage of this key, so you just need to supply your unique credential when setting up the connection.

**If I use `search_processes_advanced` and don't get results, what might be wrong?**
It usually means no processes match your specific criteria. Double-check that all date ranges and metadata filters are correctly formatted according to the Datajud API documentation.

**Does `search_processes_by_class_and_organ` require unique codes for every query?**
No, you don't need a unique code set. You can run searches that cover broad ranges or multiple classes and organs in a single request.

**How is the data structured when I use `search_processes_advanced`?**
The output provides detailed JSON metadata, including procedural history, parties involved, and current judicial status. It's designed to give you a complete picture of the lawsuit.

**How do I find a process if I only have the CNJ number?**
Use the `search_process_by_number` tool. You will need the unformatted digits of the process and the specific court alias (e.g., `api_publica_tjsp` for São Paulo State Court).

**Can I list multiple processes from a specific court organ?**
Yes, use `search_processes_by_class_and_organ`. Provide the court alias, the procedural class code, and the organ code. You can also control the result size and use pagination.

**What is the 'Advanced Search' tool for?**
The `search_processes_advanced` tool allows you to send a raw Elasticsearch query body. This is useful for complex filtering that isn't covered by standard search tools, such as filtering by specific dates or nested metadata.