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
> **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http).
466
+
467
+
By default, SSE servers are mounted at `/sse` and Streamable HTTP servers are mounted at `/mcp`. You can customize these paths using the methods described below.
468
+
392
469
You can mount the SSE server to an existing ASGI server using the `sse_app` method. This allows you to integrate the SSE server with other ASGI applications.
Caution: The `mcp run` and `mcp dev` tool doesn't support low-level server.
700
+
585
701
### Writing MCP Clients
586
702
587
-
The SDK provides a high-level client interface for connecting to MCP servers:
703
+
The SDK provides a high-level client interface for connecting to MCP servers using various [transports](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports):
588
704
589
705
```python
590
706
from mcp import ClientSession, StdioServerParameters, types
@@ -648,6 +764,28 @@ if __name__ == "__main__":
648
764
asyncio.run(run())
649
765
```
650
766
767
+
Clients can also connect using [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http):
768
+
769
+
```python
770
+
from mcp.client.streamable_http import streamablehttp_client
771
+
from mcp import ClientSession
772
+
773
+
774
+
asyncdefmain():
775
+
# Connect to a streamable HTTP server
776
+
asyncwith streamablehttp_client("example/mcp") as (
777
+
read_stream,
778
+
write_stream,
779
+
_,
780
+
):
781
+
# Create a session using the client streams
782
+
asyncwith ClientSession(read_stream, write_stream) as session:
Copy file name to clipboardExpand all lines: examples/clients/simple-chatbot/README.MD
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
25
25
```plaintext
26
26
LLM_API_KEY=your_api_key_here
27
27
```
28
+
**Note:** The current implementation is configured to use the Groq API endpoint (`https://api.groq.com/openai/v1/chat/completions`) with the `llama-3.2-90b-vision-preview` model. If you plan to use a different LLM provider, you'll need to modify the `LLMClient` class in `main.py` to use the appropriate endpoint URL and model parameters.
# Simple MCP Server with GitHub OAuth Authentication
2
+
3
+
This is a simple example of an MCP server with GitHub OAuth authentication. It demonstrates the essential components needed for OAuth integration with just a single tool.
4
+
5
+
This is just an example of a server that uses auth, an official GitHub mcp server is [here](https://github.com/github/github-mcp-server)
6
+
7
+
## Overview
8
+
9
+
This simple demo to show to set up a server with:
10
+
- GitHub OAuth2 authorization flow
11
+
- Single tool: `get_user_profile` to retrieve GitHub user information
12
+
13
+
14
+
## Prerequisites
15
+
16
+
1. Create a GitHub OAuth App:
17
+
- Go to GitHub Settings > Developer settings > OAuth Apps > New OAuth App
18
+
- Application name: Any name (e.g., "Simple MCP Auth Demo")
The server will not start without these environment variables properly set.
34
+
35
+
36
+
## Running the Server
37
+
38
+
```bash
39
+
# Set environment variables first (see above)
40
+
41
+
# Run the server
42
+
uv run mcp-simple-auth
43
+
```
44
+
45
+
The server will start on `http://localhost:8000`.
46
+
47
+
### Transport Options
48
+
49
+
This server supports multiple transport protocols that can run on the same port:
50
+
51
+
#### SSE (Server-Sent Events) - Default
52
+
```bash
53
+
uv run mcp-simple-auth
54
+
# or explicitly:
55
+
uv run mcp-simple-auth --transport sse
56
+
```
57
+
58
+
SSE transport provides endpoint:
59
+
-`/sse`
60
+
61
+
#### Streamable HTTP
62
+
```bash
63
+
uv run mcp-simple-auth --transport streamable-http
64
+
```
65
+
66
+
Streamable HTTP transport provides endpoint:
67
+
-`/mcp`
68
+
69
+
70
+
This ensures backward compatibility without needing multiple server instances. When using SSE transport (`--transport sse`), only the `/sse` endpoint is available.
71
+
72
+
## Available Tool
73
+
74
+
### get_user_profile
75
+
76
+
The only tool in this simple example. Returns the authenticated user's GitHub profile information.
77
+
78
+
**Required scope**: `user`
79
+
80
+
**Returns**: GitHub user profile data including username, email, bio, etc.
81
+
82
+
83
+
## Troubleshooting
84
+
85
+
If the server fails to start, check:
86
+
1. Environment variables `MCP_GITHUB_GITHUB_CLIENT_ID` and `MCP_GITHUB_GITHUB_CLIENT_SECRET` are set
87
+
2. The GitHub OAuth app callback URL matches `http://localhost:8000/github/callback`
88
+
3. No other service is using port 8000
89
+
4. The transport specified is valid (`sse` or `streamable-http`)
90
+
91
+
You can use [Inspector](https://github.com/modelcontextprotocol/inspector) to test Auth
0 commit comments