mcp-apps-lab

mcp-apps-lab

A FastMCP server that exposes interactive prefab apps for quizzes, weather dashboards, and live news curation, along with resources and prompts. It lets users take quizzes, check weather, and get news briefings through natural language.

Category
访问服务器

README

mcp-apps-lab

One FastMCP app server (Python) — a single MCP server that hosts three interactive Prefab apps (quiz, weather, news) plus MCP resources and prompts. Each app tool returns a Prefab UI (buttons, cards, tabs, progress) instead of raw JSON; any MCP host renders them, and the LLM sees a text summary.

Apps

App UI tool Backend tool What it demonstrates
Quiz take_quiz submit_answer Multi-turn state: the LLM generates questions, the user answers via buttons, each click grades through a backend tool, the final score is sent back to the conversation
Weather weather_app get_weather Live forecast from the Open-Meteo API: free-text location input geocodes ANY city name (no fixed table — “bekasi” works), shows current conditions with the city's local time (🕐 20:31 WIB), region/country, and a 5-day forecast; unknown names fall back to Jakarta, sample data offline (LIVE/SAMPEL badge); lookups go through the host's tools/call proxy (hashed tool names — the proxy never sees the mapping)
News Curator news_curator get_feed Live RSS feeds (Bloomberg Markets, CNBC, The Guardian Business, BBC Business) fetched through the backend tool on tab click / refresh — parsed with the stdlib, sample-data fallback when offline (LIVE/SAMPLE badge); compiles a markdown briefing and sends it back to the conversation

Also exposed server-side: live resources (news://{source}/feed, news://{source}/briefing, weather://{city}/current) and a prompt (morning-briefing).

Layout

src/mcp_apps_lab/
├── server.py          # the ONE FastMCP server — wires apps, tools, resources, prompts
├── apps/              # the FastMCPApp UIs (LLM-facing entry points)
│   ├── quiz.py        #   take_quiz UI
│   ├── weather.py     #   weather_app UI
│   └── news.py        #   news_curator UI
├── tools/             # backend tool functions the UIs call via the tool proxy
│   ├── quiz.py        #   submit_answer
│   ├── weather.py     #   get_weather
│   └── news.py        #   get_feed (live RSS fetch + offline fallback)
├── resources/         # MCP resources over the shared data (news:// live feeds, weather://)
├── prompts/           # MCP prompt templates (morning-briefing)
└── data/              # feed definitions + offline fallback data

Setup

uv sync          # installs the package (editable) + fastmcp[apps] + dev tools

Running

Plain streamable-HTTP server

uv run python -m mcp_apps_lab   # streamable HTTP at http://127.0.0.1:8090/mcp
                                # (MCP_APPS_LAB_PORT to override)

Browser dev UI (fastmcp dev apps)

uv run fastmcp dev apps src/mcp_apps_lab/server.py --mcp-port 8090
  • MCP server: http://127.0.0.1:8090/mcp (auto-reload on save)
  • Dev UI: http://localhost:8080 — pick take_quiz, weather_app, or news_curator, fill in arguments, and play the rendered app in a new tab
  • The left inspector panel shows the JSON-RPC traffic (including the hashed backend-tool calls the UIs make)

Wiring into the ai-backend-lab agent

One server, one entry — the agent sees all three UI tools plus the resources and prompt:

{
  "mcp-apps-lab": {
    "url": "http://127.0.0.1:8090/mcp",
    "transport": "streamable_http"
  }
}

Then ask the agent something like "give me a quiz about Python", "show me the weather in Tokyo", or "curate today's financial news" — it calls the UI tool, and the agent's reply streams a structured tool event the frontend renders as the interactive app.

How it's structured

# server.py — one server, three apps as providers, plus resources & prompts
mcp = FastMCP("mcp-apps-lab", providers=[quiz_app, weather_app, news_app])
register_resources(mcp)   # news://{source}/feed, weather://{city}/current, ...
register_prompts(mcp)     # morning-briefing

# apps/weather.py — the UI app owns its backend tool
app = FastMCPApp("Weather")
app.add_tool(get_weather)          # from mcp_apps_lab.tools — hashed to this app

@app.ui()                          # LLM-facing entry point — returns a PrefabApp
def weather_app(city: str) -> PrefabApp: ...
  • @app.ui() tools are the only ones advertised to the LLM; their result is a Prefab UI the host renders (the model sees a text summary).
  • Backend tools (tools/) are plain functions registered with app.add_tool(...): the renderer calls them over the MCP server under a hashed name (<sha256(app+tool)>_<tool>), so the UI can grade, look up, or compile without the LLM being in the loop — and the tool proxy never sees the mapping.
  • providers=[...] lets one server host several apps; resources and prompts are registered server-side and shared.

Adding to the lab

  1. App: create apps/<name>.py (a FastMCPApp with an @app.ui() entry point), register its backend tool(s) from tools/, and add the app to providers=[...] in server.py.
  2. Backend tool: add a plain function to tools/<name>.py; register it with app.add_tool(...) in the owning app.
  3. Resource / prompt: add a register(mcp) function in resources/<name>.py / prompts/<name>.py and call it from the corresponding register_* in server.py.
  4. Keep it lint-clean and tested: uv run ruff check . and uv run pytest (smoke tests live in tests/test_server.py).

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选