Skip to content

Commit a027d75

Browse files
ihrprpraboud-antdsp-antbhosmer-antpcarleton
authored
Auth SSE simple server example (#610)
Co-authored-by: Peter Raboud <praboud@anthropic.com> Co-authored-by: David Soria Parra <davidsp@anthropic.com> Co-authored-by: Basil Hosmer <basil@anthropic.com> Co-authored-by: Paul Carleton <paulc@anthropic.com> Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
1 parent a1307ab commit a027d75

File tree

7 files changed

+515
-1
lines changed

7 files changed

+515
-1
lines changed
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 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")
19+
- Homepage URL: `http://localhost:8000`
20+
- Authorization callback URL: `http://localhost:8000/github/callback`
21+
- Click "Register application"
22+
- Note down your Client ID and Client Secret
23+
24+
## Required Environment Variables
25+
26+
You MUST set these environment variables before running the server:
27+
28+
```bash
29+
export MCP_GITHUB_GITHUB_CLIENT_ID="your_client_id_here"
30+
export MCP_GITHUB_GITHUB_CLIENT_SECRET="your_client_secret_here"
31+
```
32+
33+
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+
## Available Tool
48+
49+
### get_user_profile
50+
51+
The only tool in this simple example. Returns the authenticated user's GitHub profile information.
52+
53+
**Required scope**: `user`
54+
55+
**Returns**: GitHub user profile data including username, email, bio, etc.
56+
57+
58+
## Troubleshooting
59+
60+
If the server fails to start, check:
61+
1. Environment variables `MCP_GITHUB_GITHUB_CLIENT_ID` and `MCP_GITHUB_GITHUB_CLIENT_SECRET` are set
62+
2. The GitHub OAuth app callback URL matches `http://localhost:8000/github/callback`
63+
3. No other service is using port 8000
64+
65+
You can use [Inspector](https://github.com/modelcontextprotocol/inspector) to test Auth
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Simple MCP server with GitHub OAuth authentication."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Main entry point for simple MCP server with GitHub OAuth authentication."""
2+
3+
import sys
4+
5+
from mcp_simple_auth.server import main
6+
7+
sys.exit(main())

0 commit comments

Comments
 (0)