order-management-mcp
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., "@order-management-mcpWhat is the status of order 9876?"
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.
Order Management API
A role-based order management backend built with FastAPI, the Model Context Protocol (MCP), and MySQL. Users authenticate with JWTs, and every action — viewing an order, issuing a refund, deleting an order, creating a manager — is authorized against a role-based permission matrix and written to an audit log.
Why this exists
Most "CRUD + JWT" portfolio projects stop at "does the token check pass?".
This one adds two things on top: a separate authorization layer that's
independently testable (permissions.py), and a tool-based execution
layer (MCP) that decouples "what can this user do" from "how the API is
shaped" — the same order-management logic could be driven by a REST API,
a CLI, or an LLM agent calling the same MCP tools.
Related MCP server: MCP Customer Support Demo
Architecture
Client
│ HTTP + JWT
▼
FastAPI (main.py)
│ 1. Verifies JWT (auth.py)
│ 2. Calls MCP tool over HTTP (fastmcp Client)
▼
MCP Server (order_checking.py) ── binds to 127.0.0.1 only, see Security below
│ 3. Authorizes the action (permissions.py)
│ 4. Runs the DB operation (database.py)
│ 5. Writes an audit log entry (audit.py)
▼
MySQL (sql/schema.sql)Authentication (who are you) and authorization (what are you allowed to
do) are deliberately split: FastAPI/auth.py only ever answers the first
question, permissions.py is the only place the second question gets
answered, and every MCP tool calls it before touching the database.
Roles & permissions
Action | USER | MANAGER | ADMIN |
View an order | own orders only | own orders + orders they manage | any |
Check refund eligibility | own orders only | own orders + orders they manage | any |
Refund an order | own orders only | own orders + orders they manage | any |
Delete an order | ❌ | ❌ | ✅ |
View user list | ❌ | users they manage | all |
Create a manager | ❌ | ❌ | ✅ |
API endpoints
Method | Path | Auth required | Description |
GET |
| – | Health check |
POST |
| – | Exchange username/password for a JWT |
GET |
| ✅ | Get an order's status |
GET |
| ✅ | Check refund eligibility |
POST |
| ✅ | Refund an order |
DELETE |
| ✅ | Delete an order (ADMIN only) |
GET |
| ✅ | List users visible to the caller |
POST |
| ✅ | Create a new MANAGER (ADMIN only) |
Tech stack
FastAPI · FastMCP · SQLAlchemy · PyMySQL · PyJWT · bcrypt · Pydantic v2 · MySQL
Setup
Install dependencies
pip install -r requirements.txt # or: uv syncConfigure environment
cp .env.example .env # fill in DATABASE_URL and JWT_SECRETCreate the database
mysql -u root -p < sql/schema.sqlSeed example data (creates ADMIN/MANAGER/USER accounts for testing)
python sql/seed.pyRun the MCP server
python order_checking.pyRun the API (separate terminal)
uvicorn main:app --reloadLog in via
POST /loginwith a seeded account (seesql/seed.pyfor credentials), then use the returnedaccess_tokenas a Bearer token on the protected routes.
Security design
Passwords are hashed with bcrypt — never stored or logged in plaintext.
JWTs carry
usernameandrole, are signed withJWT_SECRET, and expire afterJWT_EXPIRE_MINUTES(default 60).The MCP server has no authentication of its own. Every tool in
order_checking.pytrusts theusername/roleit's handed by the caller — all real auth happens one layer up, in FastAPI. Because of that,config.pyhardcodesMCP_HOST = "127.0.0.1"rather than reading it from the environment, so the MCP server can never be exposed by a misconfigured.envor container setting. If you ever split the MCP server onto a different host from the API, add real authentication insideorder_checking.py's tools first — don't just relaxMCP_HOST.SQL is 100% parameterized via SQLAlchemy's
text()— no string interpolation into queries anywhere.Every tool call is audited: caller, role, action, target order, allowed/denied, reason, and latency are written to
audit_logsand tologs/app.log, and a failure to write an audit log never crashes the request.
Known limitations
These are conscious scope cuts for a portfolio-sized project, not oversights:
JWTs aren't re-checked against the DB, so a role change or account deactivation doesn't take effect until the caller's current token expires.
No rate limiting on
/login(would sit better at a gateway/proxy layer than in the app anyway).refund_orderhas a small TOCTOU window — no row lock between the eligibility check and the update.No CORS middleware; add it if this is ever called directly from a browser.
Project structure
main.py FastAPI app: routes, JWT-protected endpoints, MCP client
order_checking.py MCP server: tools + the RBAC/audit wiring around them
auth.py Password hashing, JWT issuing/verification
permissions.py The single source of truth for authorization decisions
database.py SQLAlchemy queries (users, orders, audit log)
audit.py Structured audit log writer
schemas.py Pydantic request/response models
config.py Environment-driven configuration
logger.py App-wide logging setup
sql/schema.sql Table definitions
sql/seed.py Example users/orders for local testingThis 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 Servers
- Flicense-qualityCmaintenanceEnables e-commerce operations such as product search, price updates, and order notes via MCP tools, with secure credential handling.Last updated
- Flicense-qualityCmaintenanceEnables customer support operations such as order lookup, store credit, refunds, and audit log review through an agent using safe, typed MCP tools.Last updated
- Flicense-qualityCmaintenanceA production-grade MCP server for order management, featuring tools for looking up and refunding orders with safety measures like confirmation tokens, rate limiting, and error handling.Last updated
- Flicense-qualityBmaintenanceAn MCP server that enables non-technical operations users to resolve common commerce-ops tickets, such as orders charged but failed, through an investigate, recommend, approve, and execute workflow with read-only and write tools.Last updated
Related MCP Connectors
Remote MCP for Universal Cart merchant readiness MCP, structured receipts, audit logs, and reviewer-
Remote MCP for Gemini Omni commercial rights receipt MCP, structured receipts, audit logs, and revie
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
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/mahipalrajpurohit529-dotcom/order-management-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server