Skip to content

Connect Docketwise to Claude: Automate Law Firm Billing and Contacts

Learn how to connect Docketwise to Claude using a managed MCP server. Automate law firm billing, matter creation, and contact management with AI agents.

Yuvraj Muley Yuvraj Muley · · 9 min read
Connect Docketwise to Claude: Automate Law Firm Billing and Contacts

If your team needs to connect Docketwise to Claude to automate legal case management, law firm billing, or client onboarding, you need a Model Context Protocol (MCP) server. This server acts as the translation layer between Claude's natural language tool calls and Docketwise's REST APIs. You can either build and maintain this infrastructure yourself, or use a managed integration platform like Truto to dynamically generate a secure, authenticated MCP server URL. If your team uses ChatGPT, check out our guide on connecting Docketwise to ChatGPT or explore our broader architectural overview on connecting Docketwise to AI Agents.

Giving a Large Language Model (LLM) read and write access to a sprawling legal management ecosystem like Docketwise is an engineering challenge. You have to handle API token lifecycles, map highly nested JSON schemas to MCP tool definitions, and deal with Docketwise's strict relational data constraints. Every time the API updates an endpoint or changes a required field, you have to update your server code, redeploy, and test the integration.

This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Docketwise, connect it natively to Claude Desktop, and execute complex law firm workflows using natural language.

The Engineering Reality of the Docketwise API

A custom MCP server is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, the reality of implementing it against specialized B2B APIs is painful. Docketwise is built to manage complex immigration cases, nested contact relationships, and detailed billing. Its API reflects that domain complexity.

If you decide to build a custom Docketwise MCP server, here are the specific integration challenges you will face:

Mandatory Root Key Nesting Unlike modern, flat REST architectures, the Docketwise API enforces strict root-key wrapping for write operations. When you want to create a charge, you cannot simply send {"amount": 500, "status": "unpaid"}. You must wrap the payload in a root key that matches the resource name: {"charge": {"amount": 500, "status": "unpaid"}}. This pattern extends to complex objects like contacts, where nested arrays such as addresses_attributes and phone_numbers_attributes require further wrapping inside a data key. Truto's dynamically generated MCP schemas explicitly map these constraints so the LLM constructs the payload correctly on the first attempt.

Strict Relational Dependencies on Updates In many REST APIs, PATCH or PUT operations only require the ID in the URL path and the fields you wish to modify in the body. Docketwise requires relational context to be re-stated. For example, when updating an invoice, you must include the contact_id in the body payload, even if you are only updating the due date. When updating a matter, the client_id is strictly required. Your MCP server must guide Claude to fetch these foreign keys before attempting an update.

Base64 Payload Handling and Context Window Limits The Docketwise create_a_docketwise_document endpoint requires the file to be uploaded as a strict base64 string inside the document.base64_data JSON field. Pushing large base64 strings through an LLM is a fast way to blow up your context window and increase inference costs. A well-architected MCP tool for document uploads must instruct the LLM to stream or reference the file appropriately, rather than attempting to generate massive base64 strings natively.

Rate Limits and 429 Handling Docketwise enforces rate limits to protect its infrastructure. It is critical to understand that Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream Docketwise API returns an HTTP 429, Truto passes that error directly to the caller. Truto normalizes the upstream rate limit info into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF spec. The caller (or the agent orchestration framework) is strictly responsible for interpreting these headers and executing retry or backoff logic.

Generating a Docketwise MCP Server

Truto derives MCP tools dynamically from the connected integration's API endpoints and documentation. A tool only appears in the MCP server if it has a corresponding documentation entry, ensuring that Claude only sees well-documented, AI-ready operations.

You can generate an MCP server for Docketwise in two ways: via the Truto UI or programmatically via the API.

Method 1: Via the Truto UI

For teams testing workflows or deploying static desktop agents, the UI is the fastest path.

  1. Navigate to the Integrated Accounts page in your Truto dashboard and select your connected Docketwise account.
  2. Click the MCP Servers tab.
  3. Click Create MCP Server.
  4. Select your desired configuration. You can assign a human-readable name and apply filters (e.g., restrict to read methods only, or filter by specific tags like billing).
  5. Copy the generated MCP server URL (e.g., https://api.truto.one/mcp/a1b2c3d4...). This URL contains a cryptographic token that securely authenticates the connection.

Method 2: Via the Truto API

For platform engineers building multi-tenant AI products, you can generate MCP servers programmatically. This provisions a secure, scoped endpoint for a specific law firm's tenant.

Make an authenticated POST request to /integrated-account/:id/mcp:

curl -X POST https://api.truto.one/integrated-account/{integrated_account_id}/mcp \
  -H "Authorization: Bearer YOUR_TRUTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Docketwise Billing Agent",
    "config": {
      "methods": ["read", "write"],
      "tags": ["billing", "contacts"]
    },
    "expires_at": "2026-12-31T23:59:59Z"
  }'

