Skip to main content
Glama
tally-compliance-mcp

tally-compliance-mcp

by Rihu20
README.md
# tally-compliance-mcp

> **Pre-filing compliance health check for TallyPrime books, inside Claude.**

[![CI](https://github.com/Rihu20/tally-compliance-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Rihu20/tally-compliance-mcp/actions)
![Python](https://img.shields.io/badge/python-3.10%2B-blue) ![License: MIT](https://img.shields.io/badge/license-MIT-green) ![MCP](https://img.shields.io/badge/MCP-server-purple)

An [MCP](https://modelcontextprotocol.io) server that connects Claude (Claude Desktop, Claude Code or any MCP
client) to **TallyPrime** and runs **read-only** checks on your books before you file GST, TDS and income-tax
returns. Ask in plain English or Hinglish. Claude calls the checks and explains what to fix, voucher by voucher.

Each finding has a **severity** (HIGH / MEDIUM / LOW), the **voucher** (date, number, party, amount), the
**rule broken**, its **legal source**, and a **suggested fix**.

## Why read-only matters

Your books are your client's legal record. This server **never writes to Tally**:

- Every request passes through a guard (`tallypy`'s `is_import_request`) that refuses anything containing an
  Import request, `TALLYMESSAGE` or `IMPORTDATA`, *before* it reaches the network.
- tallypy's `create_ledger` / `post_voucher` are disabled in the client used here.
- Tests prove it: all 14 tools are run through MCP against a mock Tally and every HTTP body is captured; none
  is a write. Another test scans the source code for any write-request builder.

If Claude asks it to "fix" something, it can only *tell you* how. You make the change in Tally yourself.

## What it checks (14 tools)

| # | Tool | What it finds |
|---|------|---------------|
| 1 | `tally_status` | Tally reachable? open companies, Tally version, books period |
| 2 | `check_party_gstins` | invalid / missing GSTIN or PAN in party ledgers; GSTIN state ≠ ledger state |
| 3 | `check_gst_tax_type` | IGST on an intra-state supply, CGST+SGST on an inter-state supply |
| 4 | `check_old_gst_rates` | 12% / 28% used on vouchers dated on/after 22-09-2025 (GST 2.0) |
| 5 | `check_hsn` | stock items / sales lines with no HSN, or fewer digits than your turnover needs |
| 6 | `check_tds_missed` | party-wise FY-to-date expenses per section (194C, 194J, 194I, 194H, 194Q, 194T, 194A) above the threshold with no or short TDS. **Unmapped expense ledgers are listed, never guessed.** |
| 7 | `check_cash_payments` | cash paid to one party in a day above ₹10,000 (Sec 40A(3)); cash received ₹2,00,000 or more (Sec 269ST) |
| 8 | `check_msme_43bh` | MSME bills unpaid beyond 45 days (15 without a written agreement), Sec 43B(h) |
| 9 | `check_duplicates` | same supplier invoice number entered twice; same amount + date + party |
| 10 | `check_negative_balances` | cash negative on any date; debtors in credit; creditors in debit |
| 11 | `reconcile_2b` | Tally purchases vs a GSTR-2B JSON file (via gst-recon): summary + Excel |
| 12 | `build_gstr1` | GSTR-1 JSON from Tally sales for a month (via gstr1-builder) + error report |
| 13 | `upcoming_due_dates` | filings due in the next N days (via india-fy) |
| 14 | `health_report` | runs checks 2–10, gives a 0–100 score, lists the HIGH findings and writes an Excel workbook (one sheet per check + summary). `include_details=true` also returns every finding. |

Prompts: **`monthly_gst_review`**, **`tds_review`**, **`pre_audit_checklist`**. These chain the tools for you.

Large books are read **one month at a time** (each month cached), so a full year never loads in one request.

## Setup

### 1. Turn on TallyPrime's XML port

1. Open TallyPrime and load your company.
2. Press **F1 (Help) → Settings → Connectivity**.
3. Open **Client/Server configuration**.
4. Set **TallyPrime acts as** = **Both** (or **Server**), and **Port** = **9000**.
5. Save (Ctrl+A) and **restart TallyPrime**. Keep it open with the company loaded while you use Claude.

### 2. Install

Python 3.10+ is required.

```bash
pip install git+https://github.com/Rihu20/tally-compliance-mcp
```

> **Note:** the engine packages (`tallypy`, `indian-tax-ids`, `gst-calc-india`, `hsn-sac-india`, `tds-calc-india`,
> `gst-recon`, `gstr1-builder`, `india-fy`) are installed **from GitHub** until they are published on PyPI.
> Then `pyproject.toml` will switch to their PyPI names, e.g. `tallypy>=0.1`.

### 3. Configure (optional but recommended)

Copy [`src/tally_compliance_mcp/data/config.yaml`](src/tally_compliance_mcp/data/config.yaml) to e.g.
`C:\Users\<you>\tally-compliance\config.yaml` and set at least:

```yaml
tally: {company: "Patmon Industries Pvt Ltd"}      # empty = first open company
company: {gstin: "27AAACR5055K1Z7", fy: "2025-26", aato_crore: 12}
output_folder: "C:/Users/<you>/Documents/Tally Compliance"
tds:
  ledger_sections:                                   # YOUR expense ledgers -> TDS section
    Freight Charges: "194C"
    Professional Fees: "194J_PROF"
    Rent: "194I_LB"
  tds_ledger_sections: {"TDS Payable - 194C": "194C"}
msme_43bh:
  parties: [{name: "Kumar Suppliers", agreement: false}]
```

### 4a. Claude Desktop (Windows)

Edit `%APPDATA%\Claude\claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "tally-compliance": {
      "command": "C:\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python312\\Scripts\\tally-compliance-mcp.exe",
      "args": ["--config", "C:\\Users\\<you>\\tally-compliance\\config.yaml"]
    }
  }
}
```

(Or `"command": "python", "args": ["-m", "tally_compliance_mcp", "--config", "..."]`.) Restart Claude Desktop.

### 4b. Claude Code

```bash
claude mcp add tally-compliance -- tally-compliance-mcp --config C:\Users\<you>\tally-compliance\config.yaml
```

### 4c. One-click Claude Desktop extension (.mcpb)

See [`mcpb/README.md`](mcpb/README.md). `python scripts/build_mcpb.py` builds `tally-compliance-mcp.mcpb`.
Double-click it to install, then fill in host, port, company and GSTIN in Claude Desktop.

## Ask Claude

1. "Is Tally connected? Which companies are open?"
2. "Patmon ki October ki books check karo."
3. "Run a health report for October 2025 and tell me what to fix first."
4. "Kis party ka TDS nahi kata is saal? 194C aur 194J dekh lo."
5. "Find vouchers where IGST was charged on a local sale."
6. "Kya 22 September ke baad kahin 12% ya 28% GST laga hai?"
7. "Which stock items have missing or short HSN codes?"
8. "Cash mein 10,000 se zyada payment ya 2 lakh se zyada receipt hui hai kya?"
9. "Reconcile October purchases with C:\Downloads\GSTR2B_102025.json."
10. "Build my GSTR-1 for October 2025 and show the errors."
11. "MSME suppliers ko 45 din se zyada ka payment pending hai kya?"
12. "Agle 15 din mein kaunse returns due hain?"

## Sample health report

![Health report screenshot](docs/health_report_screenshot.png)
*(placeholder. Add a screenshot of the Excel workbook or Claude's answer here.)*

Try it without Tally: `python scripts/demo_end_to_end.py` starts a mock TallyPrime with sample books (one example
of every problem), runs the server over stdio like Claude Desktop does, and prints the score.

## Errors you may see

| Message | Meaning |
|---------|---------|
| `tally_not_reachable` | Tally is not running, or its XML/HTTP port is off. See step 1. |
| `no_company_open` | No company loaded (or the one in config isn't open) |
| `not_tally_xml` | Something else answered on that port |
| `educational_mode` | TallyPrime Educational mode allows only dates 1, 2 and 31 of a month |

## Limits

- Findings are **pointers for a professional to verify**, not legal advice. Rules and thresholds are in
  `config.yaml` / the engine packages with sources; see [VERIFY.md](VERIFY.md).
- GST rate and tax head are worked out from **ledger names** (`CGST`, `SGST`, `IGST`, `TDS` …, configurable)
  and voucher totals. A voucher with several rates shows its average rate.
- TDS uses your **ledger → section mapping**. Thresholds are counted from the FY start to the period end.
- Each tool reply lists at most **40 findings** (`reply.max_findings`); the counts always include every
  finding, and `health_report`'s Excel workbook lists them all. Very large single replies were seen to stall the
  stdio connection on Windows, so the cap keeps replies small.
- On PCs where antivirus scans every Python file, the first tool call can take a minute while packages load.
  `--prewarm` loads them before the server starts serving instead (slower start, faster first call).
- Uses MCP Python SDK **1.x (FastMCP)**. SDK 2.x renamed FastMCP; see GOOD_FIRST_ISSUES.md.

## हिंदी सारांश

`tally-compliance-mcp` Claude को आपके TallyPrime से जोड़ता है और GST, TDS और इनकम-टैक्स रिटर्न फ़ाइल करने
से पहले आपकी किताबों की जाँच करता है — गलत GSTIN/PAN, IGST बनाम CGST+SGST की गलती, 22-09-2025 के बाद
12%/28% रेट, HSN की कमी, TDS न कटना, ₹10,000 से ज़्यादा कैश पेमेंट, MSME को 45 दिन से देर, डुप्लिकेट वाउचर,
नेगेटिव कैश। यह **सिर्फ़ पढ़ता है, Tally में कुछ नहीं लिखता**। हिंदी या हिंग्लिश में पूछिए:
"Patmon ki October ki books check karo"।

## Contributing

New checks are very welcome (RCM liability, e-way bill, 194R …). See [CONTRIBUTING.md](CONTRIBUTING.md) and
[GOOD_FIRST_ISSUES.md](GOOD_FIRST_ISSUES.md). Every new check needs: a planted example in
`testing/sample_books.py`, a test that finds it, the clean-books test still passing, and any legal number in
`config.yaml` with `source` and `last_verified`. **Never** add code that writes to Tally.

## License

MIT © Himanshu Dhyani. Tally and TallyPrime are trademarks of Tally Solutions Pvt. Ltd.; this project is not
affiliated with them.

TDQS

B3.1/5.0

Scored across 14 tools

Disambiguation5/5

Each check_* tool targets one distinct statutory rule (GSTIN validity, tax type, old rates, HSN, TDS, cash limits, MSME 43B, duplicates, negative balances), so an agent can map a compliance concern to exactly one tool. The two exceptions are clearly disambiguated by their descriptions: health_report is explicitly an aggregator that runs all checks, and reconcile_2b vs build_gstr1 are opposite directions (inbound GSTR-2B match vs outbound GSTR-1 generation).

Naming Consistency4/5

Eight tools share a clean check_<rule> prefix and everything is snake_case, so the pattern is very readable. Minor deviations exist: health_report and tally_status are noun-first rather than verb-first, and upcoming_due_dates is adjectival, but these are intuitive and do not hamper selection.

Tool Count5/5

Fourteen tools sit comfortably in the well-scoped 3-15 range, and each one corresponds to a separate compliance rule, export, or diagnostic step rather than being filler. The aggregator (health_report) plus individual checks is a deliberate and useful layering, not duplication bloat.

Completeness4/5

The surface covers the core compliance lifecycle well: connectivity (tally_status), point checks across GST/TDS/cash/MSME/ledger integrity, purchase reconciliation (reconcile_2b), GSTR-1 generation, due dates, and a rolled-up health report. Gaps remain for GSTR-3B/ITC summarization or annual returns and for any remediation/export of corrected data, but agents can work around these.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues