• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
jjg

jjg

multiplayer-prompting

Public
Like
multiplayer-prompting
Home
Code
13
.vscode
.vt
backend
docs
frontend
shared
.vtignore
AGENTS.md
ARCHITECTURE.md
DEPLOYMENT.md
QUICKSTART.md
README.md
deno.json
Environment variables
Branches
1
Pull requests
Remixes
History
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
/
DEPLOYMENT.md
Code
/
DEPLOYMENT.md
Search
…
Viewing readonly version of main branch: v13
View latest version
DEPLOYMENT.md

🚀 Val Town Deployment Guide

Quick guide for deploying Vibe-Draft to Val Town using MCP tools.

Prerequisites

  • Val Town account
  • Val Town MCP tools installed
  • OpenAI API key (automatically provided by Val Town)

Deployment Steps

1. Create a New Val

Using Val Town MCP:

# Create the val project mcp_valtown_create_val --name "vibe-draft" --privacy "public"

This creates a new val with the identifier <your-username>/vibe-draft.

2. Upload Project Files

Upload all files to your val using the MCP tools:

# Create directories mcp_valtown_create_directory --val "<your-username>/vibe-draft" --path "backend" mcp_valtown_create_directory --val "<your-username>/vibe-draft" --path "backend/database" mcp_valtown_create_directory --val "<your-username>/vibe-draft" --path "frontend" mcp_valtown_create_directory --val "<your-username>/vibe-draft" --path "frontend/components" mcp_valtown_create_directory --val "<your-username>/vibe-draft" --path "shared" # Upload backend files mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "backend/index.ts" --fileType "http" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "backend/sse-hub.ts" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "backend/vibe-engine.ts" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "backend/database/schema.ts" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "backend/database/queries.ts" # Upload frontend files mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/index.html" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/index.tsx" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/style.css" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/components/App.tsx" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/components/CardDeck.tsx" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/components/PromptStack.tsx" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/components/VibeOutput.tsx" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "frontend/components/PlayerList.tsx" # Upload shared files mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "shared/types.ts" mcp_valtown_create_file --val "<your-username>/vibe-draft" --path "shared/cards.ts"

3. Set File Type

Make sure the main backend entry point is set as an HTTP type:

mcp_valtown_set_file_type --val "<your-username>/vibe-draft" --path "backend/index.ts" --fileType "http"

4. Access Your App

Your app will be available at:

https://<your-username>-vibe-draft.web.val.run/

Testing

  1. Open the URL in your browser
  2. Enter a session ID (e.g., "test-session")
  3. Enter your name
  4. Click "Join Session"
  5. Start playing cards!

Multi-Player Testing

Open multiple browser tabs/windows with different names to test multiplayer:

  • Tab 1: Session "test-game", Player "Alice"
  • Tab 2: Session "test-game", Player "Bob"
  • Tab 3: Session "test-game", Player "Charlie"

All players should see updates in real-time via SSE.

Monitoring

Check Logs

mcp_valtown_get_logs --fileId "<backend-index-file-id>"

Check Traces

mcp_valtown_get_traces --fileId "<backend-index-file-id>"

Test Endpoint

curl https://<your-username>-vibe-draft.web.val.run/api/health

Should return:

{ "status": "healthy", "timestamp": 1234567890 }

Database

SQLite tables are automatically created on first run. To inspect:

mcp_valtown_sqlite_execute --sql "SELECT * FROM sessions_v1" --val "<your-username>/vibe-draft" mcp_valtown_sqlite_execute --sql "SELECT * FROM players_v1" --val "<your-username>/vibe-draft" mcp_valtown_sqlite_execute --sql "SELECT * FROM prompt_stack_v1" --val "<your-username>/vibe-draft"

Environment Variables

OpenAI API key is automatically provided by Val Town. No manual setup needed!

If you want to use your own API key:

mcp_valtown_add_env_var --val "<your-username>/vibe-draft" --key "OPENAI_API_KEY" --value "sk-..." --description "OpenAI API key"

Updating

To update files after deployment:

mcp_valtown_update_file --val "<your-username>/vibe-draft" --path "backend/index.ts" --content "<new-content>"

Troubleshooting

"Session is full" Error

Max 10 active players. First 10 to join can play, others spectate.

SSE Connection Fails

Check browser console for errors. Val Town HTTP vals support SSE natively.

Cards Not Appearing

Check that shared/cards.ts is uploaded correctly and importing properly.

OpenAI Errors

Verify OpenAI API key is set (should be automatic). Check Val Town console for API errors.

Database Errors

Tables should auto-create on first run. If issues, check that schema.ts ran successfully in logs.

Performance Tips

  1. Database Initialization: Comment out initDatabase() after first run for faster cold starts
  2. Card Drawing: Cache CARD_DECK in memory instead of re-importing
  3. SSE Heartbeat: Adjust keep-alive interval based on needs (currently 30s)
  4. Token Limits: Use lower token limits for faster/cheaper responses

Security Notes

  • Sessions are public by session ID - anyone with ID can join
  • No authentication required (by design for easy multiplayer)
  • Consider adding password protection for private games
  • Rate limit the generate endpoint to prevent API abuse

Scaling

Val Town automatically handles:

  • Multiple concurrent sessions
  • Database connection pooling
  • SSE connection management
  • Cold start optimization

For very high traffic:

  • Consider session cleanup cron job
  • Archive old sessions to separate tables
  • Add Redis-like caching for active session state

Need Help?

  • Val Town Docs: https://docs.val.town
  • Val Town Discord: https://discord.gg/valtown
  • File Issues: On the val's page

Enjoy your multiplayer prompting sandbox! 🎴✨

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.