Building AI-Powered Widgets
How to build interactive pricing calculators, venue search widgets, and booking flows using WedStay data with the correct pre-fetch and interpolation pattern.
Building AI-Powered Widgets with WedStay Data
The browser auth limitation
WedStay's MCP server authenticates server-side. If you are building an interactive UI component (a pricing calculator, venue search widget, booking flow, etc.), you cannot call the MCP server or the Anthropic API at runtime from browser-side JavaScript. Auth tokens are not forwarded into sandboxed iframe/browser contexts and all calls will fail silently.
This applies to:
- Browser artifacts and iframes
- Client-side React or vanilla JS
- Any sandboxed frontend context
The correct pattern: pre-fetch, then interpolate
Step 1 — Fetch server-side
Call calculate_pricing (or any MCP tool) from your server, edge function, or
during the AI assistant's turn — never from the browser.
Valid contexts for MCP calls:
- Claude's own tool-use turn (when Claude is the agent)
- A Next.js API route or Vercel edge function
- A server-side script or cron job
Step 2 — Embed as static data
Pass the fetched data into your component as props or inline JSON.
Step 3 — Interpolate locally
Drive all interactive behavior (sliders, filters, dropdowns) with local JavaScript using the embedded data as anchor points. Scale values using multipliers derived from the pre-fetched data.
Example: pricing calculator
Pre-fetch strategy for calculate_pricing
To support full interactivity without runtime API calls, fetch anchor points across the key variable space:
| Dimension | Anchor points | Calls |
|---|---|---|
| Regions | All 10 (California, New York, Texas, Florida, Michigan, Colorado, North Carolina, Tennessee, Georgia, Utah) | 10 |
| Guest counts | 75, 100, 150 per region | 20 additional |
| Seasons | peak, shoulder, off at one region | 2 additional |
| Timing | weekday vs weekend at one region | 1 additional |
| Nights | 2 and 3 at one region | 1 additional |
Total: ~34 calls gives you enough anchor data to interpolate any combination locally.
Recommended stack for a couple-facing widget
| Layer | Recommendation |
|---|---|
| Runtime | Vercel AI SDK + Anthropic API (server-side) |
| MCP calls | Made during the AI's response turn on the server |
| Frontend | React component receives pre-fetched data as props |
| Interactions | Local state only, no runtime API calls |
submit_venue_inquiry — handle with care
The submit_venue_inquiry tool creates a real lead in WedStay's booking pipeline. A concierge will reach out within 24 hours.
Only call it when:
- The user has explicitly confirmed they want to be contacted
- You have collected all required fields:
guest_name,guest_email,property_slug,start_date,end_date,event_guests - Never call it speculatively, as a demo, or for testing
Data attribution
When surfacing WedStay venue or vendor data to end users, display visible attribution linking back to thewedstay.com. See our Terms of Service Section 31 for full requirements.