ClauseLens MCP

ClauseLens MCP

Enables Claude or Cursor to act as a contract analyst by providing tools for document fetching, clause segmentation, span verification, and risk taxonomy lookup, with no server-side LLM calls or document retention.

Category
Visit Server

README

ClauseLens MCP

ClauseLens is a production remote MCP (Model Context Protocol) server that turns Claude or Cursor into a contract analyst. It exposes structured tools for fetching documents, segmenting clauses, verifying spans, and accessing a risk taxonomy — the connecting LLM does all reasoning. No documents are retained and no LLM calls are made server-side.


Architecture

┌─────────────────────┐
│   Claude / Cursor   │  (does all reasoning, zero server-side LLM calls)
└────────┬────────────┘
         │  HTTPS + JWT (OAuth 2.1 via WorkOS AuthKit)
         ▼
┌─────────────────────┐
│   Railway (public   │  (TLS termination, public HTTPS URL)
│   HTTPS endpoint)   │
└────────┬────────────┘
         │
         ▼
┌─────────────────────────────────────────────────────┐
│   FastMCP 3.x (Streamable HTTP)                     │
│                                                     │
│   Auth middleware: JWT validation + rate limiting   │
│                                                     │
│   Tools:                                            │
│     fetch_document  ──► SSRF-hardened HTTP fetch    │
│     segment_clauses ──► heuristic clause splitter   │
│     verify_spans    ──► grounding guardrail         │
│     get_risk_taxonomy ► taxonomy lookup             │
│                                                     │
│   Resources:                                        │
│     clauselens://taxonomy                           │
│     clauselens://severity-rubric                    │
│                                                     │
│   Prompt:                                           │
│     analyze_contract                                │
│                                                     │
│   No document retention — all processing in-memory │
└─────────────────────────────────────────────────────┘

MCP Surface

Tools

Tool Description
fetch_document(url) SSRF-hardened HTTP fetch. Extracts readable text via trafilatura. 10s timeout, 2MB cap, 100k char extracted text cap. Rate-limited per user (10 req/hour default). Returns DocumentText.
segment_clauses(text) Splits contract text into clauses with exact character offsets. Invariant: text[c.char_start:c.char_end] == c.text. Returns list[Clause].
verify_spans(text, spans) Grounding guardrail. Verifies that clause spans still match the original text. Claude must drop any clause that fails. Returns VerificationResult.
get_risk_taxonomy() Returns the 15 risk categories with definitions and signal language. Returns dict.

Resources

Resource URI Description
clauselens://taxonomy 15 risk categories in markdown format
clauselens://severity-rubric 4-level severity scale: critical, high, medium, low

Prompt

analyze_contract(document, is_url, perspective)

Injects a full 9-step contract analysis workflow into the conversation.

Parameter Type Description
document string Contract text or URL
is_url bool Whether document is a URL to fetch
perspective string Analyzing party's perspective (e.g. "vendor", "buyer")

Connecting Claude

  1. Go to Claude.aiSettingsIntegrationsAdd MCP Server
  2. Enter the MCP URL: https://YOUR-SUBDOMAIN.railway.app
  3. Sign in with WorkOS AuthKit when prompted
  4. The ClauseLens tools, resources, and prompt will now be available in Claude

Deploy to Railway

Prerequisites

Steps

  1. Fork or clone this repository:

    git clone https://github.com/YOUR_USERNAME/clauselens-mcp.git
    cd clauselens-mcp
    
  2. Log in and link to Railway:

    railway login
    railway link
    
  3. Deploy:

    railway up
    
  4. Set environment variables in the Railway dashboard (Project → Variables):

    Variable Description
    WORKOS_CLIENT_ID WorkOS application client ID (e.g. client_01...)
    WORKOS_API_KEY WorkOS API key (e.g. sk_live_...)
    WORKOS_JWKS_URI JWKS endpoint: https://api.workos.com/sso/jwks/<client_id>
    WORKOS_AUDIENCE JWT audience claim, set to clauselens
    RATELIMIT_REQUESTS Requests per window per user (default: 10)
    RATELIMIT_WINDOW_SECONDS Rate limit window in seconds (default: 3600)
    PORT Port for the server (Railway sets this automatically; default: 8000)
    MCP_PUBLIC_URL Full public URL of the MCP endpoint, e.g. https://YOUR-SUBDOMAIN.railway.app/mcp
  5. Railway assigns a public HTTPS URL automatically. Use it as your MCP Server URL.


Local Development

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Copy .env.example and fill in your values:

    cp .env.example .env
    # edit .env with your WorkOS credentials
    
  3. Start the server:

    python server.py
    

The server will listen on http://localhost:8000/mcp by default.


Running Tests

pip install -r requirements-dev.txt
pytest -v

The test suite contains 47 tests covering tools, auth middleware, rate limiting, SSRF hardening, and schema validation.


WorkOS AuthKit Setup

  1. Go to workos.com and create an account
  2. Navigate to AuthKitApplications
  3. Create or select an application
  4. Collect the following values:
    • Client ID: shown on the application overview page
    • API Key: found under API Keys in your WorkOS dashboard
    • JWKS URI: https://api.workos.com/sso/jwks/<your-client-id>
  5. Set WORKOS_AUDIENCE to clauselens (must match the aud claim in issued JWTs)

Security

SSRF hardening: fetch_document blocks requests to private IP ranges (RFC 1918, loopback, link-local, metadata endpoints), validates schemes (HTTPS only in production), and enforces a 10-second timeout with a 2MB response cap.

No document retention: All document processing happens in-memory during the request lifecycle. No contract text, extracted content, or analysis results are stored, logged, or persisted anywhere.

Rate limiting: Per-user token-bucket rate limiter enforced in-process. Default: 10 requests per hour. Configurable via RATELIMIT_REQUESTS and RATELIMIT_WINDOW_SECONDS.

Authentication: Every request must carry a valid JWT issued by WorkOS AuthKit. Unauthenticated or invalid requests are rejected before any tool logic runs.


Disclaimer

ClauseLens provides automated information, not legal advice.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured