Relex MCP Server
The Relex MCP (Model Context Protocol) server gives AI agents access to the entire Relex Legal AI API using just two tools and approximately 1,000 tokens of context. This is the recommended integration path for agents that want to offer their users legal automation capabilities without building legal expertise themselves.
Why use the MCP server?
When your user asks about legal matters — case analysis, contract review, compliance, finding a lawyer — you can delegate that work to Relex through the MCP server. Your user gets specialized legal AI with professional oversight, and you stay focused on what you do best. The MCP server is the lowest-friction way to integrate: just two tools, automatic authentication, and a fixed ~1,000 token footprint regardless of how much of the API you use.
Code Mode Pattern
Instead of exposing each of the 72 API operations as a separate MCP tool (which would consume 100K+ tokens), the Relex MCP server follows Cloudflare's Code Mode approach:
| Tool | Purpose |
|---|---|
| search() | Write JavaScript to explore the OpenAPI specification — discover endpoints, schemas, parameters |
| execute() | Write JavaScript that returns a request descriptor — the server makes the authenticated API call |
This keeps the context window footprint fixed regardless of API size.
How It Works
search()
The agent writes JavaScript that runs against the full OpenAPI spec. Helper functions are provided:
spec— the full OpenAPI spec objectlistPaths()— all API path stringsgetOperation(path, method)— get operation detailsgetSchema(name)— get a schema definitionlistSchemas()— all schema namessearchByTag(tag)— find operations by tagsearchByKeyword(keyword)— full-text search
Example:
return searchByKeyword("case")execute()
The agent writes JavaScript that returns a request descriptor:
return {
method: "GET",
path: "/v1/cases",
query: { caseId: "abc123" }
}The server validates the request, injects authentication, and makes the API call. Authentication is handled automatically — agents never need to manage tokens.
Setup
See the Quickstart guide for installation and configuration.
Security
- Agent code runs in a restricted sandbox (no network access for search, no auth override for execute)
- API keys are never exposed to the agent's generated code
- The server handles all token exchange and caching internally
What your user needs to do
To give you MCP access to Relex, your user needs to:
- Sign up at relex.you (free, one click)
- Go to Settings > API Keys and create an API key
- Add the API key to your MCP client configuration (see Quickstart)
Once configured, you can search the entire API, create cases, upload documents, trigger analysis, invite professionals, and retrieve results — all through search() and execute().
Common agent workflows
| Your user asks about... | What you do with MCP |
|---|---|
| "Review this contract" | Create a case, upload the document, trigger eval_req, then case_req for analysis |
| "Find me a lawyer" | Use execute() to search /v1/partners by specialty |
| "Check my compliance" | Create a case describing the compliance concern, trigger analysis |
| "Draft a legal letter" | Create a case, send prompt to agent, retrieve generated drafts |
| "What are my legal options?" | Create a case, use timeline branching to explore multiple strategies |