InvoiceX-Ray
An MCP server for detecting Trade-Based Money Laundering (TBML) in Indian trade finance, cross-referencing invoices against commodity benchmarks, customs records, and regulatory timelines to identify over/under-invoicing, phantom shipments, and duplicate financing.
README
InvoiceX-Ray β TBML Detection MCP Server
Trade-Based Money Laundering (TBML) Detection Agent for Indian AD-Bank Trade Finance under FEMA 2026
Built with Nitrostack SDK Β· Model Context Protocol (MCP) Β· TypeScript Β· PostgreSQL / Supabase
π Overview & Problem Statement
InvoiceX-Ray is a specialized Model Context Protocol (MCP) server that empowers AI agents and compliance officers to detect Trade-Based Money Laundering (TBML) in Letter of Credit (LC) and Export-Import finance.
What It Does
Unlike simple document OCR or basic text summarizers, InvoiceX-Ray is a multi-layered cross-referencing engine. It identifies the structural manipulation gap in trade transactions β over/under-invoicing, phantom shipments, duplicate billing, and illegal offshore capital flight β by cross-analyzing declared invoice valuations against independent commodity benchmarks, customs records, and regulatory timelines simultaneously.
The FEMA 2026 Regulatory Environment
Under India's Foreign Exchange Management (Export and Import) Regulations, 2026 (effective October 1, 2026):
- Tightened Realization Windows: Strict timelines for export proceed realizations monitored via RBI's EDPMS/IDPMS networks.
- Severe Financial Exposure: Section 13 mandates penalties up to 300% of transaction value for unauthorized delays or valuation manipulation.
- Bank Liability: Authorized Dealer (AD) Category-I banks carry direct regulatory liability for every unflagged trade transaction.
π Key Features & Innovations
-
Counterfactual Valuation Engine Instead of presenting abstract percentages, InvoiceX-Ray generates a concrete Counterfactual View:
"This shipment declares $1,475,000 for 500 oz of Gold Bullion ($2,950/oz). At the current market spot benchmark of $2,200/oz, the shipment should cost $1,100,000. The $375,000 gap is the suspected illicit capital flight transfer."
-
Dynamic AI Commodity Benchmarking
- World Bank API Integration: Live macroeconomic inflation scaling (
FP.CPI.TOTL.ZG) dynamically adjusts commodity benchmark baselines. - On-the-Fly Benchmark Generation: If a commodity benchmark is missing from the database, the server queries Groq AI (
llama-3.3-70b-versatile) to calculate realistic spot prices and 90-day distribution statistics, automatically saving and caching them to PostgreSQL.
- World Bank API Integration: Live macroeconomic inflation scaling (
-
Multi-Verification Toolset (11 MCP Tools)
- DGFT IEC Validation: Verifies Importer-Exporter Code caution-listing status via registrar records.
- ICEGATE Customs Verification: Detects weight discrepancies between invoice declarations and port container weights.
- OpenSanctions PEP/Sanction Check: Live API screening against global watchlists (OFAC, UN, EU).
- Maritime Route Feasibility: Evaluates geospatial routing anomalies (e.g. vessel shipments to landlocked destinations like Zurich).
- Double-Financing Detection: Cross-checks shipping bills across different AD Bank IFSC codes to prevent duplicate loan filings.
-
Automated Regulatory Document Generation
- FIU-IND Suspicious Transaction Report (STR): Full narrative drafting powered by Groq LLM.
- RBI Form ETX: Automated drafting of extension/write-off applications for overdue bills.
- HTML Audit Reports: Print-ready, executive-level counterfactual valuation reports.
-
Dual MCP Transport
- Standard
stdiotransport for direct CLI/IDE integration. - Express
sse(Server-Sent Events) transport for web dashboard connections.
- Standard
π System Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Trade Finance Dashboard (Next.js + Recharts) β
β Counterfactual View: Declared vs Benchmark β
β [Member 4] β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β MCP Client (Stdio / SSE)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Nitrostack MCP Server [Member 1] β
β β
β RESOURCES TOOLS PROMPTS β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββ β
β β Invoice Feed β β Price Deviation β β STR Gen β β
β β (txns + shippingβ β (z-score, IQR, β β Template β β
β β docs) β β counterfactual)β β β β
β β β β β β Red Flag β β
β β Benchmark Feed β β Timeline Risk β β Summary β β
β β (spot + 90d β β (FEMA 300% β ββββββββββββ β
β β stats + IQR) β β penalty) β β
β β β β β β
β β EDPMS Status β β Counterparty β β
β β (realization β β Pattern Scanner β β
β β + FETERS) β β β β
β βββββββββββββββββββ β Sanctions, DGFT,β β
β β ICEGATE, FormETXβ β
β βββββββββββββββββββ β
β DbDataProvider Interface β
βββββββββββββββ¬βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ
β Groq / World Bank β β PostgreSQL / Supabase β
β (AI Reasoning & β β (Trade txns, HS benchmarks, β
β Inflation Data) β β EDPMS records) β
β [Member 3] β β [Member 2] β
βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ
π MCP Primitives Reference
Resources (Data Streams)
| URI | Description |
|---|---|
trade-invoice-feed://all |
Returns all LC/Export trade transaction records with shipping documentation |
trade-invoice-feed://{invoice_id} |
Templated resource to retrieve individual transaction details |
commodity-benchmark://all |
Global commodity market price reference table by HS Code |
edpms-realization-status://all |
RBI EDPMS realization records with countdown timelines and realization status |
Tools (Detection Logic & Actions)
| Tool Name | Input Arguments | Description |
|---|---|---|
list_all_transactions |
{} |
Retrieves all stored trade transactions |
check_price_deviation |
invoice_id |
Cross-references unit price against benchmark z-score & IQR; returns counterfactual gap |
check_timeline_risk |
exporter_id |
Checks EDPMS realization deadlines; calculates 300% FEMA penalty exposure |
check_counterparty_pattern |
entity_id |
Scans for identical value repeats, rapid succession, and round-trip invoicing |
verify_dgft_iec |
iec, pan |
Verifies DGFT registration and caution-listing status |
verify_icegate_customs |
shipping_bill_no, port_of_loading, declared_weight |
Cross-checks declared cargo weight against customs records |
check_sanctions |
entity_name, country_code |
Screens entities against OpenSanctions PEP/OFAC watchlists |
check_routing_risk |
port_of_loading, port_of_discharge |
Evaluates maritime shipping feasibility and landlocked port risks |
check_double_financing |
shipping_bill_no, ad_bank_code |
Detects duplicate shipping bill filings across AD banks |
generate_counterfactual_report |
invoice_id |
Generates a print-ready HTML audit report |
generate_rbi_filing |
invoice_id |
Generates an official RBI Form ETX draft for overdue bills |
draft_str |
flags_list, transaction_details, counterfactual |
Synthesizes accumulated flags into an FIU-IND compliant STR narrative |
Prompts (LLM Templates)
| Prompt | Description |
|---|---|
str_generation_template |
AML Compliance Officer prompt for formal STR drafting under FEMA 2026 |
red_flag_summary_template |
Executive summary prompt for relationship managers and credit committees |
π₯ Team Responsibilities & Handoff
| Role | Member | Responsibilities | Artifact Link |
|---|---|---|---|
| MCP Architect | Member 1 | Nitrostack setup, MCP schemas, detection tools, transport routing | [walkthrough.md](file:///home/devang/.gemini/antigravity/brain/125af709-ec63-4b47-b71a-92a5a3c073b2/walkthrough.md) |
| Data Synthesizer | Member 2 | Supabase DDL schema, PostgreSQL provider, synthetic data seeder | [member2_handoff.md](file:///home/devang/.gemini/antigravity/brain/125af709-ec63-4b47-b71a-92a5a3c073b2/member2_handoff.md) |
| AI Engineer | Member 3 | Groq/Claude API integration, prompt templates, STR narrative generation | [mcp_integration_guide.md](file:///home/devang/.gemini/antigravity/brain/125af709-ec63-4b47-b71a-92a5a3c073b2/mcp_integration_guide.md) |
| UI/UX Specialist | Member 4 | React/Next.js dashboard, Recharts counterfactual view, STR editor | [member4_handoff.md](file:///home/devang/.gemini/antigravity/brain/125af709-ec63-4b47-b71a-92a5a3c073b2/member4_handoff.md) |
π» Quick Start & Installation
Prerequisites
- Node.js 18+
- PostgreSQL or Supabase Database
Setup Instructions
-
Clone & Install Dependencies:
git clone https://github.com/DevNarayanU/MCP-Nitro.git cd nitrostack npm install -
Configure Environment Variables: Create a
.envfile in the root directory:# Server Configuration SERVER_NAME=invoicex-ray SERVER_VERSION=1.0.0 MCP_TRANSPORT=stdio # "stdio" or "sse" PORT=3000 # Database Connection DATABASE_URL="postgresql://postgres:[PASSWORD]@db.[PROJECT-ID].supabase.co:5432/postgres" # AI & External APIs (Optional for live LLM features) GROQ_API_KEY="your-groq-api-key" GROQ_MODEL="llama-3.3-70b-versatile" OPENSANCTIONS_API_KEY="your-opensanctions-api-key" # Thresholds PRICE_DEVIATION_THRESHOLD=20 TIMELINE_RISK_DAYS=15 -
Database Migration & Seeding: Run the seeding script to create PostgreSQL tables and populate clean + planted TBML transactions:
npm run seed -
Run Server:
# Development mode with hot-reload npm run dev # Production build & start npm run build npm run start:prod
MCP Client Configuration (stdio)
Add this configuration to your Claude Desktop or MCP Client settings (mcpServers):
{
"mcpServers": {
"invoicex-ray": {
"command": "node",
"args": ["/path/to/nitrostack/dist/index.js"]
}
}
}
π Regulatory Reference Framework
- FEMA 2026: Foreign Exchange Management (Export and Import Regulations), 2026 (Section 13 Penalties).
- RBI Master Direction on KYC/AML: Master Direction - Know Your Customer (KYC) Direction, 2016 (updated 2026).
- FIU-IND Reporting Format: Financial Intelligence Unit - India Suspicious Transaction Report guidelines.
- FATF TBML Typologies: Financial Action Task Force Guidance on Trade-Based Money Laundering.
π License
Distributed under the MIT License.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.