Skip to content
CodeWithRJ006Public

About

Transparent policy proxy + structuring detector for Razorpay's MCP server

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Structura

A transparent stdio proxy that sits between AI clients and Razorpay's official Model Context Protocol (MCP) server to enforce deterministic runtime safety on financial tool execution.

Live Demo: https://structura-mlsv.onrender.com


Why It Exists

Autonomous AI agents executing financial actions cannot rely on prompt-based guardrails. Furthermore, Razorpay's official MCP server offers only binary access (--read-only or unrestricted execution), and generic API gateways cannot inspect inside JSON-RPC frames or track state across multiple calls.

Structura fills this gap by providing:

  1. Deterministic Policy Enforcement: Evaluates tool calls against YAML-defined rules without an LLM in the decision loop. Schema-validated via Zod; fails closed on missing or invalid configurations.
  2. Transaction Structuring Detection: Detects smurfing and structuring patterns across calls. For example, five ₹10,000 refunds on the same payment_id trip a ₹15,000 threshold on the 2nd call and trigger REQUIRE_APPROVAL, whereas five ₹10,000 refunds spread across five different payments pass (ALLOW).
  3. Human Approval Queue: Intercepted calls enter an SQLite queue reviewable in an embedded React + Vite dashboard before downstream execution.
  4. Tamper-Evident Audit Chain: Every inbound frame, decision, and payload hash is committed to an SQLite hash-chain (SHA-256). A standalone CLI verifier (structura verify-audit-log) detects edited rows, deleted rows, and recomputed hashes.

Policy Rules Example (policy.yaml)

rules:
  - tool: create_refund
    action: REQUIRE_APPROVAL
    conditions:
      amount: { gt: 1000000 } # Subunits: > ₹10,000 triggers human review

structuring:
  - tool: create_refund
    group_by: payment_id
    threshold: 1500000        # Cumulative > ₹15,000 triggers REQUIRE_APPROVAL
    window_hours: 24

Decisions resolve strictly to ALLOW, DENY, or REQUIRE_APPROVAL.


Tech Stack

  • Runtime & Language: Node.js 22, TypeScript
  • Validation: Zod (fail-closed schema enforcement)
  • Database & Storage: SQLite (better-sqlite3)
  • Dashboard UI: React, Vite, Tailwind CSS
  • Protocol: Model Context Protocol (MCP) JSON-RPC 2.0 over stdio

Setup & Quick Start

# 1. Clone & install
git clone https://github.com/CodeWithRJ006/Structura.git
cd Structura && npm install

# 2. Build proxy & dashboard
npm run build

# 3. Run proxy (wraps Razorpay MCP on stdio)
npm start

# 4. Verify cryptographic audit log integrity
npx structura verify-audit-log

About

Transparent policy proxy + structuring detector for Razorpay's MCP server

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages