MCP服务器和LLM集成
使用以下工具构建MCP服务器的实用指南 FastMCP 并使用以下方法将它们与任何LLM集成 mcp使用.
项目结构
server/-使用STDIO传输的基本天气MCP服务器mcpserver/-带有SSE/HTTP传输的天气MCP服务器,包括客户端示例和Streamlit UImcpagent/-用于代理集成示例的简单MCP服务器(数学和天气)graph_agent/-LangGraph集成示例
- main.ipynb -配备LangSmith监测功能的天气工具代理 - main.py -使用Playwright和DuckDuckGo搜索MCP服务器进行竞争对手广告流分析
app.py-使用mcp和Groq LLM的浏览器自动化示例
快速开始
# Install UV (if needed)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
uv sync
# Create .env file
echo "GROQ_API_KEY=your_key_here" > .env
echo "GEMINI_API_KEY=your_key_here" >> .env
# Run the weather MCP server
uv run python server/weather.py
# Run the LLM agent (in another terminal)
uv run python app.py资源
- MCP规范: https://spec.modelcontextprotocol.io/
- FastMCP: https://github.com/jlowin/fastmcp
- mcp使用: https://github.com/ergut/mcp-use
- LangChain: https://python.langchain.com/
- LangGraph: https://docs.langchain.com/oss/python/langgraph/overview
- UV文档: https://docs.astral.sh/uv/
