Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions examples/clients/simple-auth-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,38 @@ uv run mcp-simple-auth --transport streamable-http --port 3001
### 2. Run the client

```bash
# Connect to default server (http://localhost:8000/mcp)
uv run mcp-simple-auth-client

# Or with custom server URL
MCP_SERVER_PORT=3001 uv run mcp-simple-auth-client
# Connect to a custom server URL
uv run mcp-simple-auth-client --url http://localhost:3001/mcp

# Use SSE transport
MCP_TRANSPORT_TYPE=sse uv run mcp-simple-auth-client
uv run mcp-simple-auth-client --url http://localhost:3001/sse --transport sse

# View all options
uv run mcp-simple-auth-client --help
```

### 3. Complete OAuth flow

The client will open your browser for authentication. After completing OAuth, you can use commands:

- `list` - List available tools
- `call <tool_name> [args]` - Call a tool with optional JSON arguments
- `call <tool_name> [args]` - Call a tool with optional JSON arguments
- `quit` - Exit

## Example

```markdown
🔐 Simple MCP Auth Client
Connecting to: http://localhost:3001
🚀 Simple MCP Auth Client
Connecting to: http://localhost:8001/mcp
Transport type: streamable-http

Please visit the following URL to authorize the application:
http://localhost:3001/authorize?response_type=code&client_id=...
🔗 Attempting to connect to http://localhost:8001/mcp...
Opening browser for authorization: http://localhost:9000/authorize?...

✅ Connected to MCP server at http://localhost:3001
✅ Connected to MCP server at http://localhost:8001/mcp

mcp> list
📋 Available tools:
Expand All @@ -68,7 +73,7 @@ mcp> quit
👋 Goodbye!
```

## Configuration
## Command Line Options

- `MCP_SERVER_PORT` - Server URL (default: 8000)
- `MCP_TRANSPORT_TYPE` - Transport type: `streamable-http` (default) or `sse`
- `--url` - Full URL of the MCP server (default: `http://localhost:8000/mcp`)
- `--transport` - Transport type: `streamable-http` (default) or `sse`
34 changes: 22 additions & 12 deletions examples/clients/simple-auth-client/mcp_simple_auth_client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

"""

import argparse
import asyncio
import os
import threading
import time
import webbrowser
Expand Down Expand Up @@ -331,22 +331,32 @@ async def interactive_loop(self):

async def main():
"""Main entry point."""
# Default server URL - can be overridden with environment variable
# Most MCP streamable HTTP servers use /mcp as the endpoint
server_url = os.getenv("MCP_SERVER_PORT", 8000)
transport_type = os.getenv("MCP_TRANSPORT_TYPE", "streamable-http")
server_url = (
f"http://localhost:{server_url}/mcp"
if transport_type == "streamable-http"
else f"http://localhost:{server_url}/sse"
parser = argparse.ArgumentParser(
description="Simple MCP client with OAuth authentication support",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--url",
type=str,
default="http://localhost:8000/mcp",
help="Full URL of the MCP server",
)
parser.add_argument(
"--transport",
type=str,
choices=["streamable-http", "sse"],
default="streamable-http",
help="Transport type to use",
)

args = parser.parse_args()

print("🚀 Simple MCP Auth Client")
print(f"Connecting to: {server_url}")
print(f"Transport type: {transport_type}")
print(f"Connecting to: {args.url}")
print(f"Transport type: {args.transport}")

# Start connection flow - OAuth will be handled automatically
client = SimpleAuthClient(server_url, transport_type)
client = SimpleAuthClient(args.url, args.transport)
await client.connect()


Expand Down
4 changes: 2 additions & 2 deletions examples/servers/simple-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uv run mcp-simple-auth-rs --port=8001 --auth-server=http://localhost:9000 --tra
```bash
cd examples/clients/simple-auth-client
# Start client with streamable HTTP
MCP_SERVER_PORT=8001 MCP_TRANSPORT_TYPE=streamable-http uv run mcp-simple-auth-client
uv run mcp-simple-auth-client --url http://localhost:8001/mcp --transport streamable-http
```

## How It Works
Expand Down Expand Up @@ -101,7 +101,7 @@ uv run mcp-simple-auth-legacy --port=8002
```bash
# Test with client (will automatically fall back to legacy discovery)
cd examples/clients/simple-auth-client
MCP_SERVER_PORT=8002 MCP_TRANSPORT_TYPE=streamable-http uv run mcp-simple-auth-client
uv run mcp-simple-auth-client --url http://localhost:8002/mcp --transport streamable-http
```

The client will:
Expand Down