You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example demonstrates how to use the MCP Python SDK to create a client that connects to an MCP server using OAuth authentication over streamable HTTP transport.
3
+
A demonstration of how to use the MCP Python SDK with OAuth authentication over streamable HTTP transport.
4
4
5
5
## Features
6
6
7
7
- OAuth 2.0 authentication with PKCE
8
8
- Streamable HTTP transport
9
9
- Interactive command-line interface
10
-
- Tool listing and execution
11
-
12
-
## Prerequisites
13
-
14
-
1. Python 3.9 or higher
15
-
2. An MCP server that supports OAuth authentication (like `mcp-simple-auth`)
16
-
3. uv for dependency management
17
10
18
11
## Installation
19
12
20
13
```bash
21
14
cd examples/clients/simple-auth-client
22
-
uv install
15
+
uv sync --reinstall
23
16
```
24
17
25
18
## Usage
26
19
27
-
### 1. Start the Auth Server
28
-
29
-
First, start the MCP auth server in another terminal:
20
+
### 1. Start an MCP server with OAuth support
30
21
31
22
```bash
23
+
# Example with mcp-simple-auth
32
24
cd path/to/mcp-simple-auth
33
25
uv run mcp-simple-auth --transport streamable-http --port 3001
34
26
```
35
27
36
-
### 2. Run the Client
28
+
### 2. Run the client
37
29
38
30
```bash
39
-
# Run the client
40
31
uv run mcp-simple-auth-client
41
32
42
33
# Or with custom server URL
43
34
MCP_SERVER_URL=http://localhost:3001 uv run mcp-simple-auth-client
44
35
```
45
36
46
-
### 3. Authentication Flow
47
-
48
-
1. The client will attempt to connect to the server
49
-
2. If authentication is required, the client will open your default browser
50
-
3. Complete the OAuth flow in the browser
51
-
4. Return to the client - it should now be connected
52
-
53
-
### 4. Interactive Commands
37
+
### 3. Complete OAuth flow
54
38
55
-
Once connected, you can use these commands:
39
+
The client will open your browser for authentication. After completing OAuth, you can use commands:
56
40
57
-
-`list` - List available tools from the server
58
-
-`call <tool_name> [args]` - Call a tool with optional JSON arguments
59
-
-`quit` - Exit the client
41
+
-`list` - List available tools
42
+
-`call <tool_name> [args]` - Call a tool with optional JSON arguments
43
+
-`quit` - Exit
60
44
61
-
###Example Session
45
+
## Example
62
46
63
47
```
64
-
=� Simple MCP Auth Client
48
+
🔐 Simple MCP Auth Client
65
49
Connecting to: http://localhost:3001
66
50
67
51
Please visit the following URL to authorize the application:
0 commit comments