https://github.com/dptech-corp/ui-component-mcp-server-demo
UI compnent as MCP server
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (2.8%) to scientific vocabulary
Repository
UI compnent as MCP server
Basic Info
- Host: GitHub
- Owner: dptech-corp
- Language: Python
- Default Branch: main
- Size: 1.42 MB
Statistics
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
UI Component MCP Server Demo
这是一个演示项目,展示如何通过 MCP (Model Context Protocol) 协议控制前端组件状态的能力。项目实现了完整的消息流程:MCP 工具调用 → Redis 消息 → 后端处理 → SSE 事件 → 前端更新。
项目概述
本项目演示了一个基于 MCP 协议的实时组件状态管理系统,包含以下核心功能:
- MCP Server: 处理 MCP 工具调用,生成 Redis 消息
- Backend: FastAPI 后端,处理 Redis 消息并通过 SSE 向前端推送更新
- Frontend: React 前端,通过 SSE 接收实时更新
- Redis: 作为消息通道,连接 MCP 和后端服务
- Agent: Google ADK 智能代理,通过自然语言控制 MCP 工具
- Demo 组件: 简单的 Plan List,演示完整的消息流程
技术架构
技术栈
- 前端: React + TypeScript + Tailwind CSS + shadcn/ui
- 后端: FastAPI + Python + Pydantic
- 消息通道: Redis Pub/Sub
- MCP Server: fastmcp + Python
- Agent: Google ADK (AI Development Kit)
- 容器化: Docker + Docker Compose
消息流程
正向流程(Agent → Frontend)
Agent 自然语言指令 → MCP 工具调用 → Redis Pub/Sub 消息 → 后端接收处理 → SSE 事件推送 → 前端组件更新
反向流程(Frontend → Agent)
前端用户输入 → 后端 API 接收 → Google ADK Agent /run 端点 → Agent 处理响应 → 前端显示结果
详细的消息流程说明请参考 消息流程文档。
项目结构
ui-component-mcp-server-demo/
├── README.md # 项目说明文档
├── ARCHITECTURE.md # 架构设计文档
├── docker-compose.yml # Docker 编排配置
├── .gitignore # Git 忽略文件配置
├── mcp-server/ # MCP 服务器
│ ├── src/ # 源代码
│ ├── pyproject.toml # Python 项目配置
│ ├── Dockerfile # Docker 构建文件
│ └── README.md # MCP 服务器说明
├── agent/ # Google ADK Agent
│ ├── src/ # 源代码
│ ├── pyproject.toml # Python 项目配置
│ ├── Dockerfile # Docker 构建文件
│ ├── start_web.sh # 开发模式启动脚本
│ ├── start_api.sh # API 服务器启动脚本
│ └── README.md # Agent 说明
├── backend/ # FastAPI 后端
│ ├── app/ # 应用代码
│ ├── pyproject.toml # Python 项目配置
│ ├── Dockerfile # Docker 构建文件
│ └── README.md # 后端说明
├── frontend/ # React 前端
│ ├── src/ # 源代码
│ ├── package.json # Node.js 项目配置
│ ├── Dockerfile # Docker 构建文件
│ └── README.md # 前端说明
├── shared/ # 共享类型和常量
│ ├── types/ # TypeScript 类型定义
│ └── constants/ # 常量定义
└── docs/ # 项目文档
├── message-flow.md # 消息流程详细说明
├── component-guide.md # 组件开发指南
└── deployment.md # 部署指南
快速开始
环境要求
- Docker 和 Docker Compose
- Node.js 18+ (本地开发)
- Python 3.11+ (本地开发)
- Redis (通过 Docker 提供)
使用 Docker Compose 启动
克隆项目
bash git clone https://github.com/dptech-corp/ui-component-mcp-server-demo.git cd ui-component-mcp-server-demo启动所有服务
bash docker-compose up -d访问应用
前端应用: http://localhost:3000
后端 API: http://localhost:8000
API 文档: http://localhost:8000/docs
ADK Agent: http://localhost:8002
本地开发模式
详细的本地开发设置请参考 部署指南。
Demo 功能
Plan List 组件
项目包含一个简单的 Plan List 组件,演示完整的 MCP 驱动的状态管理:
- 添加计划: 通过 MCP 工具添加新的 plan 项
- 更新计划: 修改计划标题、描述或完成状态
- 删除计划: 移除不需要的计划
- 实时同步: 所有操作通过 SSE 实时同步到前端
MCP 工具
MCP Server 提供以下工具:
add_plan: 添加新的 plan 项update_plan: 更新现有 plan 项delete_plan: 删除 plan 项toggle_plan: 切换 plan 完成状态
反向消息链路
支持从前端向 Agent 发送消息的双向通信功能:
- 消息输入: 前端提供消息输入组件
- 消息转发: 后端 API 转发消息到 Google ADK Agent
- Agent 处理: Agent 通过
/run端点处理用户消息 - 响应显示: 前端显示 Agent 的处理结果
- 会话管理: 支持基于 sessionId 的会话管理
扩展性设计
可复用组件
- 消息类型: 标准化的消息格式,支持不同组件类型
- 消息通道: Redis Pub/Sub 通道命名规范
- SSE 连接: 通用的 SSE 连接管理
添加新组件
要添加新的可控制组件,请参考 组件开发指南。
文档
贡献
欢迎提交 Issue 和 Pull Request 来改进这个项目。
许可证
MIT License
Owner
- Name: DP Technology
- Login: dptech-corp
- Kind: organization
- Location: China
- Website: https://www.dp.tech/en
- Repositories: 9
- Profile: https://github.com/dptech-corp
GitHub Events
Total
- Watch event: 1
- Member event: 2
- Issue comment event: 43
- Push event: 122
- Public event: 1
- Pull request review comment event: 6
- Pull request review event: 8
- Pull request event: 77
- Create event: 27
Last Year
- Watch event: 1
- Member event: 2
- Issue comment event: 43
- Push event: 122
- Public event: 1
- Pull request review comment event: 6
- Pull request review event: 8
- Pull request event: 77
- Create event: 27
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 0
- Total pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
Pull Request Authors
- devin-ai-integration[bot] (35)
- zhifeng-d (5)
- FingerLiu (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- python 3.11-slim build
- python 3.11-slim build
- redis 7-alpine
- node 18-alpine build
- python 3.11-slim build
- 320 dependencies
- @types/node ^20.19.0 development
- @types/react ^18.2.37 development
- @types/react-dom ^18.2.15 development
- @typescript-eslint/eslint-plugin ^6.10.0 development
- @typescript-eslint/parser ^6.10.0 development
- @vitejs/plugin-react ^4.1.0 development
- autoprefixer ^10.4.16 development
- eslint ^8.53.0 development
- eslint-plugin-react-hooks ^4.6.0 development
- eslint-plugin-react-refresh ^0.4.4 development
- postcss ^8.4.31 development
- tailwindcss ^3.3.5 development
- typescript ^5.2.2 development
- vite ^4.5.0 development
- @radix-ui/react-checkbox ^1.0.4
- @radix-ui/react-dialog ^1.0.5
- @radix-ui/react-slot ^1.0.2
- class-variance-authority ^0.7.0
- clsx ^2.0.0
- lucide-react ^0.294.0
- react ^18.2.0
- react-dom ^18.2.0
- react-resizable-panels ^3.0.3
- tailwind-merge ^2.0.0
- tailwindcss-animate ^1.0.7
- fastapi >=0.104.0
- google-adk >=0.1.0
- litellm >=1.72.6
- python-dotenv >=1.0.0
- uvicorn [standard]>=0.24.0
- 131 dependencies
- aiosqlite >=0.21.0
- fastapi [standard]>=0.104.0
- pydantic >=2.0.0
- python-dotenv >=1.0.0
- python-multipart >=0.0.6
- redis >=4.5.0
- uvicorn [standard]>=0.24.0
- black >=23.0.0,<24.0.0 development
- httpx >=0.25.0,<0.26.0 development
- isort >=5.12.0,<6.0.0 development
- mypy >=1.6.0,<2.0.0 development
- pytest >=7.4.0,<8.0.0 development
- pytest-asyncio >=0.21.0,<0.22.0 development
- aiosqlite >=0.21.0,<0.22.0
- fastapi >=0.104.0,<0.105.0
- pydantic >=2.0.0,<3.0.0
- python-dotenv >=1.0.0,<2.0.0
- python-multipart >=0.0.6,<0.1.0
- redis >=4.5.0,<5.0.0
- uvicorn >=0.24.0,<0.25.0
- aiosqlite 0.21.0
- annotated-types 0.7.0
- anyio 4.9.0
- async-timeout 5.0.1
- black 25.1.0
- certifi 2025.4.26
- click 8.1.8
- click 8.2.1
- colorama 0.4.6
- exceptiongroup 1.3.0
- fastapi 0.115.12
- h11 0.16.0
- httpcore 1.0.9
- httptools 0.6.4
- httpx 0.28.1
- idna 3.10
- iniconfig 2.1.0
- isort 6.0.1
- mypy 1.16.0
- mypy-extensions 1.1.0
- packaging 25.0
- pathspec 0.12.1
- platformdirs 4.3.8
- pluggy 1.6.0
- pydantic 2.11.5
- pydantic-core 2.33.2
- pygments 2.19.1
- pytest 8.4.0
- pytest-asyncio 1.0.0
- python-dotenv 1.1.0
- python-multipart 0.0.20
- pyyaml 6.0.2
- redis 6.2.0
- sniffio 1.3.1
- starlette 0.46.2
- tomli 2.2.1
- typing-extensions 4.14.0
- typing-inspection 0.4.1
- ui-component-backend 0.1.0
- uvicorn 0.34.3
- uvloop 0.21.0
- watchfiles 1.0.5
- websockets 15.0.1
- fastmcp >=0.1.0
- pydantic >=2.0.0
- python-dotenv >=1.0.0
- redis >=4.5.0
- annotated-types 0.7.0
- anyio 4.9.0
- async-timeout 5.0.1
- authlib 1.6.0
- black 25.1.0
- certifi 2025.6.15
- cffi 1.17.1
- click 8.2.1
- colorama 0.4.6
- cryptography 45.0.4
- exceptiongroup 1.3.0
- fastmcp 2.8.1
- h11 0.16.0
- httpcore 1.0.9
- httpx 0.28.1
- httpx-sse 0.4.0
- idna 3.10
- iniconfig 2.1.0
- isort 6.0.1
- markdown-it-py 3.0.0
- mcp 1.9.4
- mdurl 0.1.2
- mypy 1.16.0
- mypy-extensions 1.1.0
- openapi-pydantic 0.5.1
- packaging 25.0
- pathspec 0.12.1
- platformdirs 4.3.8
- pluggy 1.6.0
- pycparser 2.22
- pydantic 2.11.7
- pydantic-core 2.33.2
- pydantic-settings 2.9.1
- pygments 2.19.1
- pytest 8.4.0
- pytest-asyncio 1.0.0
- python-dotenv 1.1.0
- python-multipart 0.0.20
- redis 6.2.0
- rich 14.0.0
- shellingham 1.5.4
- sniffio 1.3.1
- sse-starlette 2.3.6
- starlette 0.47.0
- tomli 2.2.1
- typer 0.16.0
- typing-extensions 4.14.0
- typing-inspection 0.4.1
- ui-component-mcp-server 0.1.0
- uvicorn 0.34.3