MCPcopy Index your code
hub / github.com/simstudioai/sim / htmlClose

Function htmlClose

apps/sim/app/api/mcp/oauth/callback/route.ts:42–57  ·  view source on GitHub ↗
(
  message: string,
  ok: boolean,
  reason: McpOauthCallbackReason,
  serverId?: string
)

Source from the content-addressed store, hash-verified

40}
41
42function htmlClose(
43 message: string,
44 ok: boolean,
45 reason: McpOauthCallbackReason,
46 serverId?: string
47): NextResponse {
48 const safeMessage = escapeHtml(message)
49 const title = ok ? 'Connected' : 'Connection failed'
50 const body = `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title></head><body style="font-family: system-ui; padding: 24px"><p>${safeMessage}</p><script>
51 try { window.opener && window.opener.postMessage({ type: 'mcp-oauth', ok: ${ok ? 'true' : 'false'}, serverId: ${jsonLiteral(serverId)}, reason: ${jsonLiteral(reason)} }, window.location.origin) } catch (e) {}
52 setTimeout(function () { window.close() }, 800)
53 </script></body></html>`
54 return new NextResponse(body, {
55 headers: { 'Content-Type': 'text/html; charset=utf-8' },
56 })
57}
58
59export const GET = withRouteHandler(async (request: NextRequest) => {
60 const parsed = await parseRequest(mcpOauthCallbackContract, request, {})

Callers 1

route.tsFile · 0.85

Calls 2

jsonLiteralFunction · 0.85
escapeHtmlFunction · 0.70

Tested by

no test coverage detected