|
1 | 1 | # MCP Auth 🔐 |
| 2 | + |
| 3 | +👨💼 Hello, my name is Peter the Product Manager. I'm here to help you get |
| 4 | +oriented and to give you your assignments for the workshop! |
| 5 | + |
| 6 | +Welcome to **MCP Auth**! In this workshop, you'll master authentication and authorization for |
| 7 | +[Model Context Protocol (MCP)](https://modelcontextprotocol.io/specification/2025-06-18) servers—the essential skills for building secure, production-ready MCP applications that handle real user data. |
| 8 | + |
| 9 | +The Model Context Protocol is powerful, but without proper authentication, your MCP servers can only provide public data. To build truly useful applications—journaling apps, document managers, personal assistants—you need to securely identify users and control access to their private resources. |
| 10 | + |
| 11 | +```mermaid |
| 12 | +flowchart TB |
| 13 | + subgraph "OAuth Authentication Flow" |
| 14 | + Host["Host Application<br/>(VS Code, Claude Desktop, etc.)<br/>with MCP Client"] |
| 15 | + Auth["Authorization Server"] |
| 16 | + Resource["MCP Server<br/>(Resource Server)"] |
| 17 | +
|
| 18 | + Host -->|"1. Authorize & get token"| Auth |
| 19 | + Auth -->|"2. Access token"| Host |
| 20 | + Host -->|"3. MCP request + token"| Resource |
| 21 | + Resource -->|"4. Validate token"| Auth |
| 22 | + Auth -->|"5. Token info"| Resource |
| 23 | + Resource -->|"6. Protected MCP response"| Host |
| 24 | + end |
| 25 | +``` |
| 26 | + |
| 27 | +We're focused on the Resource Server in this workshop. That's the MCP server |
| 28 | +that you're building and will be the most valuable information for you as a |
| 29 | +developer of MCP servers. |
| 30 | + |
| 31 | +Throughout this workshop, you'll learn: |
| 32 | + |
| 33 | +- **Service Discovery**: Implement OAuth metadata endpoints that let clients automatically discover how to authenticate with your MCP server |
| 34 | +- **Authorization Headers**: Properly handle OAuth Bearer tokens and provide clear authentication challenges when tokens are missing or invalid |
| 35 | +- **Token Introspection**: Validate access tokens and extract user information using industry-standard OAuth 2.0 introspection |
| 36 | +- **User Context**: Pass authenticated user information through your MCP server to ensure all operations are properly scoped to the current user |
| 37 | +- **Scope-based Permissions**: Implement fine-grained access control using OAuth scopes to protect sensitive operations and data |
| 38 | + |
| 39 | +We'll be building a secure version of **EpicMe**, a personal journaling application that demonstrates real-world authentication patterns. You'll see how to: |
| 40 | + |
| 41 | +- Protect journal entries so users only see their own content |
| 42 | +- Implement scope-based permissions for read vs. write operations |
| 43 | +- Handle authentication errors gracefully with helpful error messages |
| 44 | +- Provide metadata endpoints that make your server easy to integrate with |
| 45 | + |
| 46 | +This workshop uses the |
| 47 | +[OAuth 2.0 standard](https://tools.ietf.org/html/rfc6749) and follows the |
| 48 | +[MCP Authentication specification](https://modelcontextprotocol.io/specification/2025-06-18/server/auth), |
| 49 | +ensuring your skills transfer to any OAuth-compatible system. |
| 50 | + |
| 51 | +We'll be using: |
| 52 | + |
| 53 | +- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) for our MCP server implementation |
| 54 | +- [Cloudflare Workers](https://workers.cloudflare.com/) as our runtime environment |
| 55 | +- Standard OAuth 2.0 flows for authentication and authorization |
| 56 | + |
| 57 | +<callout-info> |
| 58 | + **Prerequisites**: This workshop builds on MCP fundamentals. If you're new to |
| 59 | + MCP, consider taking [Advanced MCP |
| 60 | + Features](https://www.epicai.pro/advanced-mcp-features) first to get familiar |
| 61 | + with the protocol basics. |
| 62 | +</callout-info> |
| 63 | + |
| 64 | +Ready to build secure, user-aware MCP applications? Let's dive into the world of authenticated Model Context Protocol servers! |
0 commit comments