FoodDash

FoodDash

An MCP server and app that enables users to browse restaurants, view menus, manage shopping carts, and place food orders with live status tracking. It serves as a reference implementation for MCP Apps SDK patterns like tool visibility, lifecycle hooks, and structured content.

Category
访问服务器

README

FoodDash

A food ordering MCP App that demonstrates key MCP Apps SDK patterns. Browse restaurants, view menus, add items to cart, and place orders — all within an MCP host.

Getting Started

bun install
bun run dev

The server starts at http://localhost:3001/mcp.

Scripts

Command Description
bun run dev Start dev server with hot reload (web + server watch)
bun run build Production build (typecheck → web → server bundle)
bun run start Run the built server in production mode
bun run typecheck Type-check only
bun run build:web Build web assets only
bun run build:server Bundle server entry only
bun run dev:server Watch and restart server

MCP Apps Concepts Demonstrated

This app is designed as a learning reference. Each concept is documented with inline comments in the source code.

Tool Visibility

Two kinds of tools share one UI:

Tool Visibility Purpose
order-food Model + App Model calls this when user says "order food". Opens the UI.
get-order-summary Model + App Model calls this when user asks "where's my food?". Same UI.
get-menu App only UI calls this when user taps a restaurant. Model never sees it.
place-order App only UI calls this when user clicks "Place Order".
get-order-status App only UI polls this every 10s for live order tracking.
apply-promo App only UI calls this when user applies a promo code.

Why it matters: Model-visible tools give the LLM a clean, high-level interface ("order food", "check order status"). App-only tools handle granular CRUD that shouldn't clutter the model's tool list.

Lifecycle Hooks (mcp-app.tsx)

Hook When it fires What FoodDash does
ontoolinput Tool invoked, BEFORE server responds Pre-sets cuisine filter from model's cuisine argument
ontoolresult AFTER server returns Loads restaurant list or order data into state
ontoolcancelled Host cancels a tool call Resets loading spinners
onteardown Host is closing the app Returns order summary or abandoned cart info to the model
onhostcontextchanged Host theme/viewport changes Updates safe area insets

Structured Content

Every tool result carries two payloads:

  • content[] — text the model reads in its conversation
  • structuredContent — JSON the app UI parses to render

They can carry different levels of detail. See server.ts for examples.

Shared Resource URI

Both order-food and get-order-summary point to the same resourceUri. The host renders one UI instance and routes different tool results to it. The app distinguishes them by the shape of structuredContent.

App → Server Communication

The app calls server tools via app.callServerTool(). This is the reverse of the model calling tools — the app initiates calls for app-only operations like fetching menus and placing orders.

Features

  • Browse 5 restaurants with ratings, hours, delivery info, and feature tags
  • Search, filter by cuisine, and sort by rating/delivery time/fee
  • Menu items with dietary labels, calorie counts, and popularity badges
  • Dietary filter pills on the menu view
  • Cart with quantity controls, special instructions, and promo codes
  • Promo codes: WELCOME10 (10% off), FREEDEL (free delivery), SAVE5 ($5 off)
  • Live order tracking with auto-advancing status (confirmed → preparing → on the way → delivered)
  • Light and dark mode support

Project Structure

server.ts                  MCP server, tools, and mock data
main.ts                    Express entry point (HTTP + stdio)
src/
  mcp-app.tsx              React entry point + lifecycle hooks
  types.ts                 Shared TypeScript interfaces
  constants.ts             Dietary labels, order steps, sort options
  global.css               Design tokens and animations
  hooks/
    useAppState.ts         Central state management + server tool calls
  components/
    Header.tsx             Sticky header with back button and cart badge
    DeliveryAddressBar.tsx Address input
    RestaurantsView.tsx    Restaurant list with search/filter/sort
    RestaurantCard.tsx     Restaurant card
    SortDropdown.tsx       Sort selector
    RestaurantBanner.tsx   Restaurant detail header in menu view
    MenuView.tsx           Menu with dietary filters and categorized items
    MenuItemCard.tsx       Menu item with dietary badges and calories
    DietaryBadge.tsx       Dietary label pill
    CartView.tsx           Cart, promo code, special instructions, summary
    QuantityControl.tsx    +/- quantity buttons
    OrderTrackingView.tsx  Live order tracking with progress stepper
    ProgressStepper.tsx    4-step horizontal progress indicator
    EmptyState.tsx         Empty state placeholder

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选