Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 78f0e36

Browse files
committed
Implement OAuth callback support for MCP servers
- Add react-router-dom dependency for routing support - Create OAuthCallback component with animated background and loading spinner - Add routing to App.tsx with /oauth/callback route - Match styling with main app using animated-bg-container - Use onMcpAuthorization from use-mcp library for OAuth handling - Library already handles multiple server differentiation via state parameter - Each MCP server gets unique OAuth flow identified by state containing server URL - Clean up unused imports and variables in McpServerModal
1 parent 32a6bf5 commit 78f0e36

File tree

5 files changed

+78
-5
lines changed

5 files changed

+78
-5
lines changed

examples/chat-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"react": "^19.0.0",
2727
"react-dom": "^19.0.0",
2828
"react-markdown": "^10.1.0",
29+
"react-router-dom": "^7.6.2",
2930
"rehype-highlight": "^7.0.2",
3031
"remark-gfm": "^4.0.1",
3132
"tailwindcss": "^4.0.14",

examples/chat-ui/pnpm-lock.yaml

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/chat-ui/src/App.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
12
import ChatApp from "./components/ChatApp";
3+
import { OAuthCallback } from "./components/OAuthCallback";
24

35
function App() {
46
return (
5-
<>
6-
<ChatApp />
7-
</>
7+
<Router>
8+
<Routes>
9+
<Route path="/oauth/callback" element={<OAuthCallback />} />
10+
<Route path="/" element={<ChatApp />} />
11+
</Routes>
12+
</Router>
813
);
914
}
1015

examples/chat-ui/src/components/McpServerModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useRef, useEffect } from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { X, Info, Settings, Plus, Trash2, Power, PowerOff } from 'lucide-react'
33
import { useMcp, type Tool } from 'use-mcp/react'
44

@@ -63,7 +63,7 @@ const McpServerModal: React.FC<McpServerModalProps> = ({
6363
const stored = localStorage.getItem('mcpServerToolCounts')
6464
return stored ? JSON.parse(stored) : {}
6565
})
66-
const logRef = useRef<HTMLDivElement>(null)
66+
// const logRef = useRef<HTMLDivElement>(null) // Removed for now as debug logs not implemented in multi-server version
6767

6868
// Save servers to localStorage whenever they change
6969
useEffect(() => {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useEffect } from 'react'
2+
import { onMcpAuthorization } from 'use-mcp'
3+
4+
export function OAuthCallback() {
5+
useEffect(() => {
6+
onMcpAuthorization()
7+
}, [])
8+
9+
return (
10+
<div className="min-h-screen animated-bg-container flex items-center justify-center p-4">
11+
<div className="bg-white rounded-lg shadow-xl p-8 text-center max-w-md w-full">
12+
<h1 className="text-2xl font-bold text-zinc-900 mb-4">Authenticating...</h1>
13+
<p className="text-zinc-600 mb-2">Please wait while we complete your authentication.</p>
14+
<p className="text-sm text-zinc-500">This window should close automatically.</p>
15+
16+
<div className="mt-6">
17+
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"></div>
18+
</div>
19+
</div>
20+
</div>
21+
)
22+
}

0 commit comments

Comments
 (0)