MCPController
Click on "Deploy 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., "@MCPControllerList all doctors"
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.
MCPController
MCPController is the and a single-deploy doctor–patient appointment application with a React frontend, Express API, OAuth 2.1 authorization server, and MCP server — all served from one origin (for example https://mcpcontroller.vercel.app).
Patients book available days. Doctors accept one patient per day and can offer another date. Administrators manage the system. ChatGPT connects through OAuth with PKCE. Every MCP tool checks the caller’s role, ownership, and granted scopes.
Architecture
ChatGPT
→ OAuth discovery (/.well-known/*)
→ GET /oauth/authorize (backend bridge)
→ /login or /authorize (React)
→ POST /api/oauth/consent
→ Authorization code + PKCE
→ POST /oauth/token
→ Bearer access token (+ refresh token)
→ POST /mcp (MCP tools)
→ Permission check → MongoDBComponents
Layer | Responsibility |
Frontend ( | Role dashboards, booking UI, OAuth consent, profile |
API ( | REST endpoints for auth, admin, doctors, patients, appointments, connections |
OAuth ( | Authorization code + PKCE, DCR, token exchange, revocation |
MCP ( | Streamable HTTP MCP server with role-aware tools |
Models ( | User, Doctor, Appointment, OAuthClient, AccessToken, Connection, AuthorizationCode |
Vercel entry ( | Serverless Express handler for production |
Related MCP server: aster-mcd-mcp-adapter
Authentication
Two separate credential systems:
Website session — HTTP-only JWT cookie (
mcpcontroller_session) for the React UI.MCP access token — Bearer token used by ChatGPT on
/mcp.
Accounts
Administrator — credentials from
ADMIN_EMAIL/ADMIN_PASSWORD. Has all scopes and can manage doctors, patients, appointments, and permissions.Doctors — register through the website, set weekly availability, and accept or reject appointment requests.
Patients — register through the website, view doctors, request an available day, and accept suggested alternatives.
Registration is disabled for the reserved admin email address.
OAuth flow
ChatGPT discovers metadata from
/.well-known/oauth-authorization-serverand/.well-known/oauth-protected-resource.ChatGPT opens
GET /oauth/authorizewith PKCE S256 parameters.If no session exists, the user is redirected to
/login?returnTo=/authorize?....If a session exists, the user goes directly to
/authorize(React consent page).The user selects permissions and clicks Allow & Connect.
The backend creates a single-use authorization code bound to PKCE, client, redirect URI, and resource.
ChatGPT exchanges the code at
POST /oauth/token.ChatGPT uses the access token on
/mcp. Refresh tokens keep the connection alive without re-authorizing every time.
Revoking a connection from the dashboard (or calling POST /oauth/revoke) immediately invalidates stored tokens.
Permission system
Scope | MCP tools |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| accept / reject / suggest / cancel / complete / |
|
|
|
|
|
|
|
|
Permissions are enforced in three places:
User account —
allowedScopeson the User document (admin-managed for normal users).OAuth consent — only scopes the user is allowed to grant can be selected.
MCP tools — every tool call checks the access token scopes again.
Complete MCP tool list (29 tools)
Category | Tools |
Doctors |
|
Availability |
|
Patients |
|
Appointments |
|
Admin |
|
Profile |
|
Logs |
|
ChatGPT tip: If you only see a few doctor tools, reconnect and grant the scopes you need on the consent screen (appointments, patients, availability, profile, logs). Tools are filtered by the scopes granted during OAuth — not by role alone. Only tools your token can access appear in tools/list.
Doctor model
Field | Description |
| Required |
| Required |
| Optional contact email |
| Optional phone number |
| Summary / notes |
| Monday–Sunday: |
| Linked login account when the doctor registered |
Environment variables
Create a .env file in the project root (see .env.example).
Variable | Example | Public? | Notes |
|
| No |
|
|
| No | Local Express port |
|
| Yes | Frontend origin (Vite dev). On Vercel: |
|
| Yes | API origin. On Vercel: same as |
|
| Secret | MongoDB connection string |
|
| No | Admin login email |
|
| Secret | Admin login password |
| long random string | Secret | Session cookie signing |
|
| No | Optional session lifetime |
|
| No | Optional |
|
| No | Optional |
|
| No | Optional (30 days) |
|
| Yes | MCP server metadata |
|
| Yes | MCP server metadata |
| long random string | Secret | Recommended in production — bearer token for |
|
| No | Disable only for debugging |
|
| No | Must stay |
Never expose MONGODB_URI, ADMIN_PASSWORD, or JWT_SECRET to the browser.
Local development
npm install
npm run seed # creates admin, sample doctor/patient accounts, MCP Inspector client
npm run dev # Express :3000 + Vite :5173Seeded demo logins (password Doctor123! / Patient123!):
Doctor:
ahmed@clinic.examplePatient:
patient.a@example.com
Vite proxies /api, /oauth/token, /oauth/register, /mcp, and /.well-known to Express.
Testing
npm test
npm run buildTESTING_CENTER.md — Admin Testing Center (VU, RPS, scenarios, logs, traces, feature flags)
LOAD_TESTING.md — CLI load tests (
npm run load:smoke, etc.)OBSERVABILITY.md — Logging, correlation IDs, debugging OAuth/MCP issues
Vercel deployment
Push to GitHub and import the repo in Vercel (Framework: Other).
Set environment variables for Production (see table above).
APP_URLandAPI_URLmust both behttps://mcpcontroller.vercel.app(or your custom domain). Required:MONGODB_URI,JWT_SECRET,ADMIN_EMAIL,ADMIN_PASSWORD,APP_URL,API_URL. Recommended:METRICS_TOKEN.Deploy.
vercel.jsonrewrites API, OAuth, MCP, and discovery routes to the serverless function and serves the React SPA for other paths.Seed MongoDB Atlas from your machine:
npm run seedwithMONGODB_URIpointing at Atlas.Log in with
ADMIN_EMAIL/ADMIN_PASSWORD.
Production URLs
App:
https://mcpcontroller.vercel.app/Health:
https://mcpcontroller.vercel.app/api/healthOAuth metadata:
https://mcpcontroller.vercel.app/.well-known/oauth-authorization-serverProtected resource:
https://mcpcontroller.vercel.app/.well-known/oauth-protected-resourceMCP:
https://mcpcontroller.vercel.app/mcp
Connecting ChatGPT
In ChatGPT, add an MCP server with URL:
https://mcpcontroller.vercel.app/mcpChatGPT discovers OAuth metadata automatically.
Click Connect — you are redirected to log in (or reuse an existing session).
Review permissions on the consent page and click Allow & Connect.
ChatGPT receives tokens and can call doctor management tools within granted scopes.
To disconnect, open the dashboard and click Revoke access for the connection.
Project structure
MCPController/
├── api/index.js # Vercel serverless entry
├── client/ # React frontend (Vite)
├── server/
│ ├── app.js # Express app
│ ├── config/ # env, database
│ ├── controllers/ # route handlers
│ ├── middleware/ # auth, errors, permissions
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express routers
│ ├── services/ # business logic
│ ├── mcp/ # MCP server + tools
│ └── seed/ # database seed script
├── tests/
├── vercel.json
└── package.jsonSecurity notes
OAuth tokens are SHA-256 hashed before storage.
PKCE S256 is required for authorization code flow.
Redirect URIs are validated exactly against registered client metadata (including CIMD clients like ChatGPT).
MCP resource indicator (
resourceparameter) must match/mcp.Revocation from the dashboard marks all matching access tokens as revoked immediately.
Admin credentials live only in environment variables — not in the client bundle.
This server cannot be deployed
Maintenance
Related MCP Connectors
OAuth 2.1 short-link tools for AI agents with scoped tokens, approvals, audit logs, and revocation.
OAuth Multi-LLM Orchestrator
Connect AI agents to Filepad workspaces through OAuth MCP.
Create, publish and measure SparkleTree marketing campaigns from an AI client. OAuth 2.1 with PKCE.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA complete ChatGPT App implementation using MCP with OAuth2 authentication via Privy.io, enabling secure user authentication and interactive widgets rendered in ChatGPT.28 npm-
- FlicenseNot gradedqualityBmaintenanceEnables ChatGPT custom MCP clients to securely connect to McDonald's China official MCP using OAuth 2.1 + PKCE, while blocking order creation and sensitive write actions by default.-
- FlicenseNot gradedqualityBmaintenanceEnables inspecting and managing a Cloudflare account from MCP-compatible clients, with OAuth/PKCE support and a read-only mode for ChatGPT, plus a legacy bearer-token path for full tool access.-
- AlicenseNot gradedqualityBmaintenanceEnables coding agents like Codex to use the ChatGPT web app as a planning and review brain, letting ChatGPT read only needed code via OAuth MCP and submit locally authorized tasks without API keys or repository uploads.2MIT