Retail POS MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
About this repo. This repository showcases the complete architecture, source code, tests, and engineering walkthrough of an API-first Retail POS MCP Server I designed and built. Store/product branding is intentionally generalized; all code, schemas, OAuth flows, and tests are self-contained and runnable out of the box (including a mock Store API in
examples/mock-store-api.js).
π Contents
Related MCP server: Kromo Cargo
β‘ The idea in one minute
Retail store owners and managers spend hours clicking through back-office admin panels to check daily sales, audit cashier shift discrepancies, update variant prices, or record customer credit (Khata) repayments.
Instead of giving an LLM raw SQL access to a multi-tenant database (dangerous!), this MCP server sits strictly in front of the Store Web REST API and authenticates as a real store user:
Before (Admin UI / Raw DB Risk) | After (API-First MCP Server) |
Manual clicks across sales, catalogue, shifts, and credit screens | Ask in plain English from Claude Code, Claude Desktop, claude.ai, or mobile |
Direct DB bots bypass validation and break multi-tenant isolation | Zero direct DB access β every call runs through API validation, RBAC, and RLS |
AI edits look anonymous or unattributed | Every mutation writes to the Store Activity Audit Log under that user's name |
Separate integrations per client (local vs cloud) | One shared core ( |
Floating-point rupee bugs in financial mutations | Rupees in β integer paise out ( |
flowchart LR
U["π€ Store Owner / Manager<br/>Plain-English Prompt"] --> AI["π€ AI Client<br/>Claude Code Β· Desktop Β· claude.ai"]
AI --> T{"Transport"}
T -- "Local" --> STD["stdio<br/>server.js"]
T -- "Remote" --> HTTP["Streamable HTTP + OAuth 2.1<br/>httpServer.js"]
STD & HTTP --> CORE["βοΈ Shared MCP Core<br/>31 Zod Tools + Annotations"]
CORE -- "Authorization: Bearer <storeToken>" --> API["π‘οΈ Store Web API<br/>RBAC Β· Validation Β· Audit Log"]
API --> DB[("ποΈ PostgreSQL<br/>Row-Level Security")]
style CORE fill:#1e1b4b,stroke:#a78bfa,color:#fff
style API fill:#064e3b,stroke:#34d399,color:#fffποΈ Architecture & dual transports
The server runs in two transport modes from the exact same tool registry (src/tools.js) and server factory (src/createServer.js):
flowchart TB
subgraph Local["1. Local Mode (src/server.js)"]
direction LR
LC["Claude Code / Claude Desktop"] -- "stdin / stdout<br/>JSON-RPC" --> ST["StdioServerTransport"]
ST --> AC1["apiClient.js<br/>(lazy login + auto re-auth on 401)"]
end
subgraph Remote["2. Remote Connector Mode (src/httpServer.js)"]
direction LR
RC["claude.ai / Mobile / Remote MCP"] -- "HTTPS" --> CF["Cloudflare Tunnel / Reverse Proxy"]
CF -- "127.0.0.1:8787" --> EX["Express 5 + OAuth 2.1 Router<br/>+ StreamableHTTPServerTransport"]
EX --> AC2["Stateless per-request apiClient.js<br/>(Bearer token from OAuth session)"]
end
AC1 & AC2 -- "Bearer <store_tenant_session>" --> API["Private Store Web API (:4000)<br/>RBAC + Optimistic Versioning + Audit Log"]
API --> PG[("PostgreSQL 19<br/>Row-Level Security")]
classDef box fill:#0f172a,stroke:#22d3ee,color:#e2e8f0
class LC,ST,AC1,RC,CF,EX,AC2 boxTransport | Entry Point | Auth Strategy | Best For |
Local |
| Claude Code CLI, Claude Desktop, Cursor on a trusted dev/manager machine | |
Remote Streamable HTTP | OAuth 2.1 + PKCE ( |
|
π Deep dive: docs/01-architecture-and-transports.md
π How it works: Read-Only vs Write / Mutating
Every tool in src/tools.js declares standard MCP tool annotations so AI clients know when a call is safe to auto-execute versus when to pause for human confirmation:
export const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
export const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
export const CHANGE = { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false };1. Read-Only Tools (19 tools β readOnlyHint: true)
Zero side effects: Map strictly to
GETendpoints; AI clients run them freely to gather context, look up UUIDs, and generate summaries.POS-sensitive domains stay Read-Only: Sales bills, returns/credit notes, and cashier shift X/Z reports are read-only by designβlive POS checkout belongs at the counter, never in an AI chat.
Raw paise transparency: API responses return exact integer
...Paisevalues; server instructions direct the AI to divide by100when presentingβΉamounts.
2. Write & Mutating Tools (12 tools β 6 WRITE + 6 CHANGE)
Confirm-first guardrail: Server instructions (
src/createServer.js) require the assistant to confirm exact rupee amounts, SKUs, and status changes with the user before calling mutating tools.Float-safe money conversion: Inputs accept human-friendly rupees (
849.50) and pass throughtoPaise()(Math.round(num * 100)viasrc/money.js) so floating-point precision errors never hit financial ledgers.Idempotency & concurrency guards:
record_khata_paymentandadjust_khata_balancegenerate a freshcrypto.randomUUID()per request to prevent duplicate ledger entries on retries.update_store_settings,update_product, andupdate_variantpass optionalexpectedVersionfor optimistic concurrency control.
Role-gated at the API: Even if a prompt tries to invoke a write tool, a
CASHIERsession is rejected by the backend RBAC middleware (403 Forbidden), whileINVENTORY_MANAGERorSTORE_OWNERsucceeds and logs the edit.
Domain | Read-Only Tools ( | Write / Change Tools ( |
Session & Store |
|
|
Catalogue & Variants |
|
|
Sales, Returns & Shifts |
| None β POS counter only |
Customers & Credit Ledger |
|
|
Staff & POS Devices |
|
|
π Complete reference: docs/03-tools-read-vs-write.md
π OAuth 2.1 + PKCE remote connector
Remote connectors (claude.ai, mobile) cannot safely store plaintext passwords in local JSON config files. Instead, src/oauthProvider.js and src/httpServer.js implement a full OAuth 2.1 Authorization Server using @modelcontextprotocol/sdk's mcpAuthRouter and requireBearerAuth:
Protected Resource Discovery: Unauthenticated
POST /mcpreturns401withWWW-Authenticate: Bearer resource_metadata="...".Dynamic Client Registration (
POST /register): Only redirect URIs matchingMCP_REDIRECT_HOSTS(claude.ai,claude.com,localhost,127.0.0.1) over HTTPS (or local HTTP) are acceptedβblocking open-redirect phishing.PKCE
S256& Store Sign-In (GET /authorizeβPOST /oauth/login): Serves a clean login form protected byexpress-rate-limit(20 attempts / 15 min / IP). Credentials are forwarded once to/api/store/auth/loginand immediately discardedβonly the resulting session token stays in memory.Single-Use Code β Resource-Bound Token (
POST /token): Authorization codes expire in 2 minutes and are deleted on first exchange; issued Bearer tokens are bound to/mcpand expire with the 12-hour store session (no refresh tokens).Instant Revocation: If a staff account is deactivated or logged out, the next
401callsprovider.forgetToken(), immediately invalidating the connector token.
π Security deep dive: docs/02-oauth-security-and-rbac.md
π§° Skills, tools & tech stack
Engineering Skills & AI Workflows Used
Claude Code CLI & Progressive Context Docs: Maintained structured architecture & module reference docs (
PROJECT_CONTEXT.md, module specs) so AI coding sessions accurately mapped DTOs, RBAC permission keys, and error formats before writing code.MCP Tool Design Patterns: Applied strict
READ/WRITE/CHANGEannotations, server-level behavioral instructions, ID-first lookup patterns, and deterministicrupees β integer paiseadapters.Test-Driven Verification: Built isolated unit tests (mock
fetch), full OAuth + Streamable HTTP integration tests, and livestdioend-to-end tests using Node's native test runner.
Tech Stack
Layer | Technology / Package | Version | Purpose |
MCP SDK |
|
|
|
Schema Validation |
|
| Runtime argument validation & JSON Schema generation for all 31 tools |
HTTP Server |
|
| Stateless |
Abuse Protection |
|
| Brute-force throttling ( |
Runtime & Crypto | Node.js (ESM) |
| Native |
Backend Context | Express 5 + Prisma + PostgreSQL 19 | β | Multi-tenant Store Web API with RBAC, Row-Level Security (RLS), and immutable audit logs |
Secure Exposure | Cloudflare Tunnel ( | latest | Exposes local |
π Full stack notes: docs/04-skills-tools-and-tech-stack.md
π οΈ How I built it (step by step)
Mapped the Store Web API: Audited auth, owner analytics, catalogue/variant, credit ledger (Khata), shifts, and staff routes to catalog exact payloads and permission keys.
Enforced API-First Isolation: Built
src/apiClient.jsto log in viaPOST /api/store/auth/login, parse theHttpOnlysession cookie, sendAuthorization: Bearer, and auto-relogin once on401in local mode.Engineered the 31-Tool Registry: Implemented
src/tools.jswith Zod schemas,READ/WRITE/CHANGEannotations,toPaise()conversion, andcrypto.randomUUID()idempotency IDs.Shipped Local
stdioMode: Wiredsrc/server.jsinto Claude Code (claude mcp add) and Claude Desktop, keepingstdoutstrictly clean for JSON-RPC.Added Remote OAuth 2.1 + Streamable HTTP: Built
src/oauthProvider.jsandsrc/httpServer.jsso remote connectors authenticate via PKCES256without storing passwords.Tested End-to-End: Verified unit logic, OAuth replay/allow-list/PKCE edge cases, and live
stdiotool execution behind a Cloudflare Tunnel.
π¬ Use cases
Role | Plain-English Prompt | Tools Executed | Outcome |
Store Owner | "What were today's net sales and any cashier drawer mismatches?" |
| Instant βΉ totals + flagged shifts (Read-Only) |
Inventory Manager | "Drop Slim Fit Shirt size M selling price to βΉ2,499." |
| Converts |
Accounts / Owner | "Record a βΉ500 UPI credit payment from Ramesh (ref UPI-98231)." |
| Posts idempotent repayment with UUID & updates ledger |
Store Manager | "Add a new Cashier account for Anita with starting PIN 4821." |
| Creates staff login & returns onboarding details |
Auditor | "Show offline bills from yesterday flagged for review." |
| Surfaces synced offline bills needing review |
π Worked transcripts: examples/sample-prompts-and-workflows.md
π Key advantages
Zero Direct Database Exposure: AI never receives SQL credentials or raw DB accessβPostgreSQL stays private behind the Store API.
True Multi-Tenant RBAC: A Cashier's MCP session is blocked from price changes by the exact same middleware that governs the web UI.
Complete Auditability: Every mutation appears in the store's activity log under the real user who authorized the session.
Zero Upstream Backend Changes: Reuses existing Bearer/cookie auth middleware and validation routes as a clean, additive service.
Financial Precision: Integer-paise conversion + UUID idempotency keys + optimistic
expectedVersionprotect money and inventory state.Write Once, Run Everywhere: One tool layer powers local CLI agents (
stdio) and cloud/mobile assistants (Streamable HTTP + OAuth 2.1).
βΆοΈ Quickstart & testing
1. Install & Run the Built-in Test Suite
npm install
npm testnpm test runs:
Unit tests (
tests/tools.test.js): rupee-to-paise math, 31 unique tool names & annotations (19 Read / 12 Write), Bearer login +401auto-relogin, and API error mapping.OAuth 2.1 + Streamable HTTP tests (
tests/http.oauth.test.js):401resource metadata discovery, redirect-host allow-list rejection, dynamic registration, HTML login, PKCES256token exchange, single-use code replay rejection, and livewhoami+listToolsover Streamable HTTP.Optional
stdioend-to-end test (tests/server.integration.test.js): automatically runs when a Store API (or the included demo API) is up.
2. Try It Live with the Included Mock Store API
# Terminal 1: start the lightweight demo Store API on http://127.0.0.1:4000
npm run demo:api
# Terminal 2: run all tests including the live stdio integration suite
STORE_EMAIL=owner@demo-store.example STORE_PASSWORD=demo-pass npm test3. Connect to Claude Code / Claude Desktop (Local stdio)
claude mcp add retail-pos-store \
-e STORE_API_BASE_URL=http://localhost:4000 \
-e STORE_EMAIL=inventory-manager@example-store.in \
-e STORE_PASSWORD=your-staff-password \
-- node /absolute/path/to/retail-pos-mcp-server/src/server.jsOr copy examples/claude_desktop_config.json into your claude_desktop_config.json.
4. Run as a Remote OAuth 2.1 Connector (claude.ai / Mobile)
# 1. Expose local port 8787 via Cloudflare Quick Tunnel
cloudflared tunnel --url http://127.0.0.1:8787
# 2. Start the OAuth + Streamable HTTP server with the printed HTTPS URL
MCP_PUBLIC_URL=https://<random>.trycloudflare.com npm run start:httpThen add https://<random>.trycloudflare.com/mcp under Settings β Connectors β Add custom connector and sign in with your store user credentials.
ποΈ Repository structure
retail-pos-mcp-server/
βββ src/
β βββ money.js # Float-safe rupees -> integer paise converter
β βββ apiClient.js # Store Web API client (cookie login -> Bearer + 401 retry)
β βββ tools.js # 31 Zod-validated tools (19 Read-Only + 12 Write/Change)
β βββ createServer.js # Shared McpServer factory + confirm-first instructions
β βββ server.js # Local stdio entry point (Claude Code / Desktop / Cursor)
β βββ oauthProvider.js # OAuth 2.1 + PKCE S256 + sign-in HTML + allow-list
β βββ httpServer.js # Express 5 + Streamable HTTP + rate-limited /oauth/login
βββ tests/
β βββ tools.test.js # Unit tests: money, 31 tools, auth retry, errors
β βββ http.oauth.test.js # Full OAuth 2.1 + PKCE + Streamable HTTP test
β βββ server.integration.test.js # Live stdio end-to-end integration test
βββ docs/
β βββ 01-architecture-and-transports.md # API-first architecture & stdio vs HTTP deep dive
β βββ 02-oauth-security-and-rbac.md # OAuth 2.1 sequence, PKCE, allow-list, RBAC & audit log
β βββ 03-tools-read-vs-write.md # Complete 31-tool matrix (19 Read vs 12 Write)
β βββ 04-skills-tools-and-tech-stack.md # Build steps, skills, tools, and package versions
βββ examples/
β βββ claude_desktop_config.json # Ready-to-use Claude Desktop MCP config
β βββ mock-store-api.js # Zero-DB mock Store Web API for instant local testing
β βββ sample-prompts-and-workflows.md # Real Read-Only and Read->Confirm->Write walkthroughs
βββ assets/
β βββ hero.svg # Animated hero architecture banner
β βββ mcp-architecture-flow.gif # Animated 6-step end-to-end request lifecycle
β βββ read-vs-write-safety.gif # Animated Read-Only vs Write/Change safety model
β βββ oauth-pkce-sequence.svg # Animated OAuth 2.1 + PKCE S256 sequence diagram
βββ .env.example
βββ .gitignore
βββ LICENSE
βββ package.jsonπ€ Author
Suyog Patil Data Engineer Β· AI Engineering Β· MCP Servers Β· Agentic Systems
β If this MCP server architecture helped you build safe, RBAC-governed AI connectors, consider starring the repo.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
Related MCP Connectors
Build custom POS apps with your AI agent. Final's MCP server gives developers what they need to ship a custom point of sale: scaffold a checkout flow, adapt vetted screen blueprints for counter POS, self-checkout kiosks, restaurant ordering and payment terminals, ground every call in Final's version-locked POS APIs, validate, boot a live preview and deploy to real hardware with integrated card payments. The same server also manages the store behind it: products, stock, orders, customers and sales reports. Remote Streamable HTTP with OAuth 2.1.
AI phone receptionist for small businesses: calls, transcripts, recordings, contacts, appointments, texts and outbound AI calls. OAuth 2.1 with PKCE and dynamic client registration; the account owner picks what the assistant may do.
Connect AI to store orders, products and inventory with scoped access and human approvals.
Run your restaurant from an AI client: orders, menu, reports, refunds, payouts and staff.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to query a retail and food-service point-of-sale database through predefined business tools for sales summaries, top products, margins, stagnant inventory, cash reconciliation, and optional stock adjustments, returning formatted markdown answers.MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI agents and counter staff to run inventory and fast sales for a single-branch physical store β products, stock movements (entries, sales, adjustments), reports, labels and imports β over the same database the app uses, exposed via stdio or a remote Streamable HTTP endpoint with OAuth 2.1 and access tokens. Every action is validated, permission-checked, optionally confirmed with a preview, recorded in history, and undoable, so changes made by an AI appear live in the counter UI.-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables read- or write-scoped access to synthetic enterprise orders, inventory, support tickets, and metrics via schema-validated JSON-RPC tools over stdio and HTTP, with permission allow-lists and audit logging. It also exposes enterprise resources and prompt templates for grounded, cited, multi-step assistant workflows.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to look up customers, orders, products, and stock; take role-restricted actions such as creating orders and handling refunds; enforce business rules; and maintain a tamper-evident audit log.MIT