
LegalContext
STDIOSecure MCP server connecting Clio document system to Claude Desktop for legal professionals.
Secure MCP server connecting Clio document system to Claude Desktop for legal professionals.
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.
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:
# 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?"
Our automated setup script handles the complete configuration process for you:
# Run the setup script ./install.sh
The script will:
This is the recommended approach as it ensures all components are correctly configured.
If you prefer to set up manually:
Install Bun
curl -fsSL https://bun.sh/install | bash
Clone the repository
git clone https://github.com/protomated/legal-context.git cd legal-context
Install dependencies
bun install
Configure environment variables
cp .env.example .env
Edit .env
with your Clio credentials and other settings
Configure Claude Desktop Create or edit the Claude Desktop configuration file (see Claude Desktop Integration)
Start the server
bun run src/server.ts
LegalContext communicates with Claude Desktop using the Model Context Protocol (MCP). To configure Claude Desktop to use LegalContext:
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.
Create or edit the Claude Desktop configuration file at:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
Add 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:
which bun
)which bun
to find it)~/Library/Logs/Claude/legalcontext.log
%USERPROFILE%\AppData\Local\Claude\Logs\legalcontext.log
Once the integration is set up, you can test it with a simple query in Claude Desktop:
http://127.0.0.1:3001/clio/auth/callback
documents
and folders
scopes.env
file or directly to your Claude Desktop configurationhttp://localhost:3001/clio/auth
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:batch
Once your documents are indexed, you can ask Claude questions about them:
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.
LegalContext prioritizes security and confidentiality:
~/.legalcontext
directory in your home folderThe free version of LegalContext includes reasonable limitations:
These limitations ensure the project remains sustainable while providing value to individual legal practitioners.
"Clio API client not initialized"
.env
or Claude Desktop configbun run auth:simple
to test authentication"No documents found in vector search"
bun run index:batch
~/.legalcontext/indexed_documents.json
file to see which documents are indexedLegalContext not appearing in Claude Desktop
bun start
in a terminal)~/Library/Logs/Claude/legalcontext.log
(macOS)LegalContext stores all its data in the ~/.legalcontext
directory in your home folder. This includes:
~/.legalcontext/lancedb
- Contains the vector embeddings for document search~/.legalcontext/clio_tokens
- Stores your Clio API authentication tokens~/.legalcontext/indexed_documents.json
- Tracks which documents have been indexed~/.legalcontext/query_counter.json
- Tracks daily query usage for free tier limitationsIf 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.
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.ts
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
For assistance, please: