Legacy Billing MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Legacy Billing MCP Server calculate an invoice for customer with ID 9876 for March 2024"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
legacy-mcp-bridge
A small, complete example of making a legacy system agent-operable:
an untyped 2014-era billing module (
legacy/billing.js) is wrapped, not rewrittena typed anti-corruption layer and hexagonal ports isolate it
a modern replacement is introduced with the Strangler Fig pattern (
legacy→shadow→modern)characterization tests pin the legacy behaviour, quirks included, so refactoring can't change invoices
a Model Context Protocol (MCP) server exposes the system to AI agents as typed, validated, read-only tools
an agent context layer (
AGENTS.md,.claude/commands) tells agents the rules of the codebase
Architecture
AI agent (Claude, Cursor, ...)
│ MCP (stdio, JSON-RPC)
┌────────▼─────────┐
│ src/mcp/server │ zod input/output contracts, tool errors
└────────┬─────────┘
│ InvoiceCalculator port
┌────────────▼─────────────┐
│ StranglerInvoiceCalculator│ MIGRATION_MODE = legacy | shadow | modern
└──────┬────────────┬──────┘
│ │
LegacyInvoiceCalculator ModernInvoiceCalculator
(anti-corruption layer) (pure, typed, injected)
│
legacy/billing.js ← frozen, never editedLayer | File | Responsibility |
Contracts |
| zod schemas = single source of truth for types and MCP tool schemas |
Ports |
| interfaces the core depends on |
Legacy adapter |
| translates untyped legacy data and error codes into domain types |
Modern adapter |
| clean reimplementation, named constants, no globals |
Strangler facade |
| routes traffic; in |
Composition root |
| the only place that wires concrete classes (DI) |
MCP adapter |
| tools for agents |
Related MCP server: BillingEngine MCP server
MCP tools
Tool | What it does |
| all customers and their pricing tier |
| one customer by id |
| subtotal, tier discount, 18% VAT, shipping, total, through the strangler facade |
| runs legacy and modern on the same order and reports whether they match |
Every tool has an input and output schema and readOnlyHint. Unknown customers return a tool error that tells the agent how to recover (Call list_customers to see valid ids) instead of crashing.
Pinned legacy quirks
Characterization tests document behaviour that is surprising but that customers' invoices depend on. They are kept until the business decides otherwise:
tier codes are case-sensitive: customer 4 has tier
g, so gets no gold discountnegative quantities are silently treated as 0
the bulk discount (2% at qty ≥ 10) is applied per line, before rounding
the subtotal is a raw float sum and is not rounded
shipping is not taxed; it is free above 1000 after discount, and 0 for empty orders
A seeded property test also checks that the modern calculator matches legacy exactly on 5,000 random orders.
Run it
npm install
npm test # characterization + MCP contract tests
npm run buildAdd it to an MCP client (for example Claude Code, Claude Desktop or Cursor):
{
"mcpServers": {
"legacy-billing": {
"command": "node",
"args": ["/absolute/path/to/legacy-mcp-bridge/dist/src/index.js"],
"env": { "MIGRATION_MODE": "shadow" }
}
}
}Or with Claude Code:
claude mcp add legacy-billing --env MIGRATION_MODE=shadow -- node dist/src/index.jsMigration playbook
legacy: wrap the old module behind a port; write characterization tests against it.
shadow: build the modern implementation; run both on every call, serve legacy, log mismatches.
modern: when shadow logs are clean and the tests pass, switch the flag.
Delete the legacy adapter and module once nothing routes to them.
License
MIT
Available Tools
4 toolscalculate_invoiceCalculate invoiceBRead-onlyIdempotent
Calculate subtotal, tier discount, 18% VAT, shipping and total for an order. Routed through the strangler facade (legacy, shadow or modern implementation).
Inputs: items (required), customerId (required). Returns: tax, total, discount, shipping, +1 more
compare_implementationsCompare legacy vs modernARead-onlyIdempotent
Run the order through BOTH the legacy and the modern calculator and report whether they agree. Use this to verify a refactor before switching MIGRATION_MODE to modern.
Inputs: items (required), customerId (required). Returns: match, legacy, modern
get_customerGet customerBRead-only
Get one customer by id.
Inputs: customerId (required). Returns: id, name, tier, country
list_customersList customersARead-only
List all customers with their pricing tier.
Inputs: no named parameters. Returns: customers
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
The two customer tools (list vs get-by-id) are clearly separated, and calculate_invoice vs compare_implementations have distinct purposes spelled out in their descriptions. There is minor conceptual overlap since compare_implementations implicitly runs both calculators, so an agent might pick calculate_invoice when it really wanted verification, but the descriptions mitigate this.
All four tools follow a clean snake_case verb_noun pattern (list_customers, get_customer, calculate_invoice, compare_implementations). The verbs are conventional and predictable for their actions.
Four tools is thin for a server labeled 'Billing'; the surface is essentially read-customers plus invoice math plus a migration check. The count is defensible for a narrow strangler-facade migration service, but feels borderline minimal for the stated domain.
Customers are read-only (no create/update) and there is no invoice persistence or retrieval — only calculation — plus no order or payment operations. The calculation and migration-verification path is well covered, but the broader billing lifecycle has notable gaps.
Maintenance
Related MCP Connectors
Time tracking and invoicing for AI agents and their humans: track, log and bill work by agent.
Quote-to-cash tools: parse invoices and POs, match POs to invoices, collection emails, billing math.
Create invoices, clients, and Stripe payment links from any agent. 7 tools. No email or deletes.
Backend for AI agents: one batched tool over ~668 actions (hosting, storage, auth, payments).
Related MCP Servers
- AlicenseAqualityCmaintenanceLets an AI agent list reports, start and poll exports, and look up insurance claims from a legacy system that has no API, with each server process serving only the tools and report types its role permits. Every tool call is written to an append-only, field-masked audit log, and the backend's login credentials stay in an encrypted vault the model never sees.3MIT
- AlicenseAqualityBmaintenanceEnables MCP clients such as Claude and Cursor to manage customers, create and update draft invoices, list or download invoices as PDF and XML e-invoices, and record and list payments in a BillingEngine account. It runs locally with your API key and never deletes data.1090 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables an LLM to query and manage customers and invoices—listing clients, searching invoices by status, computing outstanding debt, creating invoices, and marking them paid—through a closed set of server-validated tools without direct database access. Business rules such as amount limits, accumulated daily caps, and input validation are enforced server-side to resist prompt injection and misuse.MIT
- AlicenseNot gradedqualityCmaintenanceExposes five typed tools over stdio for a small wholesaler's back office, letting an agent search suppliers, filter purchase orders and invoices, save email drafts, and move invoice statuses under enforced business rules. Write actions require explicit human confirmation and every change is audit-logged.MIT