MCP
本地 MCP + Groq + OpenAI Agents SDK
本课堂示例包含:
app.py:一个持久化的本地 Streamable HTTP MCP 服务器,带有多个工具。mcp_groq_agent.ipynb:一个可以发现并调用这些工具的智能体。
环境设置
请使用 Python 3.10 或更高版本。在终端中进入此项目文件夹,创建虚拟环境,并安装服务器和 Notebook 所需的全部依赖(如有必要,请将 python3.11 替换为您使用的较新 Python 命令):
cd /Users/somenathmandal/Documents/transfer/grok-playground/MCP
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt根据示例创建 .env 文件,并将您的 Groq API 密钥放入其中:
cp .env.example .envGROQ_API_KEY=replace_with_your_groq_key
GROQ_MODEL=openai/gpt-oss-20b切勿提交或共享 .env 文件;它已被 .gitignore 排除。
Related MCP server: mcp-file-system-lmstudio
运行 MCP 服务器
在一个终端中启动 MCP 服务器,并让它保持运行:
source .venv/bin/activate
.venv/bin/python app.py现在可以通过以下地址访问 Streamable HTTP 端点:
http://127.0.0.1:8000/mcp保持该终端打开。当您想停止服务器时,按 Ctrl+C 即可。
运行智能体 Notebook
在第二个终端中:
cd /Users/somenathmandal/Documents/transfer/grok-playground/MCP
source .venv/bin/activate
jupyter lab mcp_groq_agent.ipynb如果 Jupyter 询问,请选择 .venv Python 内核,然后自上而下运行所有单元格。Notebook 会直接连接到 http://127.0.0.1:8000/mcp;它不会启动或导入 app.py。Groq API Key 从 .env 中加载,绝不会存储在 Notebook 中。
各部分如何连接
Notebook agent
-> Groq OpenAI-compatible API (model reasoning and tool selection)
-> http://127.0.0.1:8000/mcp (tool discovery and execution)
-> app.py MCP tools必须先运行服务器,然后才能执行 MCP 连接单元格。如果 Notebook 报告连接错误,请先确认服务器终端显示 Uvicorn 正在 http://127.0.0.1:8000 上运行。
Notebook 还会防范偶尔从 Notebook 启动器中继承的过期证书文件环境变量。它只会在引用的路径不存在时移除证书变量;有效的自定义证书设置会被保留。
This server cannot be deployed
Maintenance
Related MCP Connectors
Exposes FEDLIN's public security scanners as agent-callable tools over Streamable HTTP.
Discover, inspect and run 63,000+ agent tools from one balance. Pay per call, no subscriptions.
Discover, compare, route, and execute machine-accessible capabilities for AI agents.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Related MCP Servers
AlicenseBqualityBmaintenanceExposes Granoflow's local REST API and CLI as tools for AI agents, IDEs, and automation, enabling task and project management via natural language.19121 npmMIT- AlicenseNot gradedqualityCmaintenanceExposes local LM Studio language models as MCP tools, enabling chat completions and model listing through a local OpenAI-compatible API without requiring API keys.MIT
- FlicenseNot gradedqualityCmaintenanceExposes local Python tools via a persistent Streamable HTTP endpoint, allowing an OpenAI Agents SDK notebook to discover and invoke them while using Groq for reasoning and tool selection.-
- FlicenseNot gradedqualityCmaintenanceEnables an agent to discover and call local MCP tools over a Streamable HTTP endpoint using Groq for reasoning and tool selection.-