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

Commit 76272d9

Browse files
committed
feat: add React integration and OAuth authentication support
- Add React hooks and components for MCP integration - Implement OAuth authentication with browser provider - Add auth callback handling and types - Update examples to use new React components - Add utility functions for assertions - Update package configurations and dependencies
1 parent 4d0d018 commit 76272d9

22 files changed

Lines changed: 2637 additions & 2262 deletions

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"@typescript-eslint/eslint-plugin": "^8.0.0",
2020
"@typescript-eslint/parser": "^8.0.0",
2121
"eslint": "^9.28.0",
22-
"@eslint/js": "^9.28.0",
2322
"eslint-import-resolver-typescript": "^4.4.4",
2423
"eslint-plugin-import": "^2.32.0",
2524
"husky": "^9.1.7",
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import React from 'react'
2-
import { createRoot } from 'react-dom/client'
2+
import ReactDOM from 'react-dom/client'
33
import ReactExample from './react_example'
4+
import OAuthCallback from './oauth-callback'
45

5-
const container = document.getElementById('root')
6-
if (container) {
7-
const root = createRoot(container)
8-
root.render(<ReactExample />)
9-
}
10-
else {
11-
console.error('Root element not found')
6+
// Simple router based on pathname
7+
function App() {
8+
const path = window.location.pathname
9+
10+
// Route to OAuth callback page
11+
if (path === '/oauth/callback') {
12+
return <OAuthCallback />
13+
}
14+
15+
// Default to main example
16+
return <ReactExample />
1217
}
18+
19+
ReactDOM.createRoot(document.getElementById('root')!).render(
20+
<React.StrictMode>
21+
<App />
22+
</React.StrictMode>,
23+
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { onMcpAuthorization } from 'mcp-use/react'
2+
import { useEffect } from 'react'
3+
4+
/**
5+
* OAuth callback page for MCP authentication
6+
* This page handles the OAuth redirect and exchanges the authorization code for tokens
7+
*/
8+
export default function OAuthCallback() {
9+
useEffect(() => {
10+
// Handle the OAuth callback when the component mounts
11+
onMcpAuthorization()
12+
}, [])
13+
14+
return (
15+
<div style={{
16+
padding: '40px',
17+
fontFamily: 'Arial, sans-serif',
18+
textAlign: 'center',
19+
maxWidth: '600px',
20+
margin: '0 auto',
21+
}}>
22+
<h1>🔐 Authenticating...</h1>
23+
<p>Please wait while we complete your authentication.</p>
24+
<p style={{ color: '#6c757d', fontSize: '0.9em' }}>
25+
This window should close automatically once authentication is complete.
26+
</p>
27+
28+
<div style={{
29+
marginTop: '30px',
30+
padding: '20px',
31+
backgroundColor: '#f8f9fa',
32+
borderRadius: '8px',
33+
fontSize: '0.9em',
34+
}}>
35+
<p>If this window doesn't close automatically, you can close it manually and return to the main application.</p>
36+
</div>
37+
</div>
38+
)
39+
}
40+

0 commit comments

Comments
 (0)