使用说明
MCP GHC演示与AWS Bedrock LLM集成
模型上下文协议(MCP)的全面演示,其中AWS Bedrock LLM是一个使用MCP服务器作为工具的智能代理。为GHC 2025会议规划而构建,具有真实数据和实时API集成。
录制演示
🧠 Strands+MCP架构
┌─────────────────────────────────────────────────────────────────────────────┐
│ MCP Client │
│ ┌─────────────────┐ ┌─────────────────────────────────────────────────┐ │
│ │ React Frontend │ │ Strands Agent │ │
│ │ (Chat UI) │◄──►│ ┌─────────────────┐ ┌─────────────────────┐ │ │
│ └─────────────────┘ │ │ Strands Agent │ │ Fallback MCP │ │ │
│ │ │ │ │ Tool Execution │ │ │
│ │ └─────────────────┘ └─────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────┴─────────────┐
│ MCP Protocol │
│ (JSON-RPC) │
└─────────────┬─────────────┘
│
┌───────────────────────────────────┼───────────────────────────────────┐
│ │ │
┌───────▼────────┐ ┌────────▼────────┐ ┌───────▼────────┐ ┌───────▼────────┐
│ GHC Schedule │ │ Weather Server │ │ Stock Server │ │ AWS Docs │
│ MCP Server │ │ (Live APIs) │ │ (Live APIs) │ │ MCP Server │
│ (Local) │ │ (Local) │ │ (Local) │ │ (Remote) │
│ │ │ │ │ │ │ │
│ Strands Tools: │ │ Strands Tools: │ │ Strands Tools: │ │ Strands Tools: │
│ • searchGHC │ │ • getWeather │ │ • getStock │ │ • searchAWS │
│ • recommend │ │ • getForecast │ │ • getMarket │ │ • getGuides │
│ • getDetails │ │ │ │ │ │ │
│ │ │ Resources: │ │ Resources: │ │ Resources: │
│ Resources: │ │ • wttr.in │ │ • Yahoo Finance│ │ • Official │
│ • SQLite DB │ │ • OpenWeather │ │ • Alpha Vantage│ │ AWS Docs │
│ • 290 Sessions │ │ │ │ │ │ • uvx runtime │
└────────────────┘ └─────────────────┘ └────────────────┘ └────────────────┘
🚀 主要特点
Strands代理架构
- AWS基岩代理与Strands 用于智能工具编排
- 优雅的后退 在代理设置复杂时指导MCP工具的执行
- 克劳德3俳句 作为推理引擎
- 根据用户查询自动选择合适的MCP工具
- 自然语言理解和语境反应
- 针对复杂请求的多工具编排
真实会议数据
- 290场GHC 2025实际会议 从官方会议文件解析
- 在会话标题、描述和演讲者之间进行全文搜索
- 基于兴趣和经验水平的智能推荐
- 包含时间、地点和轨迹的完整会话详细信息
实时数据集成
- 天气:使用OpenWeatherMap回退来自wttr.in API的实时数据
- 股市:雅虎财经API实时价格
- 旅行:芝加哥航线(ORD机场)的模拟飞行数据
MCP架构
- 工具:MCP服务器向LLM公开的功能
- 资源:数据源(数据库、API、文件)
- 提示模板:用于一致交互的结构化提示
🛠️ 设置和安装
先决条件
- Node.js 18+和npm
- 具有基岩访问权限的AWS帐户
- 已安装AWS CLI
- Python和uv包管理器(用于远程MCP服务器)
快速开始
# 1. Install dependencies
npm install
# 2. Install uv (Python package manager for remote MCP servers)
# macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or via pip: pip install uv
# 3. Configure AWS credentials (recommended)
aws configure
# Enter your AWS Access Key ID, Secret Access Key, and region (us-east-1)
# 4. Optional: Create .env file for custom configuration
cp .env.example .env
# Edit .env with AWS_REGION or API keys if needed
# 5. Start the demo
chmod +x start-llm-demo.sh
./start-llm-demo.sh
# OR start manually:
npm start # Backend with strands agent
npm run start:demo # Both backend and frontend
# Note: The SQLite database with 290 GHC sessions will be automatically
# created in servers/ghc_schedule.db on first run
AWS配置选项
选项1:AWS CLI(推荐)
aws configure
# AWS Access Key ID: your_key_here
# AWS Secret Access Key: your_secret_here
# Default region: us-east-1
# Default output format: json
选项2:环境变量
export AWS_ACCESS_KEY_ID=your_key_here
export AWS_SECRET_ACCESS_KEY=your_secret_here
export AWS_REGION=us-east-1
选项3:.env文件(可选)
cp .env.example .env
# Edit .env with AWS_REGION (credentials optional if using aws configure)
# Optionally add API keys for enhanced live data:
# WEATHER_API_KEY=your_openweathermap_key
# ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
🔧 MCP工具和资源
GHC调度MCP服务器
工具:
search_sessions-按关键字、主题、演讲者查找会话get_session_details-获取完整的会话信息recommend_sessions-基于人工智能的个性化推荐
资源:
- SQLite数据库,包含290个真实GHC会话
- 全文搜索功能
- 会话元数据(跟踪、级别、天数、位置)
气象MCP服务器
工具:
get_weather-当前天气状况get_forecast-三天天气预报
资源:
- wttr.in API(主要,无需密钥)
- OpenWeatherMap API(回退)
库存MCP服务器
工具:
get_stock_price-实时股票报价get_market_status-交易时间和市场状态
资源:
- 雅虎财经API(主要,无需密钥)
- AlphaVantage API(后备)
飞行MCP服务器
工具:
search_flights-查找前往芝加哥的GHC航班
资源:
- 具有真实数据的模拟飞行数据库
- 芝加哥奥黑尔(ORD)重点航线
AWS文档MCP服务器(远程)
工具:
search_docs-使用官方AWS MCP服务器搜索AWS服务文档- 由...驱动
uvx awslabs.aws-documentation-mcp-server@latest
资源:
- AWS官方服务文档
- 通过远程MCP服务器实时访问AWS文档
- 全面覆盖所有AWS服务
🎯 演示体验
自然语言查询
LLM代理能够理解复杂的会话请求:
"I'm interested in AI and leadership. What GHC sessions would you recommend,
and what's the weather like in Chicago?"
代理自动执行以下操作:
- 呼叫
recommend_sessions有兴趣:[“AI”,“领导力”] - 呼叫
get_weather地点:“芝加哥” - 结合自然反应的结果
示例交互
- 会话搜索:“在第2天向我展示网络安全会议”
- 天气芝加哥的天气预报如何
- 旅行:“查找从旧金山到芝加哥的航班”
- 建议:“为数据科学初学者推荐课程”
- AWS文档:“如何将Bedrock与Lambda函数结合使用?”
- MCP协议:“什么是MCP工具,它们是如何工作的?”
- 复杂:“计划我的GHC之旅:天气、从纽约出发的航班、人工智能会话和AWS基岩文档”
🏗️ 技术架构
数据库设置和架构
自动初始化:
SQLite数据库(servers/ghc_schedule.db)在您首次运行服务器时自动创建和填充。它包含:
- 290场真正的GHC 2025会议 从官方会议文件解析
- 完整会话元数据:标题、演讲者、描述、时间、地点、曲目
- 可搜索字段:所有文本字段都已编入索引,可进行全文搜索
数据库架构:
- 会话表:290个真实的GHC会话,包含完整的元数据
- 索引字段:标题、描述、演讲者、标签、曲目、级别、日期
- 搜索功能:全文搜索,在所有字段中进行相关性评分
验证数据库:
# Check if database exists and has data
sqlite3 servers/ghc_schedule.db "SELECT COUNT(*) FROM sessions;"
# Should return: 290
# View sample sessions
sqlite3 servers/ghc_schedule.db "SELECT title, speaker, track FROM sessions LIMIT 3;"
数据库重建(如果需要): 如果数据库文件丢失或损坏,服务器启动时,它将自动使用示例数据重新创建。完整的290会话数据集嵌入到应用程序中并自动加载。
Strands代理集成
- 主要的,重要的:具有链架构的AWS Bedrock Agent
- 后备方案:使用Claude 3 Haiku直接执行MCP工具
- 工具规划:智能选择合适的MCP工具
- 参数提取:智能解析用户查询
- 响应生成:结果的自然语言格式
- 故障弱化:无论AWS设置复杂性如何,始终正常运行
回退策略
- LLM故障→ 基于规则的查询处理
- API故障→ 具有明确指标的模拟数据
- 优雅的降级确保演示始终有效
📊 演示脚本
看 DEMO_SCRIPT.md 完整的5分钟演练,包括:
- 安装说明
- 关键谈话要点
- 预期响应
- 故障排除提示
- 架构说明
这个演示展示了人工智能应用的未来:Strands代理使用MCP作为标准协议,智能地编排多个数据源和服务。
🧪 测试演示
测试AWS文档集成
# Test the remote AWS MCP server directly
curl -X POST "http://localhost:3001/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "How do I get started with AWS Bedrock?"}'
# Expected: Real AWS documentation with official links
测试GHC会议数据
# Test the local SQLite database
curl -X POST "http://localhost:3001/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "Show me AI sessions at GHC"}'
# Expected: Real conference sessions from 290-session database
测试实时数据集成
# Test weather API
curl -X POST "http://localhost:3001/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "What is the weather in Seattle?"}'
# Expected: Live weather data from wttr.in
测试多工具编排
# Test complex query using multiple MCP servers
curl -X POST "http://localhost:3001/api/chat" \
-H "Content-Type: application/json" \
-d '{"message": "Plan my GHC trip: weather in Chicago, AI sessions, and AWS Bedrock documentation"}'
# Expected: Combined results from weather, sessions, and AWS docs
验证系统状态
# Check overall system health including database
curl "http://localhost:3001/api/health"
# Look for:
# - "database": "connected"
# - "sessionsCount": 290
# - "llmAgent": "enabled"
# Check database info specifically
curl "http://localhost:3001/api/database/info"
# Should show:
# - totalSessions: 290
# - Available tracks, levels, and days
前端测试
- 打开http://localhost:3000
- 点击“MCP架构”选项卡查看线束架构
- 聊天界面中的测试查询:
- “如何将Bedrock与Lambda结合使用?”(AWS文档)
- “显示网络安全会话”(GHC数据)
- “芝加哥天气”(实时数据)
故障排除
- AWS文档不起作用:检查uvx安装(
uvx --version) - 代理人工作正常:系统使用直接MCP工具编排
- 没有回应:验证AWS凭据(
aws sts get-caller-identity)