LegalContext is an open-source Model Context Protocol (MCP) server that creates a secure bridge between a law firm's Clio document management system and Claude Desktop AI assistant.
LegalContext addresses a critical challenge in legal practice: efficiently finding and leveraging information within your document management system while maintaining the highest standards of data security and client confidentiality.
For a comprehensive overview of how LegalContext can transform your legal practice, solve search frustrations, and protect against AI hallucinations, please read our detailed white paper.
The white paper covers:
Install Bun
curl -fsSL https://bun.sh/install | bash
After installation, you may need to close and reopen your terminal, or run:
source ~/.bashrc # if using bash
source ~/.zshrc # if using zsh
Clone the Repository
git clone https://github.com/yourusername/legalcontext-mcp-server.git
cd legalcontext-mcp-server
Install Dependencies
bun install
Configure Environment Variables
cp .env.example .env
Edit the .env
file using your preferred text editor and set the required variables:
nano .env # or use any other text editor
Ensure you set the following variables:
CLIO_CLIENT_ID
: Your Clio application's Client IDCLIO_CLIENT_SECRET
: Your Clio application's Client SecretCLIO_REDIRECT_URI
: The callback URL registered in your Clio app settingsCLIO_API_REGION
: The region of your Clio account ('us', 'eu', 'ca', 'au')LANCEDB_DB_PATH
: Local filesystem path to store the LanceDB database files (e.g., ./lancedb
)Start the Server
bun run src/server.ts
Configure Claude Desktop
Create or edit the Claude Desktop configuration file:
nano ~/.config/Claude-Desktop/claude_desktop_config.json
Add LegalContext as an MCP server:
{
"mcpServers": [
{
"name": "LegalContext",
"command": "/Users/YOUR_USERNAME/.bun/bin/bun",
"args": ["/Users/YOUR_USERNAME/path/to/legalcontext-mcp-server/src/server.ts"]
}
]
}
Replace /Users/YOUR_USERNAME/
with your actual home directory path.
Restart Claude Desktop for the changes to take effect.
Install Bun
Install Windows Subsystem for Linux (WSL) if you haven't already:
wsl --install
After WSL is installed, open a WSL terminal and install Bun:
curl -fsSL https://bun.sh/install | bash
Close and reopen your WSL terminal, or run:
source ~/.bashrc
Clone the Repository
git clone https://github.com/yourusername/legalcontext-mcp-server.git
cd legalcontext-mcp-server
Install Dependencies
bun install
Configure Environment Variables
cp .env.example .env
Edit the .env
file:
nano .env
Configure the required variables as described in the macOS section.
Start the Server
bun run src/server.ts
Configure Claude Desktop
Create or edit the Claude Desktop configuration file at this location:
C:\Users\YOUR_USERNAME\AppData\Roaming\Claude-Desktop\claude_desktop_config.json
Add LegalContext as an MCP server:
{
"mcpServers": [
{
"name": "LegalContext",
"command": "wsl",
"args": ["~/.bun/bin/bun", "~/path/to/legalcontext-mcp-server/src/server.ts"]
}
]
}
Replace ~/path/to/
with your actual WSL path to the project.
Restart Claude Desktop for the changes to take effect.
LegalContext can be deployed using Docker for a more standardized, firmwide setup. This approach simplifies deployment across different environments and ensures consistent behavior.
Need help? Email the Protomated team for deployment assistance or custom features/configurations for your firm's specific needs.
Build the Docker Image
docker build -t legalcontext-mcp-server:latest .
Create a docker-compose.yml File
version: '3'
services:
legalcontext:
image: legalcontext-mcp-server:latest
container_name: legalcontext
restart: unless-stopped
volumes:
- ./lancedb:/app/lancedb # Persist vector database
- ./config:/app/config # Store configuration and tokens
environment:
- NODE_ENV=production
- LOG_LEVEL=info
- CLIO_CLIENT_ID=${CLIO_CLIENT_ID}
- CLIO_CLIENT_SECRET=${CLIO_CLIENT_SECRET}
- CLIO_REDIRECT_URI=${CLIO_REDIRECT_URI}
- CLIO_API_REGION=${CLIO_API_REGION}
- LANCEDB_DB_PATH=/app/lancedb
- MAX_DOCUMENTS=100
- MAX_QUERIES_PER_DAY=50
ports:
- "3001:3001" # Expose HTTP port if needed
Create an Environment Variables File
Create a .env
file in the same directory as your docker-compose.yml
:
CLIO_CLIENT_ID=your_client_id
CLIO_CLIENT_SECRET=your_client_secret
CLIO_REDIRECT_URI=https://your-server-address/auth/clio/callback
CLIO_API_REGION=us
Start the Container
docker-compose up -d
For any firm seeking advanced deployments, consider these additional steps:
Authentication and Security
High Availability Setup
Monitoring and Logging
version: '3'
services:
legalcontext:
# ... basic config as above
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Add these if using Prometheus monitoring
labels:
- "prometheus.scrape=true"
- "prometheus.port=3001"
- "prometheus.path=/metrics"
Using Docker Secrets for Sensitive Information
version: '3.8'
services:
legalcontext:
# ... other configuration
secrets:
- clio_client_id
- clio_client_secret
environment:
- CLIO_CLIENT_ID_FILE=/run/secrets/clio_client_id
- CLIO_CLIENT_SECRET_FILE=/run/secrets/clio_client_secret
# ... other environment variables
secrets:
clio_client_id:
file: ./secrets/clio_client_id.txt
clio_client_secret:
file: ./secrets/clio_client_secret.txt
Integration with Claude Desktop
For firmwide deployments, instead of having each user configure Claude Desktop manually, consider:
Example centralized configuration script:
#!/bin/bash
# Script to configure Claude Desktop for LegalContext
# Create config directory if it doesn't exist
mkdir -p ~/.config/Claude-Desktop
# Generate the config file with the correct server address
cat > ~/.config/Claude-Desktop/claude_desktop_config.json << EOF
{
"mcpServers": [
{
"name": "LegalContext (Firm)",
"url": "http://legalcontext.internal.example.com:3001"
}
]
}
EOF
echo "Claude Desktop configured successfully."
# Pull the latest code
git pull
# Rebuild the Docker image
docker-compose build
# Restart the service
docker-compose down
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose stop legalcontext
# Back up the vector database
tar -czf lancedb-backup-$(date +%Y%m%d).tar.gz ./lancedb
# Restart the container
docker-compose start legalcontext
Run the document indexing process to pull and index Clio documents:
bun run src/scripts/index.ts
This process:
Example queries:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
{
"mcpServers": {
"LegalContext": {
"env": {},
"args": [
"/Users/YOUR_USERNAME/path/to/legalcontext-mcp-server/src/server.ts"
],
"command": "bun"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.