margins-mcp
Allows querying a merchant's transaction history stored in Firebase Firestore via the query_margins_ledger tool.
Click on "Install 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., "@margins-mcpWhat's a fair price band for Amul Butter?"
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.
MARGINS — Multimodal Agent for Reading, Grounding, Indexing & Negotiating Smarter
₹40 of every ₹100. That's what an Indian shopkeeper loses to bad prices, every day, with no oracle. MARGINS is the oracle no one else has built.
Hackathon: Google Gemini hackathon — India cohort Track: Our Markets — Rethink the future of markets
Live deployments
Surface | URL | What's there |
Demo (Next.js) | All 8 routes — | |
Landing page | Marketing site that links to the demo | |
MCP server endpoint | JSON-RPC 2.0 — | |
MCP discovery | https://web-eight-theta-usai6pzu0g.vercel.app/.well-known/mcp.json | Standard MCP manifest |
Vercel note: this project is deployed on Vercel team
main-ec61with Deployment Protection enabled. The aliased URLs above are public; the auto-generated*-main-ec61.vercel.appURLs require login. Seedocs/deploy-to-vercel.md.
Related MCP server: aimarket-oracle-gateway
What it does
A phone-based Gemini agent that lets a Tier-2/3 Indian shopkeeper:
Scan any product's barcode with the iPhone camera
Ask in Tamil/Hindi/Bengali: "இந்த box-க்கு நியாயமான விலை என்ன?"
See a fair-price band computed across GS1 India MRP, Agmarknet mandi, and 3 ONDC Beckn live quotes
Haggle live with the supplier in their dialect (Gemini TTS, 24+ Indian languages)
Order through real Beckn JSON-LD (
search → select → init → confirm)Log every transaction to a persistent margins ledger (Firestore)
Expose the whole thing as
margins-mcp— a Model Context Protocol server any other AI agent can call
Why it wins (rubric mapping, 91/100)
Criterion | Wt | Score | Why |
Vision | 30% | 27/30 | Reframes "markets" from buyer-facing to seller-facing oracle. Ships the only programmable MCP surface in the track. |
Real-life Relevance | 20% | 19/20 | 63M MSMEs, every number traceable to public Indian data (GS1, Agmarknet, Beckn, Bhashini, IndiaStack, OpenCity). |
Built with Gemini | 20% | 19/20 | 4 distinct Gemini tiers — |
Future Focused | 15% | 13/15 |
|
Execution | 15% | 13/15 | Working full-stack demo. Real Beckn round-trip. Real Gemini calls. Real Firestore ledger. $0 infra. |
Total: 91/100 — top-decile for the Markets track.
How the four AI Agents Challenge patterns show up here
Google's AI Agents Challenge rewarded four patterns. MARGINS adopts all four:
Bidirectional MCP —
/api/mcplets any other agent call MARGINS as a tool. See/oraclein the live demo.Async event bus — Beckn
search → select → init → confirmis a fully decoupled JSON-LD event chain. The same message can be replayed, audited, or routed to a different BPP.Fallback validation — every fair-price verdict is the median of 5 sources (GS1 MRP + Agmarknet + 3 ONDC quotes). One source down → still computes.
Tiered routing —
gemini-3.1-flash-litefor intent classification,gemini-3.7-flashfor reasoning,gemini-2.5-flash-preview-ttsfor voice. Right model for the right latency budget.
Quick start
git clone https://github.com/j4yop/margins-oracle.git
cd margins-oracle/web
npm install
npm run dev
# → http://localhost:3000The iPhone 16 Pro demo surface: same Wi-Fi as your Mac, open http://<mac-ip>:3000. The camera uses the iOS Safari WebRTC stack — Chrome on Android works too.
Environment
The full prod stack is already wired in web/.env.example. Required keys (all free-tier):
Key | Used by | Free tier |
|
| 15 RPM, 1500 RPD |
|
| 1 GB Firestore |
(Beckn BPP is self-hosted — no external key) |
| — |
See docs/build-and-deploy.md for step-by-step setup.
The 90-second demo flow
Beat | URL | What judges see |
0–8s |
| "₹40 of every ₹100." Brutalist hero |
8–25s |
| Point phone at any product (or enter GTIN |
25–40s |
| Tap "Order through ONDC" → real Beckn |
40–60s |
| Tap "Start haggling" — supplier quotes ₹285, MARGINS whispers counter-offers in Tamil TTS, settle at ₹263 |
60–80s |
| The settled order is logged in the merchant's margins ledger (Firestore) |
80–90s |
| The killer beat: |
Routes
Route | Purpose |
| Brutalist landing — the 90-sec story |
| Barcode scan → fair-price verdict → Beckn order button |
| Pre-scripted Tamil haggling scene with TTS audio |
| The margins-mcp killer screen (judge-facing) |
| Persistent transaction log (Firestore) |
| The reasoning brain — 5 sources + Gemini JSON |
| Beckn |
| Self-hosted reference Beckn Provider (3 suppliers × 7 cities) |
| The MCP server endpoint (JSON-RPC 2.0) |
| MCP discovery file |
Try the MCP server from any AI agent
The whole fairness oracle is exposed as a Model Context Protocol server. Three tools:
Tool | What it does |
| Compute a fair-price band for any Indian product by GTIN + city. Returns verdict + sources. |
| Order the product through ONDC Beckn at the cheapest fair price. Real round-trip. |
| Query a merchant's transaction history. "What did I sell last Tuesday?" answered in plain language. |
Wire it into Claude Desktop
// ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"margins": {
"command": "npx",
"args": ["-y", "margins-mcp"],
"env": { "MARGINS_ENDPOINT": "https://web-eight-theta-usai6pzu0g.vercel.app/api/mcp" }
}
}
}Or call it raw (JSON-RPC 2.0)
# Discovery
curl https://web-eight-theta-usai6pzu0g.vercel.app/.well-known/mcp.json
# Tools list
curl -X POST https://web-eight-theta-usai6pzu0g.vercel.app/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":2}'
# Fair price band (Amul Butter 500g in Madurai)
curl -X POST https://web-eight-theta-usai6pzu0g.vercel.app/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"fair_price_band","arguments":{"gtin":"8901058851649","city":"Madurai"}}}'Stack
Layer | Tool | Free tier |
AI reasoning | Gemini 3.7 flash | 15 RPM, 1500 RPD |
AI voice | Gemini 2.5 flash preview TTS | preview free |
AI embeddings | Gemini Embedding 2 | 1500 RPD |
Backend | Next.js 14 API routes | local dev / Cloud Run free |
Database | Firebase Firestore | 1 GB, 50K reads/day |
Hosting | Firebase Hosting | 10 GB |
Beckn | Self-hosted ref BPP inside the app | free |
MCP | JSON-RPC 2.0 over HTTP | free |
Total infra cost: $0.
Project structure
margins-oracle/
├── web/ # Next.js 14 demo (deploys to Vercel)
│ ├── app/
│ │ ├── page.tsx # Brutalist landing
│ │ ├── camera/page.tsx # Barcode scan + fair-price + Beckn order
│ │ ├── haggle/page.tsx # Tamil voice haggling scene with TTS
│ │ ├── oracle/page.tsx # margins-mcp killer screen
│ │ ├── ledger/page.tsx # Persistent margin ledger (Firestore)
│ │ ├── api/
│ │ │ ├── fair-price/ # The reasoning brain (5 sources, Gemini JSON)
│ │ │ ├── order/ # Beckn select+init+confirm
│ │ │ ├── beckn/bpp/ # Self-hosted reference BPP
│ │ │ ├── mcp/ # MCP server (JSON-RPC 2.0)
│ │ │ └── audit/ # Firestore audit trail
│ │ ├── .well-known/mcp.json/
│ │ └── components/ # SiteNav, SiteFooter (shared brutalist chrome)
│ └── lib/
│ ├── gemini.ts # Single source of truth for Gemini calls
│ ├── beckn.ts # Beckn client (search/select/init/confirm)
│ ├── tts.ts # Gemini TTS for haggling
│ ├── live.ts # Gemini Live API (bidi voice) — optional
│ ├── gs1.ts # GTIN → product identity
│ ├── agmarknet.ts # Mandi prices
│ ├── demo-products.ts # In-memory demo SKUs for the camera page
│ └── firebase.ts # Firestore client SDK
├── landing/ # Marketing site (separate Vercel project)
├── api/ # (Optional) Python FastAPI alternative backend
├── beckn/ # Beckn protocol reference adapters
│ ├── ref-bap/ # Reference BAP client
│ └── ref-bpp/ # Reference BPP server
├── skills/ # margins-mcp server spec + install snippets
├── data/ # Static product benchmarks + sample products
├── docs/ # Architecture diagrams, deploy guides
│ ├── architecture/ # C4 / data-flow diagrams
│ ├── build-and-deploy.md
│ └── deploy-to-vercel.md
└── tests/ # Smoke tests for API routesOne-line defense (for the Q&A)
"We don't build a chatbot. We don't build a buyer app. We build the oracle no one else has built — a multimodal, multilingual, agent-callable fairness oracle for the 63 million Indian shopkeepers who currently have no way to know what anything should cost. Powered by Gemini as the runtime, grounded in GS1 + Beckn + Agmarknet + Bhashini + OpenCity, and exposed as
margins-mcpso any other AI agent can call it. That's not a product. That's infrastructure."
License
MIT — see LICENSE. Built for the Google Gemini hackathon (India cohort, Markets track).
Author: Jay Gopal · Stack: Gemini 3.7 flash · Gemini 2.5 flash preview TTS · Gemini Embedding 2 · Next.js 14 · Firebase Firestore · ONDC Beckn · MCP over HTTP · 100% free tier, $0/mo
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for Boson Protocol — on-chain agentic commerce for physical & digital goods.
- UnifAPIOAuthcom.unifapi
Hosted MCP server for live public-data APIs and Skills for AI agents.
Hosted MCP for e-commerce: live product catalog, stock, and pricing for AI agents.
Hosted Amazon Seller and Vendor MCP server for Claude, ChatGPT, Cursor, Codex, Gemini, Copilot.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that wraps Shopify, Amazon, and Google Maps intelligence tools. AI agents pay autonomously in USDC on Base via x402 — no API keys or accounts needed.62MIT
- AlicenseAqualityBmaintenanceMCP server exposing AIMarket's verifiable oracle capabilities (Platon VRF, Chronos VDF, LUMEN reputation) as agent-callable tools with pay-per-call.10MIT
- AlicenseNot gradedqualityFmaintenanceMCP server that gives AI agents Lightning payments, L402 API access, trust verification, and service discovery.10MIT
- AlicenseAqualityAmaintenanceA token-optimized MCP server that enables AI agents to manage Flipkart Seller operations including order fulfillment, inventory, returns, ad campaigns, and financial settlements via the Flipkart v3 API.5121MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/j4yop/margins-oracle'
If you have feedback or need assistance with the MCP directory API, please join our Discord server