LegalContext
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LegalContextWhat are the key provisions in our standard NDA?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LegalContext
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.
Features
Secure Document Access: Connects to Clio API to access legal documents while maintaining complete security and confidentiality
Local Processing: All document processing happens locally within your firm's infrastructure, ensuring client data never leaves your security perimeter
MCP Integration: Seamlessly integrates with Claude Desktop through the Model Context Protocol (MCP)
Semantic Search: Uses LanceDB for efficient vector search, enabling Claude to find the most relevant documents based on meaning, not just keywords
Citation Tracking: All Claude responses include proper citations to your source documents
Free Tier Limitations: Includes reasonable limits for the free version (100 documents, 50 queries/day)
Related MCP server: Claude RAG MCP Pipeline
Why LegalContext?
For legal professionals, the intersection of AI capabilities and client confidentiality creates a significant challenge:
The AI Hallucination Problem: Large language models like Claude can provide incorrect or fabricated information. This is particularly dangerous in legal contexts where accuracy is paramount.
The Client Confidentiality Dilemma: Traditional AI tools require uploading documents to external servers, potentially compromising client confidentiality and attorney-client privilege.
LegalContext solves both problems by:
Grounding Claude's responses in your actual documents - eliminating hallucinations by using Retrieval-Augmented Generation (RAG)
Processing all documents locally - maintaining complete data control and meeting confidentiality requirements
Creating a secure bridge to Claude Desktop - leveraging AI capabilities without exposing sensitive information
Table of Contents
Prerequisites
Bun: Version 1.0 or later (JavaScript runtime and package manager)
Clio: A Clio account with API access and registered application credentials
Claude Desktop: Anthropic's Claude Desktop application
Operating System: macOS, Linux, or Windows with WSL
Quick Start
# Clone the repository
git clone https://github.com/protomated/legal-context.git
cd legal-context
# Install dependencies
bun install
# Run the setup script (automated configuration)
./install.sh
# The script will set up everything including an initial document indexing
# Start Claude Desktop and verify that LegalContext appears as an MCP server
# In Claude Desktop, ask a legal question that requires document access
# Example: "What are the key provisions in our standard NDA?"Detailed Installation
Automated Setup
Our automated setup script handles the complete configuration process for you:
# Run the setup script
./install.shThe script will:
Check for Bun installation or install it if needed
Configure necessary environment variables in .env
Create Claude Desktop configuration file automatically with the correct paths and environment variables
Guide you through Clio OAuth setup
Run an initial batch indexing of your documents (up to 100 for free tier)
This is the recommended approach as it ensures all components are correctly configured.
Manual Setup
If you prefer to set up manually:
Install Bun
curl -fsSL https://bun.sh/install | bashClone the repository
git clone https://github.com/protomated/legal-context.git cd legal-contextInstall dependencies
bun installConfigure environment variables
cp .env.example .envEdit
.envwith your Clio credentials and other settingsConfigure Claude Desktop Create or edit the Claude Desktop configuration file (see Claude Desktop Integration)
Start the server
bun run src/server.ts
Claude Desktop Integration
LegalContext communicates with Claude Desktop using the Model Context Protocol (MCP). To configure Claude Desktop to use LegalContext:
Automated Configuration (Recommended)
The install.sh script will automatically create or update the Claude Desktop configuration file. After running the script, simply restart Claude Desktop to apply the changes.
Manual Configuration
Create or edit the Claude Desktop configuration file at:
macOS
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows
%APPDATA%\Claude\claude_desktop_config.jsonLinux
~/.config/Claude/claude_desktop_config.jsonAdd the following configuration (adjust paths and environment variables for your system):
{
"mcpServers": {
"legalcontext": {
"command": "/path/to/bun",
"args": [
"/path/to/legal-context/src/server.ts"
],
"cwd": "/path/to/legal-context",
"env": {
"CLIO_CLIENT_ID": "your_clio_client_id",
"CLIO_CLIENT_SECRET": "your_clio_client_secret",
"CLIO_REDIRECT_URI": "http://127.0.0.1:3001/clio/auth/callback",
"CLIO_API_REGION": "us"
}
}
}
}Important Notes:
Replace the command path with the full path to your Bun executable (find using
which bun)Replace the args path with the full absolute path to your server.ts file
Add your actual Clio API credentials in the env section
The environment variables in this config will override your .env file
Verifying the Integration
Start Claude Desktop
Go to Settings > Developer
You should see "legalcontext" listed as an MCP server with status "Running"
If it shows "Not running" or doesn't appear:
Ensure the paths in your configuration are absolute and correct for your system
Verify that the Bun executable path is correct (use
which bunto find it)Check that you have the correct environment variables set
Restart Claude Desktop after making configuration changes
Check the logs at:
macOS:
~/Library/Logs/Claude/legalcontext.logWindows:
%USERPROFILE%\AppData\Local\Claude\Logs\legalcontext.log
Testing the Integration
Once the integration is set up, you can test it with a simple query in Claude Desktop:
Open Claude Desktop
Type: "Can you check if LegalContext is working?"
Claude should respond that it can access the LegalContext tools
Try a document query like: "What documents do we have in our Clio account?"
Clio Setup
Creating a Clio API Application
Visit Clio Developers Portal
Use the appropriate regional URL if not using the US version of Clio
Click "New Application"
Enter application details:
Name: "LegalContext"
Redirect URI:
http://127.0.0.1:3001/clio/auth/callbackScopes: Enable
documentsandfoldersscopes
Save the application and note your Client ID and Client Secret
Add these credentials to your
.envfile or directly to your Claude Desktop configuration
Usage Guide
Authentication
Start Claude Desktop (which will automatically launch LegalContext)
Open a browser and navigate to:
http://localhost:3001/clio/authFollow the Clio OAuth flow to authorize LegalContext
You'll be redirected to a success page once authentication completes
Indexing Documents
The installation script automatically runs an initial batch indexing process for your documents (up to the free tier limit of 100).
For additional documents or to refresh the index, you can:
Ask Claude to index specific documents:
Claude, please index the document with ID 12345 from our Clio account.Or use the batch indexing tool directly:
bun run index:batchUsing with Claude Desktop
Once your documents are indexed, you can ask Claude questions about them:
Document search: "Find all employment contracts drafted in the last year"
Document analysis: "What are the key provisions in our standard NDA?"
Legal research: "Summarize our precedents for data privacy cases"
Contract comparison: "How does the Johnson contract compare to our standard terms?"
Claude will use the LegalContext tools to search your document repository, retrieve the most relevant documents, ground its answers in your actual documents, and provide citations to the source documents.
Security Features
LegalContext prioritizes security and confidentiality:
Local Processing: All document content is processed within your infrastructure
Secure OAuth: Uses industry-standard OAuth 2.0 for Clio authentication
Encrypted Token Storage: Access tokens are securely stored with encryption
No Cloud Dependencies: Documents are never sent to external AI services
Full Transparency: Open-source codebase allows complete security audit
Centralized Data Storage: All data is stored in the
~/.legalcontextdirectory in your home folder
Free Tier Limitations
The free version of LegalContext includes reasonable limitations:
Document Limit: Maximum of 100 indexed documents
Query Limit: 50 queries per day
Single Instance: Designed for individual use rather than firm-wide deployment
These limitations ensure the project remains sustainable while providing value to individual legal practitioners.
Troubleshooting
Common Issues
"Clio API client not initialized"
Ensure you've completed the Clio authentication process
Check your Clio API credentials in
.envor Claude Desktop configVerify the redirect URI matches your Clio application settings
Try running
bun run auth:simpleto test authentication
"No documents found in vector search"
Make sure you've indexed documents with
bun run index:batchCheck that your documents are in a compatible format (PDF, DOCX)
Verify that the documents exist in your Clio account
Look at the
~/.legalcontext/indexed_documents.jsonfile to see which documents are indexed
LegalContext not appearing in Claude Desktop
Ensure the Claude Desktop configuration file has the correct format and location
Use absolute paths for both the Bun executable and the server.ts file
Verify all required environment variables are set in the config
Check that LegalContext server is running (
bun startin a terminal)Restart Claude Desktop after configuration changes
Look at the logs in
~/Library/Logs/Claude/legalcontext.log(macOS)
Data Storage
LegalContext stores all its data in the ~/.legalcontext directory in your home folder. This includes:
LanceDB database:
~/.legalcontext/lancedb- Contains the vector embeddings for document searchClio tokens:
~/.legalcontext/clio_tokens- Stores your Clio API authentication tokensIndexed documents:
~/.legalcontext/indexed_documents.json- Tracks which documents have been indexedQuery counter:
~/.legalcontext/query_counter.json- Tracks daily query usage for free tier limitations
If you need to reset the application, you can delete this directory, but you'll need to re-authenticate with Clio and re-index your documents.
Diagnostic Tools
LegalContext includes several diagnostic tools:
# Test Clio authentication
bun run auth:simple
# Check Clio API access
bun run check:clio
# Test document processing
bun run test:extraction
# Reset indexing state
bun run src/tools/reset-index-tracking.tsContributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create a feature branch:
git checkout -b feature/amazing-featureCommit your changes:
git commit -m 'Add amazing feature'Push to the branch:
git push origin feature/amazing-featureOpen a Pull Request
License
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
Support
For assistance, please:
Open an issue on GitHub
Email the team at team@protomated.com
Visit our website at protomated.com
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/protomated/legal-context-ce'
If you have feedback or need assistance with the MCP directory API, please join our Discord server