FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
emcho
emchohello-mcp
Remix of jubertioai/hello-realtime
Public
Like
1
hello-mcp
Home
Code
6
frontend
1
routes
4
.vtignore
README.md
deno.json
H
main.tsx
Branches
1
Pull requests
Remixes
2
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
9/2/2025
Viewing readonly version of main branch: v6
View latest version
README.md

hello-mcp

Hello MCP is a remix of OpenAI's hello-realtime demo that adds Model Context Protocol (MCP) support for server-side tool execution.

This demo showcases:

  • WebRTC-based voice conversations with OpenAI's Realtime API
  • MCP (Model Context Protocol) for secure server-side tool execution
  • A demo getFavoriteFood tool to demonstrate MCP functionality
  • Toggle between standard and MCP-enabled modes

If you remix the app, you'll just need to pop in your own OPENAI_API_KEY (from platform.openai.com).

What's New: MCP Support

Model Context Protocol (MCP)

MCP enables server-side tool execution, keeping your business logic and API keys secure on the server rather than exposing them to the client.

Demo Tool: getFavoriteFood

Try asking questions like:

  • "What's Thomas's favorite food?"
  • "What does Brian like to eat?"
  • "Tell me about Yana's favorite food"

The tool knows about: Thomas, Brian, Emil, Yana, Alex, Max, Justin, and Sam.

Architecture

  1. Standard WebRTC Flow:

    • Browser connects to frontend
    • Creates WebRTC offer
    • /rtc endpoint handles SDP negotiation with OpenAI
    • Observer established to monitor session
  2. MCP-Enhanced Flow (when enabled):

    • Same WebRTC setup as above
    • OpenAI discovers tools via MCP protocol (/mcp/agent/:agentId)
    • Tools execute server-side when invoked
    • Results returned through MCP protocol
    • Client triggers response generation after tool completion

API Endpoints

  • GET / - serves the WebRTC-based app with MCP toggle
  • POST /rtc - creates a new WebRTC-based Realtime API session (with optional ?mcp=true)
  • POST /sip - handles an incoming Realtime API SIP call
  • POST /observer - internal endpoint to establish a Realtime API websocket for session control
  • POST /mcp/agent/:agentId - MCP protocol endpoint for tool discovery and execution
  • GET /mcp/agent/:agentId/tools - Debug endpoint to list available tools

Project Structure

├── frontend/     
│   └── index.html          # HTML/JS application for WebRTC with MCP support
├── main.tsx                # Main entrypoint for the val.town app
└── routes/
    |── mcp.ts              # MCP protocol handler with getFavoriteFood tool
    |── observer.ts         # Server-side session control for SIP & WebRTC
    |── rtc.ts              # WebRTC session setup with MCP configuration
    |── sip.ts              # SIP webhook handling and session setup
    └── utils.ts            # Realtime API session configuration with MCP support

How to Test MCP

  1. Start the app - Click "Start" and allow microphone access
  2. Check MCP is enabled - Ensure "Use MCP Tools" checkbox is checked
  3. Ask about favorite foods - Try "What's Thomas's favorite food?"
  4. Watch the logs - You'll see MCP events including tool discovery and execution
  5. Try without MCP - Uncheck the box and restart to see the difference

MCP Protocol Details

The MCP implementation follows the JSON-RPC 2.0 specification:

Initialize

{ "method": "initialize", "params": { "protocolVersion": "2025-06-18" } }

Tools List

{ "method": "tools/list", "result": { "tools": [...] } }

Tool Call

{ "method": "tools/call", "params": { "name": "getFavoriteFood", "arguments": { "name": "Thomas" } } }
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.