Skip to content

Commit 7e0dfaf

Browse files
committed
Update naming and docs for client credentials example
1 parent fe548e5 commit 7e0dfaf

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

examples/clients/simple-auth-client-client-credentials/README.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
# Simple Auth Client Example
22

3-
A demonstration of how to use the MCP Python SDK with OAuth authentication over streamable HTTP or SSE transport.
3+
A demonstration of how to use the MCP Python SDK with OAuth authentication using client credentials over streamable HTTP or SSE transport.
4+
This example demonstrates integration with an authorization server that does not implement Dynamic Client Registration.
45

56
## Features
67

7-
- OAuth 2.0 authentication with PKCE
8+
- OAuth 2.0 authentication with the `client_credentials` flow
89
- Support for both StreamableHTTP and SSE transports
910
- Interactive command-line interface
1011

1112
## Installation
1213

1314
```bash
14-
cd examples/clients/simple-auth-client
15-
uv sync --reinstall
15+
cd examples/clients/simple-auth-client-client-credentials
16+
uv sync --reinstall
1617
```
1718

1819
## Usage
1920

20-
### 1. Start an MCP server with OAuth support
21+
### 1. Start an MCP server with OAuth support using client credentials
2122

2223
```bash
23-
# Example with mcp-simple-auth
24-
cd path/to/mcp-simple-auth
25-
uv run mcp-simple-auth --transport streamable-http --port 3001
24+
# Example with mcp-simple-auth-client-credentials
25+
cd path/to/mcp-simple-auth-client-credentials
26+
uv run mcp-simple-auth-client-credentials --transport streamable-http --port 3001
2627
```
2728

2829
### 2. Run the client
@@ -39,22 +40,32 @@ MCP_TRANSPORT_TYPE=sse uv run mcp-simple-auth-client
3940

4041
### 3. Complete OAuth flow
4142

42-
The client will open your browser for authentication. After completing OAuth, you can use commands:
43+
The client will automatically authenticate using dummy client credentials for the demo authorization server. After completing OAuth, you can use commands:
4344

4445
- `list` - List available tools
45-
- `call <tool_name> [args]` - Call a tool with optional JSON arguments
46+
- `call <tool_name> [args]` - Call a tool with optional JSON arguments
4647
- `quit` - Exit
4748

4849
## Example
4950

5051
```
51-
🔐 Simple MCP Auth Client
52-
Connecting to: http://localhost:3001
53-
54-
Please visit the following URL to authorize the application:
55-
http://localhost:3001/authorize?response_type=code&client_id=...
56-
57-
✅ Connected to MCP server at http://localhost:3001
52+
🚀 Simple MCP Auth Client
53+
Connecting to: http://localhost:8001/mcp
54+
Transport type: streamable_http
55+
🔗 Attempting to connect to http://localhost:8001/mcp...
56+
📡 Opening StreamableHTTP transport connection with auth...
57+
🤝 Initializing MCP session...
58+
⚡ Starting session initialization...
59+
✨ Session initialization complete!
60+
61+
✅ Connected to MCP server at http://localhost:8001/mcp
62+
Session ID: ...
63+
64+
🎯 Interactive MCP Client
65+
Commands:
66+
list - List available tools
67+
call <tool_name> [args] - Call a tool
68+
quit - Exit the client
5869
5970
mcp> list
6071
📋 Available tools:

examples/servers/simple-auth-client-credentials/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,3 @@ curl -v http://localhost:8001/.well-known/oauth-protected-resource
102102
# Test Authorization Server metadata
103103
curl -v http://localhost:9000/.well-known/oauth-authorization-server
104104
```
105-
106-
### Test Token Introspection
107-
108-
```bash
109-
# After getting a token through OAuth flow:
110-
curl -X POST http://localhost:9000/introspect \
111-
-H "Content-Type: application/x-www-form-urlencoded" \
112-
-d "token=your_access_token"
113-
```

examples/servers/simple-auth-client-credentials/mcp_simple_auth_client_credentials/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from mcp.server.auth.settings import AuthSettings
1818
from mcp.server.fastmcp.server import FastMCP
1919

20-
from .token_verifier import IntrospectionTokenVerifier
20+
from .token_verifier import PartialIntrospectionTokenVerifier
2121

2222
logger = logging.getLogger(__name__)
2323

@@ -52,8 +52,8 @@ def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
5252
Create MCP Resource Server.
5353
"""
5454

55-
# Create token verifier for introspection with RFC 8707 resource validation
56-
token_verifier = IntrospectionTokenVerifier(
55+
# Create partial token verifier
56+
token_verifier = PartialIntrospectionTokenVerifier(
5757
introspection_endpoint=settings.auth_server_introspection_endpoint,
5858
server_url=str(settings.server_url),
5959
)

examples/servers/simple-auth-client-credentials/mcp_simple_auth_client_credentials/token_verifier.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Example token verifier implementation using OAuth 2.0 Token Introspection (RFC 7662)."""
1+
"""Example token verifier implementation."""
22

33
import logging
44
from datetime import datetime
@@ -9,8 +9,13 @@
99
logger = logging.getLogger(__name__)
1010

1111

12-
class IntrospectionTokenVerifier(TokenVerifier):
13-
"""Example token verifier that uses OAuth 2.0 Token Introspection (RFC 7662)."""
12+
class PartialIntrospectionTokenVerifier(TokenVerifier):
13+
"""
14+
Example token verifier.
15+
16+
Discord doesn't actually support token introspection, but this is required by FastMCP, so
17+
we shim a non-strict verifier on top of it that leverages the "current application" endpoint.
18+
"""
1419

1520
def __init__(
1621
self,

0 commit comments

Comments
 (0)