Legalis MCP Server
Assistente jurídico com IA para advogados brasileiros
MCP (Model Context Protocol) server for Legalis — Brazilian legal document AI for attorneys.
Connect Claude (or any MCP-compatible client) to your Legalis account and interact with cases, generate legal documents, search legislation, and more using natural language.
Quick start
1. Install
pip install legalis-mcp
# or with uv:
uv tool install legalis-mcp
2. Authenticate
legalis-mcp auth
This opens your browser. Log in to Legalis normally — tokens are saved to ~/.legalis/credentials.json (owner-readable only).
3. Configure Claude
Add to your Claude configuration (~/.claude/claude_desktop_config.json for Claude Desktop, or claude_code_config.json for Claude Code):
{
"mcpServers": {
"legalis": {
"command": "legalis-mcp",
"args": ["serve"]
}
}
}
4. Use
In Claude, try:
- "Liste meus casos no Legalis"
- "Crie um caso de rescisão indireta para João Silva"
- "Gere a seção de fundamentos jurídicos da peça X do caso Y"
- "Pesquise legislação trabalhista sobre justa causa"
- "Quantas gerações ainda tenho disponíveis este mês?"
Available tools
Cases
| Tool | Description |
|---|---|
list_cases |
List cases (paginated, filterable by status) |
get_case |
Get case details by ID |
create_case |
Create a new case |
update_case |
Update case fields |
search_cases |
Full-text search across cases |
delete_case |
Delete a case permanently |
Legal documents
| Tool | Description |
|---|---|
list_legal_documents |
List peças processuais for a case |
get_legal_document |
Get a document with all sections |
create_legal_document |
Create a new legal document |
generate_section |
AI-generate a document section (fatos, fundamentos, pedidos…) |
update_section_text |
Manually edit a document section |
get_case_context |
Get case context (facts, parties, evidence) |
update_case_context |
Update case context |
delete_legal_document |
Delete a legal document |
export_legal_document_docx |
Export a document as DOCX |
Events & Tasks
| Tool | Description |
|---|---|
create_case_event |
Create an event on a case (internal or client-visible) |
list_case_events |
List events for a case |
delete_case_event |
Delete a case event |
create_case_task |
Create a task with due date and priority |
list_case_tasks |
List tasks for a case |
update_case_task |
Update a task's fields |
complete_case_task |
Mark a task as complete |
delete_case_task |
Delete a task |
list_upcoming_tasks |
List upcoming tasks across all cases |
list_overdue_tasks |
List all overdue tasks |
Other
| Tool | Description |
|---|---|
run_interview |
AI-guided case intake interview |
list_templates |
List available document templates |
get_template |
Get template details and sections |
search_legislation |
Search Brazilian legislation (LexML) |
get_my_usage |
Check AI quota and billing period usage |
CLI commands
legalis-mcp auth # Authenticate via browser
legalis-mcp serve # Start MCP server (stdio)
legalis-mcp status # Verify authentication
legalis-mcp logout # Remove stored credentials
Development
git clone <repo>
cd mcp
pip install -e ".[test]"
# Run unit tests (no external services needed)
pytest tests/unit/ -v
# Run integration tests (requires Docker)
cd ../integration && docker-compose up -d
cd ../mcp
LEGALIS_API_URL=http://localhost:8000 \
LEGALIS_ACCESS_TOKEN=<token> \
LEGALIS_REFRESH_TOKEN=<refresh> \
pytest tests/integration/ -v
Environment variables
| Variable | Default | Description |
|---|---|---|
LEGALIS_API_URL |
https://hai-production-612f.up.railway.app |
Backend URL |
LEGALIS_ACCESS_TOKEN |
— | Pre-issued token (CI/test only) |
LEGALIS_REFRESH_TOKEN |
— | Refresh token (CI/test only) |
LEGALIS_CREDENTIALS_FILE |
~/.legalis/credentials.json |
Credentials file path |
LEGALIS_OAUTH_PORT |
3742 |
Local OAuth callback port |
Security
- Credentials are stored in
~/.legalis/credentials.jsonwith600permissions (owner read/write only). - The OAuth redirect is restricted to
http://localhost— open-redirect attacks are blocked at the backend. - Tokens are never stored in the MCP configuration file.
- All API calls go through the existing Legalis backend — RBAC, rate limiting, and quotas apply normally.
Publishing
# PyPI
pip install build twine
python -m build
twine upload dist/*
# Then register at:
# - smithery.ai (MCP marketplace)
# - mcp.so (community directory)
# - github.com/modelcontextprotocol/servers (official list)
Metadata
Release files for legalis-mcp 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| legalis_mcp-0.5.0.tar.gz | 92.2 kB | Without provenance | Details for legalis_mcp-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| legalis_mcp-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for legalis_mcp-0.5.0-py3-none-any.whl |
Total release size: 111.4 kB
Release files / legalis_mcp-0.5.0.tar.gz
| Download URL | legalis_mcp-0.5.0.tar.gz |
|---|---|
| Size | 92.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0db422448621c0c83246d25577e404af9e7e69c93a118105996a6c90309d503d
|
|
BLAKE2b-256 checksum How to use checksums |
59279a6ad549258d9076c781c9bfeeeaffe4d9b1a7668a398a33efcde7991e0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / legalis_mcp-0.5.0-py3-none-any.whl
| Download URL | legalis_mcp-0.5.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afdd89c9cd485f4ee01ea313a3d4165aff9621ff0beeba6335e63adec5a70506
|
|
BLAKE2b-256 checksum How to use checksums |
dd556fa8897252cdbb15596502974f47b70751dcd3467131d76791a76aa66dfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for legalis-mcp 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.