The API will return a database record containing the url required for the MCP client to connect.

Connecting the MCP Server to Claude

Once you have your Truto MCP server URL, connecting it to Claude is a straightforward process.

Method A: Via the Claude Desktop UI

If you are using Claude Desktop or an MCP-enabled interface like ChatGPT Developer Mode:

  1. Open Settings -> Integrations (or Connectors).
  2. Click Add MCP Server (or Custom Connector).
  3. Paste the Truto MCP URL.
  4. Click Add. Claude will immediately execute an MCP initialize handshake and request the tools/list to discover the Docketwise operations.

Method B: Via Manual Configuration File

For programmatic setups or specific IDE integrations (like Cursor), you can modify your MCP configuration JSON file. Truto MCP URLs act as Server-Sent Events (SSE) endpoints.

{
  "mcpServers": {
    "docketwise-truto": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/YOUR_TRUTO_TOKEN"
      ]
    }
  }
}

Restart your client, and the tools will be instantly available to the model.

Hero Tools for Docketwise

Truto maps Docketwise's sprawling API into discrete, schema-validated tools. Here are the highest-leverage tools for automating law firm operations.

list_all_docketwise_matters

Fetches a paginated list of the firm's matters (cases). This is the starting point for almost any workflow involving case management or billing reconciliation.

Usage Note: The connector handles pagination via the X-Pagination header under the hood. For large firms, Claude should utilize the limit and next_cursor parameters exposed in the query schema to page through 200 records at a time.

"Fetch the first 50 active matters in our Docketwise account so we can audit which ones lack an assigned billing contact."

get_single_docketwise_matter_by_id

Returns deep details about a specific matter, including associated user_ids, immigration receipt numbers, client details, and notes.

Usage Note: Because list endpoints rarely return deeply nested arrays for performance reasons, use this tool when the agent needs full context on a specific case before drafting an email or generating an invoice.

"Retrieve the full details for matter ID 8912, including all notes and associated receipt numbers."

create_a_docketwise_contact

Creates a new contact (person or institution) in the CRM database.

Usage Note: Remember the root key wrapping. Claude will automatically construct the payload inside the contact key. Arrays for addresses_attributes and phone_numbers_attributes require nested data objects, which the Truto schema enforces.

"Create a new Docketwise contact for John Doe. His email is john@example.com and his phone number is 555-0199. Make sure to format the phone number array correctly based on the schema."

create_a_docketwise_invoice

Generates a new invoice for a client.

Usage Note: You must provide the contact_id in the invoice root payload. This tool creates the invoice shell; you must use the charge tools to add billable line items.

"Generate a new invoice for contact ID 4451. Set the issue date to today and the due date to Net 30."

create_a_docketwise_charge

Adds a line-item charge to an existing invoice.

Usage Note: Requires invoice_id as a query parameter. The body payload requires charge.amount, charge.status, and charge.date inside the charge root key.

"Add a $300 charge to invoice ID 10994 for 'Consultation Fee'. Mark the status as unpaid and set the charge date to today."

create_a_docketwise_note

Creates a note attached to either a matter or a contact.

Usage Note: Unlike charges and contacts, this endpoint accepts a bare body (no root key). However, you must provide either matter_id or client_id for the note to attach correctly.

"Add a note to matter ID 8912 stating: 'Client called to confirm receipt of the USCIS physical notice. Upload pending.'"

list_all_docketwise_documents

Lists the firm's documents, providing metadata about files stored in the CRM.

Usage Note: This returns metadata (size, title, associated client). If the agent needs to access the file contents, it must subsequently call get_single_docketwise_document_download_url_by_id.

"List the most recent documents uploaded for client ID 4451 to check if the passport scan has been processed."

For the complete inventory of available tools, endpoint behaviors, and exact JSON schemas, review the Docketwise integration page.

Workflows in Action

With the MCP server connected to Claude, you can orchestrate multi-step legal workflows entirely via natural language.

Scenario 1: Automated Client Intake and Case Creation

Persona: Legal Assistant

When a new client signs a retainer, the legal assistant needs to onboard them, open a matter, and log the initial consultation notes.

"We just signed Jane Smith (jane@example.com, 555-0122) for an H-1B Visa case. Please create her contact profile, open a new matter for her, and log a note on the matter that the retainer agreement is signed and filed."

