python-sdk/examples/clients/simple-auth-client
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Paul Carleton f22501315e
feat: implement SEP-991 URL-based client ID (CIMD) support (#1652)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
2025-11-24 17:21:03 +00:00
..
mcp_simple_auth_client feat: implement SEP-991 URL-based client ID (CIMD) support (#1652) 2025-11-24 17:21:03 +00:00
pyproject.toml fix: replace deprecated dev-dependencies in examples/clients (#1518) 2025-10-28 14:09:14 +00:00
README.md Use streamable-http consistently in examples (#1389) 2025-09-23 20:19:14 +01:00

Simple Auth Client Example

A demonstration of how to use the MCP Python SDK with OAuth authentication over streamable HTTP or SSE transport.

Features

  • OAuth 2.0 authentication with PKCE
  • Support for both StreamableHTTP and SSE transports
  • Interactive command-line interface

Installation

cd examples/clients/simple-auth-client
uv sync --reinstall 

Usage

1. Start an MCP server with OAuth support

# Example with mcp-simple-auth
cd path/to/mcp-simple-auth
uv run mcp-simple-auth --transport streamable-http --port 3001

2. Run the client

uv run mcp-simple-auth-client

# Or with custom server URL
MCP_SERVER_PORT=3001 uv run mcp-simple-auth-client

# Use SSE transport
MCP_TRANSPORT_TYPE=sse uv run mcp-simple-auth-client

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
  • quit - Exit

Example

🔐 Simple MCP Auth Client
Connecting to: http://localhost:3001

Please visit the following URL to authorize the application:
http://localhost:3001/authorize?response_type=code&client_id=...

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

mcp> list
📋 Available tools:
1. echo - Echo back the input text

mcp> call echo {"text": "Hello, world!"}
🔧 Tool 'echo' result:
Hello, world!

mcp> quit
👋 Goodbye!

Configuration

  • MCP_SERVER_PORT - Server URL (default: 8000)
  • MCP_TRANSPORT_TYPE - Transport type: streamable-http (default) or sse