Skip to main content

MCP server for Legalis — Brazilian legal document AI for attorneys

Project description

Legalis MCP Server

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

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
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…)
get_case_context Get case context (facts, parties, evidence)
run_interview AI-guided case intake interview
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.json with 600 permissions (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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

legalis_mcp-0.2.0.tar.gz (79.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

legalis_mcp-0.2.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file legalis_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: legalis_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 79.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for legalis_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1f01bc1f617aac98bffc2de0b0f4d6a5ab5f88ab6e1ecc84e2944fe252fd62e0
MD5 182ed171e622688640e274441e1e3152
BLAKE2b-256 85e8c525ce3323150d2f586e104e6a20d91b438f06e7c7fb279e127649f0719b

See more details on using hashes here.

File details

Details for the file legalis_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: legalis_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for legalis_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6789945ebffc93c2c75af3d649f829c3036d68aac24a4d0f6afbb059771d527d
MD5 83308d6eefdb846372f21cd78e4e2d1c
BLAKE2b-256 d909a74095e79d78c3769def8564d1ab43867e0c66558079a793bdfe7dc4e9a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page