Step-by-step execution:

  1. create_a_docketwise_contact: Claude constructs the payload, wrapping Jane's data in the contact root key and structuring the phone number attribute.
  2. create_a_docketwise_matter: Claude extracts the newly generated client_id from step 1 and creates the matter, wrapping the payload in the matter root key.
  3. create_a_docketwise_note: Claude uses the new matter_id from step 2 to create a bare-body note logging the retainer status.

Result: The agent autonomously chains three relational API calls, successfully handling foreign key extraction and payload formatting without human intervention.

Scenario 2: End-of-Month Billing Generation

Persona: Billing Coordinator

A billing coordinator needs to track down unbilled time and generate invoices for active cases.

"Find the matter details for the 'TechCorp L-1 Transfer' case. Once you find the client ID, generate a new invoice for them with today's date, and add a single charge of $1,500 for 'Premium Processing Prep'."

sequenceDiagram
    participant User
    participant Claude as Claude Desktop
    participant MCP as Truto MCP Server
    participant Upstream as "Docketwise API"

    User->>Claude: "Find TechCorp L-1 Transfer case..."
    Claude->>MCP: Call list_all_docketwise_matters
    MCP->>Upstream: GET /matters
    Upstream-->>MCP: Returns matter array
    MCP-->>Claude: Returns matter data (extracts client_id)
    Claude->>MCP: Call create_a_docketwise_invoice (client_id)
    MCP->>Upstream: POST /invoices (invoice wrapped)
    Upstream-->>MCP: Returns invoice_id
    MCP-->>Claude: Returns invoice_id
    Claude->>MCP: Call create_a_docketwise_charge (invoice_id)
    MCP->>Upstream: POST /charges (charge wrapped)
    Upstream-->>MCP: Returns 201 Created
    MCP-->>Claude: Success confirmation
    Claude-->>User: "Invoice created and $1500 charge added."

Step-by-step execution:

  1. list_all_docketwise_matters: Claude searches the matters list for "TechCorp L-1 Transfer" to identify the correct client_id.
  2. create_a_docketwise_invoice: Claude generates the invoice shell using the discovered client_id.
  3. create_a_docketwise_charge: Claude takes the resulting invoice_id and attaches the $1,500 line item, ensuring the charge wrapper and required fields are present.

Result: The LLM navigates a complex relational schema to generate billable artifacts with zero manual data entry.

Security and Access Control

Exposing financial and sensitive legal data to an LLM requires strict governance. Truto MCP servers provide several layers of access control out of the box:

  • Method Filtering (methods): Restrict a server to read-only operations (e.g., methods: ["read"]) to prevent an AI agent from accidentally modifying contacts or issuing rogue invoices.
  • Tag Filtering (tags): Scope servers by business domain. You can create a server strictly for billing tools and another strictly for CRM tools, ensuring agents adhere to the principle of least privilege.
  • Secondary Authentication (require_api_token_auth): By default, the MCP token URL is all that is required to connect. By setting this flag to true, the client must also pass a valid Truto API token in the Authorization header, adding a mandatory identity check.
  • Automatic Expiration (expires_at): For temporary workflows - like granting a contract paralegal access to an AI agent for a specific project - you can set a hard TTL on the server. Once the timestamp passes, the server URL automatically expires and all credentials are revoked.
  • Upstream Rate Limiting: Truto normalizes X-RateLimit headers into standard IETF formats but does not absorb or retry rate limit errors. If Docketwise throws an HTTP 429, the error is passed back to Claude. Your agent framework must implement its own backoff logic.

Connecting Docketwise to Claude transforms static legal software into an active, conversational participant in your firm's workflows. By leveraging managed MCP servers, engineering teams can bypass the boilerplate of OAuth tokens, nested payload mapping, and schema drift, giving LLMs native, secure access to law firm data in minutes.

FAQ

How does Truto handle Docketwise rate limits?
Truto passes HTTP 429 Too Many Requests errors directly to the caller and standardizes the upstream rate limit headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). The caller is responsible for implementing retry and backoff logic.
Can I prevent Claude from deleting cases or invoices?
Yes. When creating the Truto MCP server, you can set the config methods array to ["read", "update"] or ["read"], which filters out any delete operations before the tools are exposed to the LLM.
Why does the LLM need to wrap payloads for Docketwise?
The Docketwise API requires strict root-key wrapping for write operations (e.g., sending charge data inside a {"charge": {...}} object). Truto's dynamically generated MCP schemas instruct the LLM to format these nested payloads correctly.
Does Truto cache my Docketwise data?
No. Truto operates as a real-time pass-through proxy. Tool calls execute against the live Docketwise API, and Truto does not store or cache the customer records passing through the connection.

More from our Blog