Skip to content

Commit e8fb1a9

Browse files
committed
feat: add /oauth/status diagnostic endpoint for deployment verification
Exposes database column state, pending request counts, and auth configuration status. Proxied through Fastify to the MCP Express server for external accessibility. Made-with: Cursor
1 parent 0840ada commit e8fb1a9

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/mcp-server.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,35 @@ export function startMcpServer(config: McpServerConfig, port: number): void {
598598
});
599599
});
600600

601+
// Diagnostic endpoint (proxied via /oauth/status)
602+
app.get("/oauth/status", (_req, res) => {
603+
try {
604+
const pendingCount = (db.prepare(`SELECT COUNT(*) as c FROM oauth_pending_requests`).get() as { c: number }).c;
605+
const clientCount = (db.prepare(`SELECT COUNT(*) as c FROM oauth_clients`).get() as { c: number }).c;
606+
const tokenCount = (db.prepare(`SELECT COUNT(*) as c FROM oauth_tokens`).get() as { c: number }).c;
607+
const codesCols = (db.prepare(`PRAGMA table_info(oauth_codes)`).all() as { name: string }[]).map(c => c.name);
608+
const tokensCols = (db.prepare(`PRAGMA table_info(oauth_tokens)`).all() as { name: string }[]).map(c => c.name);
609+
const pendingCols = (db.prepare(`PRAGMA table_info(oauth_pending_requests)`).all() as { name: string }[]).map(c => c.name);
610+
res.json({
611+
status: "ok",
612+
has_user_id_cols: hasUserIdColumns(),
613+
service_key_configured: (dashboardServiceKey?.length ?? 0) > 0,
614+
jwt_secret_configured: (dashboardJwtSecret?.length ?? 0) > 0,
615+
db: {
616+
pending_requests: pendingCount,
617+
clients: clientCount,
618+
tokens: tokenCount,
619+
codes_has_user_id: codesCols.includes("user_id"),
620+
tokens_has_user_id: tokensCols.includes("user_id"),
621+
pending_has_user_id: pendingCols.includes("user_id"),
622+
},
623+
sessions: Object.keys(transports).length,
624+
});
625+
} catch (err) {
626+
res.status(500).json({ error: (err as Error).message });
627+
}
628+
});
629+
601630
const vendors = Object.keys(agentKeys);
602631
app.listen(port, "0.0.0.0", () => {
603632
console.log(`MCP server listening on port ${port} (vendors: ${vendors.join(", ")})`);

src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ export async function createServer(config: ServerConfig): Promise<FastifyInstanc
446446
"/register",
447447
"/oauth/approve",
448448
"/oauth/approve-s2s",
449+
"/oauth/status",
449450
];
450451
for (const oauthPath of oauthPaths) {
451452
await server.register(proxy, {

0 commit comments

Comments
 (0)