Логотип LegalContext

LegalContext

Организация
protomated

LegalContext is an open-source Model Context Protocol (MCP) server that creates a secure, standardized bridge between law firms' document management systems (specifically Clio) and AI assistants (starting with Claude Desktop)

Издательprotomated
Репозиторийlegal-context-ce
ЯзыкTypeScript
Форки
9
Звёзды
29
Доступные инструменты
0
Тип транспортаstdio
Категории
ЛицензияMPL-2.0
Ссылки
  • Подключайте инструменты к рабочим процессам с ИИ

    LegalContext предоставляет возможности MCP, доступные совместимым ИИ-клиентам и агентам.

  • Доступные инструменты: 0

    Ниже представлены доступные для вызова действия с названиями и описаниями, если сервер их предоставляет.

  • Готовая конфигурация для копирования

    Используйте примеры конфигурации, чтобы настроить этот сервер в MCP-клиенте на ваш выбор.

  • Показатели интереса к открытому проекту

    В указанном репозитории: звёзды — 29, форки — 9.

MseeP.ai Security Assessment Badge

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)

Why LegalContext?

For legal professionals, the intersection of AI capabilities and client confidentiality creates a significant challenge:

  1. 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.

  2. 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:

  1. Grounding Claude's responses in your actual documents - eliminating hallucinations by using Retrieval-Augmented Generation (RAG)
  2. Processing all documents locally - maintaining complete data control and meeting confidentiality requirements
  3. 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

bash
# 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:

bash
# Run the setup script
./install.sh

The script will:

  1. Check for Bun installation or install it if needed
  2. Configure necessary environment variables in .env
  3. Create Claude Desktop configuration file automatically with the correct paths and environment variables
  4. Guide you through Clio OAuth setup
  5. 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:

  1. Install Bun

    bash
    curl -fsSL https://bun.sh/install | bash
  2. Clone the repository

    bash
    git clone https://github.com/protomated/legal-context.git
    cd legal-context
  3. Install dependencies

    bash
    bun install
  4. Configure environment variables

    bash
    cp .env.example .env

    Edit .env with your Clio credentials and other settings

  5. Configure Claude Desktop Create or edit the Claude Desktop configuration file (see Claude Desktop Integration)

  6. Start the server

    bash
    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.json

Windows

%APPDATA%\Claude\claude_desktop_config.json

Linux

~/.config/Claude/claude_desktop_config.json

Add the following configuration (adjust paths and environment variables for your system):

json
{
  "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:

  1. Replace the command path with the full path to your Bun executable (find using which bun)
  2. Replace the args path with the full absolute path to your server.ts file
  3. Add your actual Clio API credentials in the env section
  4. The environment variables in this config will override your .env file

Verifying the Integration

  1. Start Claude Desktop
  2. Go to Settings > Developer
  3. You should see "legalcontext" listed as an MCP server with status "Running"
  4. 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 bun to 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.log
      • Windows: %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:

  1. Open Claude Desktop
  2. Type: "Can you check if LegalContext is working?"
  3. Claude should respond that it can access the LegalContext tools
  4. Try a document query like: "What documents do we have in our Clio account?"

Clio Setup

Creating a Clio API Application

  1. Visit Clio Developers Portal
    • Use the appropriate regional URL if not using the US version of Clio
  2. Click "New Application"
  3. Enter application details:
    • Name: "LegalContext"
    • Redirect URI: http://127.0.0.1:3001/clio/auth/callback
    • Scopes: Enable documents and folders scopes
  4. Save the application and note your Client ID and Client Secret
  5. Add these credentials to your .env file or directly to your Claude Desktop configuration

Usage Guide

Authentication

  1. Start Claude Desktop (which will automatically launch LegalContext)
  2. Open a browser and navigate to:
    http://localhost:3001/clio/auth
  3. Follow the Clio OAuth flow to authorize LegalContext
  4. 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:

bash
bun run index:batch

Using 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 ~/.legalcontext directory 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

  1. "Clio API client not initialized"

    • Ensure you've completed the Clio authentication process
    • Check your Clio API credentials in .env or Claude Desktop config
    • Verify the redirect URI matches your Clio application settings
    • Try running bun run auth:simple to test authentication
  2. "No documents found in vector search"

    • Make sure you've indexed documents with bun run index:batch
    • Check 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.json file to see which documents are indexed
  3. 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 start in 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 search
  • Clio tokens: ~/.legalcontext/clio_tokens - Stores your Clio API authentication tokens
  • Indexed documents: ~/.legalcontext/indexed_documents.json - Tracks which documents have been indexed
  • Query 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:

bash
# 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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open 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:

Установка

TypingMind
Требования:

Node.js 18+

{
  "mcpServers": {
    "protomated-legal-context": {
      "command": "",
      "args": []
    }
  }
}

Используйте LegalContext MCP с разными моделями ИИ

TypingMind подключает инструменты MCP на уровне рабочего пространства, поэтому после подключения LegalContext вы можете использовать их с разными моделями ИИ в TypingMind, не настраивая подключение отдельно для каждой модели. Эта интеграция MCP работает локально на вашем устройстве через коннектор MCP TypingMind.

Руководство по настройке локального коннектора

Выберите этот способ, если серверу MCP нужен доступ к локальным файлам, приложениям или закрытым ресурсам на вашем компьютере.

1

Откройте настройки MCP

В TypingMind откройте «Настройки», затем «Расширенные настройки», перейдите в раздел «Протокол контекста модели» и выберите «Настроить коннектор».

  1. Откройте TypingMind в браузере.
  2. Нажмите значок настроек.
  3. Перейдите в «Расширенные настройки».
  4. Откройте раздел «Протокол контекста модели».
  5. Нажмите «Настроить коннектор» и выберите «Это устройство».
Экран настройки коннектора MCP в TypingMind с выбранным вариантом «Это устройство»
2

Выполните команду запуска коннектора

Выберите «Это устройство», скопируйте команду из TypingMind и выполните её в терминале. Не останавливайте процесс, пока используете MCP.

  1. Скопируйте команду настройки, показанную в TypingMind.
  2. Откройте «Терминал» в macOS или Windows Terminal в Windows.
  3. Вставьте и выполните команду.
  4. Если в терминале появится запрос на подтверждение, подтвердите установку пакета.
  5. Не закрывайте окно терминала и не останавливайте процесс, пока используете инструменты MCP.
3

Добавьте сервер LegalContext

Когда статус коннектора сменится на «Готов», нажмите «Изменить серверы» и вставьте конфигурацию сервера MCP.

  1. Дождитесь, пока статус коннектора сменится на «Готов».
  2. Нажмите «Изменить серверы».
  3. Вставьте конфигурацию сервера MCP LegalContext.
  4. Сохраните список серверов.
  5. Обновите статус, если хотите убедиться, что коннектор по-прежнему готов к работе.
Настройки MCP в TypingMind с активным сервером и кнопкой «Изменить серверы»
{
  "mcpServers": {
    "protomated-legal-context": {
      "command": "npx",
      "args": [
        "-y",
        "@protomated/legal-context"
      ]
    }
  }
}
4

Используйте подключение с разными моделями

Сохраните список серверов, откройте раздел «Плагины», включите инструменты MCP для LegalContext, затем выберите любую поддерживаемую модель ИИ в TypingMind и используйте инструменты в чате или назначьте их ИИ-агенту.

  1. Откройте страницу «Плагины» в TypingMind.
  2. Включите инструменты MCP для LegalContext.
  3. Начните чат и выберите модель ИИ, которую хотите использовать.
  4. Используйте инструменты MCP в чате или назначьте их ИИ-агенту.
  5. При необходимости переключайтесь на другую модель ИИ без повторного подключения MCP.
Чат TypingMind с включёнными инструментами MCP и выбранной ИИ-моделью
Можете использовать LegalContext, чтобы помочь мне с этой задачей?
LegalContext
Конечно. Я всё прочитал.
Вот что я нашёл с помощью LegalContext.

Часто задаваемые вопросы

Для чего используется сервер MCP LegalContext?

LegalContext — это сервер MCP, который позволяет совместимым ИИ-клиентам подключаться к внешним инструментам и получать контекст. В TypingMind достаточно один раз добавить этот сервер MCP, чтобы его инструменты стали доступны в вашем рабочем пространстве с ИИ.

Можно ли использовать сервер MCP LegalContext с несколькими ИИ-моделями в TypingMind?

Да. TypingMind подключает инструменты MCP на уровне рабочего пространства, поэтому вы можете использовать LegalContext с разными ИИ-моделями, например Claude, ChatGPT, Gemini или другими моделями, настроенными в TypingMind, без отдельной настройки сервера MCP для каждой модели.

Зачем использовать сервер MCP LegalContext с TypingMind?

TypingMind — один из лучших интерфейсов для чата с LLM: он объединяет разные ИИ-модели, промпты, плагины, ИИ-агентов, ключи API и инструменты MCP в одном рабочем пространстве. Подключив LegalContext, вы сможете использовать его инструменты MCP с моделями, которые предпочитаете, и поддерживать порядок в чатах TypingMind.

Как подключить сервер MCP LegalContext к TypingMind?

LegalContext работает через локальный коннектор MCP TypingMind. Этот вариант лучше всего подходит, когда серверу MCP нужен доступ к локальным файлам, настольным приложениям, инструментам командной строки или закрытым ресурсам на вашем компьютере.

Какие инструменты предоставляет сервер MCP LegalContext в TypingMind?

LegalContext предоставляет возможности MCP, которые можно включить на странице «Плагины» в TypingMind и использовать в чате или назначить ИИ-агентам.

Нужно ли передавать TypingMind свои ключи API для использования сервера MCP LegalContext?

Нет. TypingMind ориентирован прежде всего на локальную работу и позволяет вам контролировать выбор провайдеров моделей, ключи API, промпты и конфигурацию MCP. Если LegalContext требует аутентификации, при создании подключения добавьте необходимые заголовки, настройки OAuth или локальную конфигурацию для этого сервера MCP.

Похожие MCP-серверы

Все

Создайте своё рабочее пространство с ИИ прямо сейчас

Подпишитесь на нашу рассылку, чтобы узнавать о новых функциях и предстоящих розыгрышах 👇