Yams Cheese Stakes E-commerce Application Demo Summary
Key Concepts:
- MCP (Model Context Protocol): A protocol for connecting AI agents to HTTP endpoints.
- MCP Remote: A component that allows AI agents (like Claude) to interact with MCP servers.
- Clerk: An authentication service used for user login and authorization.
- SSE (Server-Sent Events): A technology for pushing real-time updates from the server to the client.
- Agentic Workflow: An AI workflow where an agent (like Claude) autonomously performs tasks by interacting with multiple data sources and services.
- JSON RPC 2.0: A remote procedure call protocol encoded in JSON.
- Off Info: Authentication information, including user ID, passed with requests.
Application Overview
The demo showcases an e-commerce application called "Yams Cheese Stakes" integrated with AI using Claude and MCP. The application allows users to order food, and the demo explores how to connect Claude to the application to automate ordering, even incorporating data from external sources like HR systems.
Authentication and Authorization with Clerk and MCP
- Clerk Integration: The application uses Clerk for standard user sign-in and authentication on the web UI.
- MCP Remote Configuration: An MCP remote server is configured to connect Claude to the Yams Cheese Stakes API (Localhost 3000 API SSE).
- Authentication Bridging: The MCP remote authenticates Claude through the same Clerk service, ensuring Claude and the web application are connected to the same user.
- Tool Discovery: The Yams Cheese Stakes site exposes tools like
get menu,add to cart,get cart items, andclear cartto Claude via the MCP server. well-known/ooth-protected-resourceEndpoint: MCP remote initially calls this endpoint to get information on how to connect to the server, including the resource URL (localhost 3000) and the authorization server (Clerk).- API SSE Endpoint: After authentication, MCP remote makes requests to this endpoint, which uses
with MCP offto verify authorization. with MCP offUtility: This utility bridges Clerk and MCP by checking authorization and adding theoff responseto the request asrequest.off.- Authorization in API Messages: The
API messageshandler useswith MCP offto extract the user's identity (subject) from theoff infoand pass it to thehandle messagefunction. - User Identification: The user ID is extracted from the
off infoand used to associate actions like adding items to the cart with the correct user.
AI-Powered Ordering with Claude
- Basic Ordering: Claude can be instructed to order items from the Yams Cheese Stakes menu, demonstrating basic AI integration.
- Multi-Agent Agentic Workflow: The demo extends this by connecting Claude to an HR server containing employee food preferences.
- HR Server Integration: A local MCP server simulates an HR system with a static list of employees and their food preferences.
- Data Retrieval: Claude retrieves employee food preferences from the HR server.
- Intelligent Ordering: Claude uses the retrieved preferences to place orders from Yams Cheese Stakes that cater to individual employee tastes.
- Agentic Behavior: Claude acts as an agent by gathering data from one source (HR server) and using it to perform actions in another (Yams Cheese Stakes).
Real-Time Cart Updates with Server-Sent Events (SSE)
- Cart Storage: The application uses an in-memory cart storage with a list of subscribers.
subscribe to cartFunction: This function allows components to subscribe to cart changes for a specific user ID.- Notification Mechanism: When an item is added to the cart, all subscribers for that user are notified.
- API Cart Endpoint: This endpoint creates a readable stream that sends pings to the client every second to maintain the connection.
- SSE Flow: The
API cartendpoint usessubscribe to cartto send the updated cart contents to the client as a text event stream whenever the cart changes. - Client-Side Updates: The client-side
cartcomponent usesuse effectto create anevent sourcethat listens for server-sent events from theAPI cartendpoint. - Real-Time Synchronization: When a message is received from the server, the
cartcomponent updates its state with the new cart contents, ensuring real-time synchronization between the client and server. - Symmetric Updates: Cart updates initiated from either the web UI or the MCP UI (AI side) are reflected in real-time on both sides due to the SSE mechanism.
Code Structure and Key Components
env.example: Contains Clerk API keys and other configuration settings.utils/off.ts: Contains thewith MCP offutility for bridging Clerk and MCP authentication.public/well-known/ooth-protected-resource: Defines the resource and authorization server for MCP remote.pages/api/sse.ts: Implements the API SSE endpoint for handling MCP requests.pages/api/messages.ts: Handles incoming JSON RPC 2.0 requests and calls the appropriate server functions.server/cart.ts: Implements the in-memory cart storage with subscription and notification capabilities.pages/api/cart.ts: Creates the SSE stream for pushing cart updates to the client.components/cart.tsx: The client-side component that usesevent sourceto listen for SSE events and update the cart display.
Conclusion
The demo illustrates a powerful approach to integrating AI agents with web applications using MCP and Clerk. The use of SSE enables real-time updates and a seamless user experience. While MCP for HTTP is still evolving, this demo provides a glimpse into the future of AI-powered applications where agents can intelligently interact with various data sources and services. The key takeaway is the ability to create agentic workflows where AI can autonomously perform tasks by connecting to multiple MCP servers and acting on the data retrieved.
AI summaries can miss context or contain errors. Check important details against the original video.





