Skip to content

Example Auth client #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged

Example Auth client #526

merged 3 commits into from
May 22, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented May 21, 2025

Adding example of client with auth for testing and demo purposes:

to run

npx tsx src/examples/client/simpleOAuthClient.js

Output:

Simple MCP OAuth Client
Connecting to: http://localhost:3000/mcp

🔗 Attempting to connect to http://localhost:3000/mcp...
🔐 Creating OAuth provider...
🔐 OAuth provider created
👤 Creating MCP client...
👤 Client created
🔐 Starting OAuth flow...
🚢 Creating transport with OAuth provider...
🚢 Transport created
🔌 Attempting connection (this will trigger OAuth redirect)...
📌 OAuth redirect handler called - opening browser
Opening browser to: http://localhost:3001/authorize?response_type=code&client_id=39357645-601a-432a-8f09-2c1bf9a34e76&code_challenge=my6jCjq2YifKYagEHQlRYOBWt-76bUOBfN5-I2Q9WUA&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A8090%2Fcallback&scope=mcp%3Atools
🌐 Opening browser for authorization: http://localhost:3001/authorize?response_type=code&client_id=39357645-601a-432a-8f09-2c1bf9a34e76&code_challenge=my6jCjq2YifKYagEHQlRYOBWt-76bUOBfN5-I2Q9WUA&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A8090%2Fcallback&scope=mcp%3Atools
🔐 OAuth required - waiting for authorization...
OAuth callback server started on http://localhost:8090
📥 Received callback: /callback?code=e395268a-66e4-4ab3-9457-52a15979f5fa
✅ Authorization code received: e395268a-6...
🔐 Authorization code received: e395268a-66e4-4ab3-9457-52a15979f5fa
🔌 Reconnecting with authenticated transport...
🚢 Creating transport with OAuth provider...
🚢 Transport created
🔌 Attempting connection (this will trigger OAuth redirect)...
✅ Connected successfully

🎯 Interactive MCP Client with OAuth
Commands:
  list - List available tools
  call <tool_name> [args] - Call a tool
  quit - Exit the client

mcp>

@ihrpr ihrpr requested a review from pcarleton May 21, 2025 15:31

if (platform === 'darwin') {
command = `open "${url}"`;
} else if (platform === 'win32') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not confident in the non-mac ones 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't have a way to tests it and don't think it's worth spending time on spinning up a vm, removing for now

@bhosmer-ant bhosmer-ant self-requested a review May 21, 2025 20:32
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ihrpr ihrpr merged commit 3d76bbe into main May 22, 2025
5 checks passed
@ihrpr ihrpr deleted the ihrpr/auth-example-client3 branch May 22, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants