Skip to main content
Glama

cpl-mcp

CI Python Coverage

MCP server for the New York State Criminal Procedure Law (CPL). Wraps the NY Senate OpenLegislation API so any MCP client can look up CPL sections by citation and search the CPL by keyword.

Installation

With uv (recommended):

uvx cpl-mcp

With pip:

pip install cpl-mcp
python -m cpl_mcp.server

Related MCP server: tr-eli-mcp

Auth setup

The server requires a free OpenLegislation API key.

  1. Go to https://legislation.nysenate.gov and click Sign up for an API Key.

  2. Fill in the form — the key is emailed to you within a few minutes.

  3. Set the environment variable before starting the server:

export NYS_LEG_API_KEY="your-key-here"

Or put it in a .env file in the project root — the server loads it automatically:

NYS_LEG_API_KEY=your-key-here

Claude Desktop config

Add the following to claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows):

{
  "mcpServers": {
    "cpl": {
      "command": "uvx",
      "args": ["cpl-mcp"],
      "env": {
        "NYS_LEG_API_KEY": "your-key-here"
      }
    }
  }
}

If you prefer a local checkout instead of uvx:

{
  "mcpServers": {
    "cpl": {
      "command": "uv",
      "args": [
        "--directory", "/absolute/path/to/cpl-mcp",
        "run", "python", "-m", "cpl_mcp.server"
      ],
      "env": {
        "NYS_LEG_API_KEY": "your-key-here"
      }
    }
  }
}

Environment variables

Variable

Required

Description

NYS_LEG_API_KEY

Yes

OpenLegislation API key. Get one at https://legislation.nysenate.gov.

Tools

Tool

Description

cpl_lookup_section

Retrieve the full text of a CPL section or article by citation (e.g. 245.20, A245).

cpl_search

Full-text keyword search across the CPL. Returns a ranked list of matching sections with snippets.

cpl_lookup_section

Use when you know the section number. Accepts flexible citation formats — CPL § 245.20, section 245.20, and 245.20 all resolve to the same location. Returns the statute text, active date, structural breadcrumb (article/title parents), and a link to the official nysenate.gov page.

Use when searching by topic rather than citation. Supports pagination via limit (1–50, default 10) and offset (1-based, default 1).

Both tools accept a response_format parameter: "markdown" (default, human-readable) or "json" (machine-readable, useful for chaining tools).

Running locally

# one-shot lookup — no MCP client needed
python -m cpl_mcp.server --selftest 245.20

# one-shot lookup + keyword search
python -m cpl_mcp.server --selftest 245.20 --search "speedy trial"

# HTTP transport for debugging (listens on 127.0.0.1:8000)
python -m cpl_mcp.server --http

Available Tools

2 tools
cpl_lookup_sectionA
Read-onlyIdempotent

Retrieve the full text of a single New York Criminal Procedure Law (CPL) location by citation.

Use this when the user names a specific CPL section or article (e.g. "What does CPL 245.20 say?", "pull up CPL section 510.10"). It returns the official statute text plus its title and structural context (article/title parents and adjacent sections). It does NOT search by topic — use cpl_search for that.

Args: params (LookupInput): Validated input containing: - citation (str): A CPL location id such as "245.20", "1.20", "A245", or "T1". Leading "CPL", "section", and "§" are stripped automatically. - response_format (ResponseFormat): "markdown" (default) or "json".

Returns: str: In markdown mode, a formatted document with the section title, citation, full statute text, structural breadcrumb, and a source link. In json mode, an object with this schema: { "lawId": str, # "CPL" "locationId": str, # e.g. "245.20" "docType": str, # e.g. "SECTION", "ARTICLE", "TITLE" "title": str, # human title, e.g. "Automatic discovery" "activeDate": str, # ISO date this version became active "text": str, # full statute text "parents": [ {"docType": str, "docLevelId": str, "title": str} ], "sourceUrl": str # canonical nysenate.gov page }

On failure, a string beginning with "Error:".

Examples: - Use when: "Show me CPL 245.20" -> citation="245.20" - Use when: "What's in article 245 of the CPL?" -> citation="A245" - Don't use when: "Which CPL section covers discovery?" (use cpl_search instead)

Inputs: params (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: cpl_lookup_section retrieves specific sections by citation, while cpl_search performs full-text topic searches. Each explicitly states when to use the other, leaving no ambiguity.

    Naming Consistency5/5

    Both tools follow a consistent 'cpl_' prefix followed by a verb or verb_noun (lookup_section, search). The naming clearly signals the action and domain, and the pattern is uniform.

    Tool Count4/5

    The server has only two tools, which feels thin for a general API but is appropriate for a focused legal statute lookup service. The two tools cover the essential search-and-retrieve workflow and earn their place.

    Completeness4/5

    The pair covers the key user journeys: finding a section by topic and reading a section by citation. A minor gap is the lack of a browse or list-all-articles tool, but search and citation lookup handle most practical needs.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      An MCP server for accessing Turkish legislation (laws, regulations, decrees) via the Adalet Bakanligi API, providing search, full-text retrieval, and structured citations.
      5
      62 PyPI
      2
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for Australia's Federal Register of Legislation. Enables searching and fetching Commonwealth Acts with verifiable citations.
      3
      91 PyPI
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server for the Revised Code of Washington (RCW) that enables retrieving full statutory text by citation, searching for citations by partial reference, and finding bills that affect a given citation.
      3
      MIT