lexmcp
v1.0.0
Published
Model Context Protocol (MCP) Server for LexMCP with Typesense integration
Maintainers
Readme
LexMCP - Model Context Protocol Server
A Model Context Protocol (MCP) server for LexMCP that interfaces with Typesense to provide legal resources.
Features
- MCP server that provides legal resources through the Model Context Protocol
- REST API for directly accessing Typesense data
- Support for searching legal opinions and court information
- Easily deployable via NPX
Installation
npm install -g lexmcp-mcp-serverOr run directly with npx:
npx lexmcp-mcp-serverConfiguration
The server can be configured using environment variables:
PORT: The port for the REST API server (default: 8001)TYPESENSE_HOST: Typesense server host (default: localhost)TYPESENSE_PORT: Typesense server port (default: 8108)TYPESENSE_PROTOCOL: Typesense server protocol (default: http)TYPESENSE_API_KEY: Typesense API key (default: xyz)
MCP Tools
The server provides the following MCP tools:
search - Search for documents
- Parameters:
query: The search querycollection(optional): The collection to search (default: "opinions")fields(optional): The fields to search (default: ["text_chunks"])per_page(optional): The number of results per page (default: 10)page(optional): The page number (default: 1)
- Parameters:
get_document - Retrieve document by ID
- Parameters:
document_id: The document IDcollection(optional): The collection to search (default: "opinions")
- Parameters:
list_courts - List available courts
- Parameters:
per_page(optional): The number of results per page (default: 100)page(optional): The page number (default: 1)
- Parameters:
health_check - Check Typesense server health
REST API Endpoints
POST /search: Search for documentsGET /collections/:collection/documents/:id: Retrieve document by IDGET /courts: List available courtsGET /health: Check Typesense server health
Adding to Claude Config
Add LexMCP to your Claude configuration file:
{
"mcpServers": {
"lexmcp": {
"command": "npx",
"args": ["-y", "lexmcp-mcp-server"]
}
}
}Examples
Search for legal opinions
{
"type": "function_call",
"name": "search",
"id": "1",
"arguments": {
"query": "first amendment",
"collection": "opinions",
"fields": ["text_chunks"]
}
}Get a specific document
{
"type": "function_call",
"name": "get_document",
"id": "2",
"arguments": {
"document_id": "10224550",
"collection": "opinions"
}
}List courts
{
"type": "function_call",
"name": "list_courts",
"id": "3",
"arguments": {
"per_page": 20,
"page": 1
}
}Search API Features
The MCP server now supports three types of search:
1. Vector Search (Default)
Vector search uses embedding vectors to find semantically similar documents, regardless of exact keyword matches. This is useful for finding conceptually related documents even when they don't contain the exact search terms.
POST /search
{
"searchType": "vector",
"vector": [0.1, -0.2, 0.3, ...], // 384-dimension embedding vector
"collection": "documents",
"per_page": 10,
"page": 1
}2. Keyword Search
Traditional text-based search using keywords.
POST /search
{
"searchType": "keyword",
"query": "first amendment freedom of speech",
"collection": "documents",
"fields": ["title", "text_chunks"],
"per_page": 10,
"page": 1
}3. Hybrid Search
Combines both vector similarity and keyword matching for more robust results.
POST /search
{
"searchType": "hybrid",
"query": "first amendment freedom of speech",
"vector": [0.1, -0.2, 0.3, ...], // 384-dimension embedding vector
"vectorWeight": 0.3, // Weight given to vector similarity (0-1)
"collection": "documents",
"fields": ["title", "text_chunks"],
"per_page": 10,
"page": 1
}MCP Function Calls
The same search types are available through MCP function calls:
{
"name": "search",
"arguments": {
"searchType": "vector", // "vector", "keyword", or "hybrid"
"query": "search query", // Required for keyword and hybrid search
"vector": [0.1, 0.2, ...], // Required for vector and hybrid search
"vectorWeight": 0.3, // Optional, for hybrid search (0-1)
"collection": "documents",
"fields": ["title", "text_chunks"],
"per_page": 10,
"page": 1
}
}License
MIT
