> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uselim.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Set up lim as a Model Context Protocol server for AI agents.

# MCP Server

lim includes a native [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server. Any MCP-compatible AI client -- Claude Code, Claude Desktop, Cursor, or custom agents -- can connect to lim and perform accounting operations.

## Quick Setup

Register lim as an MCP server with a single command:

```bash theme={null}
npx @lim-labs/lim mcp add
```

This adds lim to your MCP configuration file (`~/.config/claude/claude_desktop_config.json` or `.claude/mcp.json` depending on your client).

The generated configuration looks like:

```json theme={null}
{
  "mcpServers": {
    "lim": {
      "command": "npx",
      "args": ["@lim-labs/lim", "mcp", "serve"],
      "env": {
        "LIM_API_URL": "https://api.uselim.com",
        "LIM_COMPANY_ID": "your-company-id"
      }
    }
  }
}
```

<Tip>
  Run `lim auth login` first to ensure you have valid credentials. The MCP server uses the same
  authentication token as the CLI.
</Tip>

### Manual Configuration

If you prefer to configure manually:

<CodeGroup>
  ```json Claude Desktop theme={null}
  // ~/.config/claude/claude_desktop_config.json
  {
    "mcpServers": {
      "lim": {
        "command": "npx",
        "args": ["@lim-labs/lim", "mcp", "serve"],
        "env": {
          "LIM_COMPANY_ID": "your-company-id"
        }
      }
    }
  }
  ```

  ```json Claude Code theme={null}
  // .claude/mcp.json (in your project root)
  {
    "mcpServers": {
      "lim": {
        "command": "npx",
        "args": ["@lim-labs/lim", "mcp", "serve"]
      }
    }
  }
  ```
</CodeGroup>

## MCP Resources

Resources are read-only data that AI agents can access for context. They do not modify any data.

### trial-balance

```
URI: lim://company/{companyId}/trial-balance
```

Returns the current trial balance -- all account balances for the current fiscal year. The agent uses this to understand the company's financial position.

**Example interaction:**

```
You: What's our current cash position?

Claude: Let me check the trial balance.
        [Reads lim://company/.../trial-balance]

        Your current cash position:
        - Cash: ¥2,450,000
        - Checking account: ¥1,800,000
        - Total liquid: ¥4,250,000
```

### accounts

```
URI: lim://company/{companyId}/accounts
```

Returns the full chart of accounts with codes, names, types, and normal balance directions. Essential for the agent to know which accounts exist when creating journal entries.

### journal-entries

```
URI: lim://company/{companyId}/journal-entries
```

Returns recent journal entries. The agent uses this to understand transaction patterns and verify its own work.

### bank-transactions

```
URI: lim://company/{companyId}/bank-transactions
```

Returns bank transactions, including unmatched ones that need classification. This is the primary input for autonomous bookkeeping.

### alerts

```
URI: lim://company/{companyId}/alerts
```

Returns currently triggered alerts (cash runway low, unusual spending, budget overrun, etc.). The agent can proactively notify humans about issues.

### cash-runway

```
URI: lim://company/{companyId}/cash-runway
```

Returns cash runway calculation: current cash balance, monthly burn rate, and estimated months remaining. Computed from the last 3 months of data.

**Example response:**

```json theme={null}
{
  "cashBalance": 2450000,
  "monthlyBurn": 710000,
  "runwayMonths": 3.5,
  "calculatedAt": "2026-03-16T10:00:00Z"
}
```

### scenario diff

```
URI: lim://company/{companyId}/scenario/{scenarioId}/diff
```

Returns the impact of a scenario on the trial balance. Shows what changes if the scenario's virtual entries were real.

## MCP Tools

Tools are actions that modify data. Each tool call creates audit-logged events.

### create\_journal\_entry

Create a new journal entry with explicit debit/credit lines.

**Input schema:**

```json theme={null}
{
  "effectiveDate": "2026-03-16",
  "sourceType": "manual",
  "memo": "AWS monthly bill",
  "lines": [
    { "side": "debit", "accountId": "uuid-of-communication", "amount": 10000 },
    { "side": "debit", "accountId": "uuid-of-input-vat", "amount": 1000 },
    { "side": "credit", "accountId": "uuid-of-accounts-payable", "amount": 11000 }
  ]
}
```

**Example interaction:**

```
You: Record that we paid ¥55,000 for office rent this month.

Claude: I'll create the journal entry.
        [Reads lim://company/.../accounts to find account IDs]
        [Calls create_journal_entry]

        Done! Recorded:
          Debit  Rent expense (7101)     50,000
          Debit  Input VAT (1501)         5,000
          Credit Cash (1101)             55,000
```

<Warning>
  Total debits must equal total credits. The tool will return an error if the entry doesn't balance.
</Warning>

### match\_bank\_transaction

Run the 3-step judgment engine on a bank transaction to suggest the correct journal entry.

**Input schema:**

```json theme={null}
{
  "transactionId": "uuid-of-bank-transaction"
}
```

**Returns:** A judgment result with the suggested account classification, confidence score, and which step resolved it (rule, history, AI, or escalated).

**Example interaction:**

```
You: Process the unmatched bank transactions.

Claude: Let me check the unmatched transactions.
        [Reads lim://company/.../bank-transactions]

        Found 3 unmatched transactions:
        1. ¥11,000 to AWS — [match_bank_transaction] → Rule match (91%)
           → Communication ¥10,000 + Input VAT ¥1,000
        2. ¥3,300 to Amazon — [match_bank_transaction] → History match (78%)
           → Supplies ¥3,000 + Input VAT ¥300
        3. ¥150,000 to "TANAKA" — [match_bank_transaction] → Escalated
           → Could not classify. Needs human review.

        Shall I post entries 1 and 2?
```

### generate\_scenario

Generate virtual journal entries for a scenario (e.g., "What if we hire 2 engineers?").

**Input schema:**

```json theme={null}
{
  "scenarioId": "uuid-of-scenario"
}
```

### apply\_scenario

Promote a scenario's virtual entries to real journal entries. This is irreversible.

**Input schema:**

```json theme={null}
{
  "scenarioId": "uuid-of-scenario"
}
```

**Example interaction:**

```
You: We decided to go ahead with the new hire. Apply the scenario.

Claude: [Calls apply_scenario with the scenario ID]

        Done! The scenario "Hire Senior Engineer" has been applied.
        3 journal entries were created:
        - Monthly salary: ¥600,000/month
        - Social insurance: ¥90,000/month
        - Equipment: ¥300,000 (one-time)

        Your updated runway is now 2.8 months (was 3.5).
```

## Combining Resources and Tools

The real power of MCP is combining reads and writes in a single conversation:

```
You: How's the company doing this month?

Claude: [Reads trial-balance, cash-runway, alerts, bank-transactions]

        Here's your March summary:
        - Revenue: ¥1,100,000 (+5% vs February)
        - Expenses: ¥680,000 (-2% vs February)
        - Cash runway: 3.5 months
        - 2 unmatched bank transactions
        - No active alerts

        Want me to process the unmatched transactions?

You: Yes, go ahead.

Claude: [Calls match_bank_transaction for each]
        [Calls create_journal_entry for high-confidence matches]

        Done. Both transactions processed:
        1. AWS ¥11,000 → Communication (rule match, auto-posted)
        2. Zoom ¥2,200 → Communication (AI inference, 85% confidence)

        #2 was a new vendor. I've created a matching rule for "Zoom"
        so it'll be instant next time.
```

## Troubleshooting

### "Company not found" error

Make sure `LIM_COMPANY_ID` is set in your MCP configuration or that you've run `lim companies use <id>`.

### "Unauthorized" error

Your auth token may have expired. Run `lim auth login` to refresh it.

### Tools not appearing

Restart your MCP client after adding the lim server. Most clients require a restart to pick up new MCP servers.
