国家探索器

一个集成了MCP服务器和LangGraph的国家探索工具,用于生成包含嵌入图像的美丽国家档案。

  • by anilsharmay
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 anilsharmay/mcp-demo

使用说明

MCP演示:使用LangGraph的国家探索器

🌍 国家探索者:MCP与LangGraph集成

这个项目展示了一个完整的 MCP(模型上下文协议)服务器 与……集成 LangGraph 创建带有嵌入图片的精美国家简介。

✨ 特点/功能

  • 🔍 MCP服务器 与Unsplash搜索API集成
  • 🤖 机器人 LangGraph 代理 用于智能国家探索
  • 🖼️(图片) 每个国家10张图片 附有摄影师署名
  • 📄 纸张、文件、文档 美观的Markdown个人资料模板 带有嵌入图像
  • 🧪 试管或实验器材的符号(常用于表示化学实验) 综合测试套件 用于验证
  • 📁文件夹 组织化的项目结构 和;与 profiles/ 并且 tests/ 文件夹

🏗️ 项目结构

mcp-demo/
├── country_explorer.py          # Main LangGraph app (10 images)
├── server.py                   # MCP server with Unsplash API
├── profiles/                   # 📁 Generated country profiles
│   ├── india_profile.md
│   ├── japan_profile.md
│   ├── uganda_profile.md
│   └── usa_profile.md
├── tests/                      # 📁 Test files
│   ├── test_country_explorer.py
│   ├── test_unsplash.py
│   └── search_5_mountains.py
└── .env                        # API keys

🚀 快速入门

先决条件

  • Python 3.13及以上版本
  • Unsplash API密钥
  • OpenAI API密钥

安装

  1. 克隆仓库:

    git clone https://github.com/anilsharmay/mcp-demo.git
    cd mcp-demo
    
  2. 安装依赖项:

    uv sync
    
  3. 配置环境变量: 创造 .env 文件包含您的API密钥:

    UNSPLASH_API_KEY=your_unsplash_api_key_here
    OPENAI_API_KEY=your_openai_api_key_here
    TAVILY_API_KEY=your_tavily_api_key_here
    

运行国家探索器

  1. 启动MCP服务器:

    uv run mcp dev server.py
    
  2. 运行国家探索器:

    uv run python country_explorer.py
    
  3. 运行测试:

    cd tests && uv run python test_country_explorer.py
    

🎯 MCP服务器工具

MCP服务器提供以下工具:

  • **unsplash_search**使用方向过滤器搜索美丽图片
  • **web_search**在网上搜索国家信息
  • **roll_dice**使用自定义标记掷骰子

🤖 LangGraph 代理

乡村探索者代理:

  • 使用网络搜索研究各国情况
  • 通过Unsplash找到10张美丽的图片
  • 创建包含嵌入图片的丰富Markdown资料
  • 包含摄影师致谢及链接

📸 样本输出

每个国家概况包括:

  • 文化信息 以及历史
  • 地理细节 以及地标
  • 10张高质量图片 附带学分/积分
  • 干净的Markdown格式 便于查看

🎬 动态演示GIF

印度概况:

瑞士概况:

美国概况:

🧪 测试

运行综合测试套件:

# Test MCP server
uv run python tests/test_unsplash.py

# Test Country Explorer
cd tests && uv run python test_country_explorer.py

# Test mountain search
uv run python tests/search_5_mountains.py

🔧 MCP(主控处理器/多点控制单元)配置

在您的Cursor MCP设置中添加:

{
  "mcpServers": {
    "unsplash-mcp-server": {
      "command": "uv",
      "args": ["--directory", ".", "run", "server.py"]
    }
  }
}

📚 所用技术

  • MCP(模型上下文协议) - 服务器框架
  • LangGraph - 代理编排
  • LangChain MCP适配器 - 工具集成
  • Unsplash API - 图片搜索
  • OpenAI GPT-4 - 语言模型
  • Python 3.13 - 运行时环境

🎉 展示

这个项目展示了:

  • ✅ MCP服务器开发 与自定义API集成
  • ✅ LangGraph 代理创建 使用工具编排
  • ✅ 生成美观的输出 带有嵌入式图像
  • ✅ 整洁的项目组织 以及测试
  • ✅ 实际应用 人工智能代理框架

非常适合展示MCP与LangGraph的集成! 🌍✨(地球✨)