本地AI代理系统

一个基于Ollama、FastAPI和MCP微服务的本地化AI代理平台,提供聊天协调、天气查询、地理编码和搜索等功能。

  • by sankar-ramamoorthy
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 sankar-ramamoorthy/ollama-with-mcp

使用说明

Ollama+MCP试剂系统

使用模块化AI Agent平台 奥利玛(问题3:4B) + FastMCP工具 + 快速API + Docker Compose.

一个完全本地的、无框架的ReAct风格的AI代理,使用Ollama、FastAPI和MCP微服务(天气、搜索、地理编码、日期时间)。

注:该项目是在人工智能工具(ChatGPT、Perplexy.AI、DuckDuckGo AI、谷歌搜索)的帮助下快速开发的,在适度的硬件上实现了高效的设计、文档和多服务编排。

🎯 特性

  • ✅ 聊天编排器:LLM决定工具→ 执行→ 格式化自然响应
  • ✅ 日期时间MCP:“今天几号?”→ datetime-mcp:50051
  • ✅ 天气MCP“达拉斯的天气?”→ weather-mcp:50053 → 开放天气
  • ✅ 搜索MCP:DDGS/SearxNG集成(端口50052)
  • ✅ 地理编码MCP:天气地理编码支持(端口50054)
  • 🎨 Gradio用户界面: http://localhost:7860
  • 🚀 生产准备就绪:Docker化、uv依赖管理
服务 端口 状态 描述
后端编排器 8000 ✅ FastAPI+LLM工具决策+MCP执行
日期时间MCP 50051 ✅ “今天几号?”→ UTC ISO日期时间
天气MCP 50053 ✅ “达拉斯的天气?”→ 通过地理编码打开Meteo
地理编码MCP 50054 ✅ 地址→ lat/lon(提名,按天气使用)
搜索MCP 50052 ⚠️ SearxNG(计划:DDGS更换)
Gradio用户界面 7860 ✅ Web界面
SearxNG 8181 ✅ 搜索后端

🚀 快速开始

# Clone & start
git clone <repo>
cd ollama-with-mcp
docker compose up -d

# Backend API ready
curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is today'\''s date?"}'

答复: "Today's date is November 30, 2025."


🛠️ API终点

端点 目的 示例
POST /chat 主编排器 {"message": "Weather in Dallas?"}
POST /datetime/get 直接日期时间 返回UTC ISO日期时间
POST /weather 直接天气 {"location": "Dallas"}
GET /health 系统状态 健康检查所有服务

🏗️ 建筑

User → FastAPI (/chat) → LLM Decision → MCP Tool → LLM Synthesis → Response
                    ↓
              orchestrator.py orchestrates it all

🐳 Docker编写服务

服务 端口 用途
backend 8000 FastAPI编排器
datetime-mcp 50051 日期/时间工具✅
weather-mcp 50053 天气工具✅
searchxng 50052 网络搜索
frontend 7860 Gradio用户界面
searchxng_svc 8181 SearxNG后端

📚 发展

# Backend (uv)
cd backend
uv sync
uv run pytest

# MCP Servers (uv)  
cd mcp-servers/datetime
uv sync
uv run python datetime_mcp/server.py

🙏 致谢


---

## Acknowledgments & Credits

* **AI Assistance:** The README, documentation, and several project markdown files were created with extensive help from **ChatGPT (Free Version)**, along with supplementary support from **Perplexity.ai** (free version) and AI features from **DuckDuckGo** and **Google Search**.
* **Rapid Development on Modest Hardware:** The project was developed on a **HP ENVY x360 laptop (Intel i7-8565U, 8 GB RAM, Windows 11 Home)** in just **4 days**,(during thanksgiving break) ,  demonstrating efficient resource usage.
* **Productivity Enhancement:** AI tools helped streamline development, maintain GitHub issues and milestones, and ensure adherence to the project plan and schedule.
* **Open-Source Resources:** This project leverages existing repositories and tools, including:

  * [Docker](https://www.docker.com/) for container orchestration
  * [FastMCP](https://github.com/your-link) for MCP server infrastructure
  * [Open-Meteo](https://open-meteo.com/) for weather APIs
  * [Nominatim](https://nominatim.org/) for geocoding
  * My **previous repositories** for reusable utilities and code patterns

> ⚡ *Note:* This project was built with AI-assisted development to maximize efficiency while maintaining a clean architecture and robust multi-service deployment.

---