Skip to main content
Glama

python3 -m venv .venv 或 python -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt .venv\Scripts\python.exe app.py

本地 MCP + Groq + OpenAI Agents SDK

本课堂示例包含:

  • app.py:一个持久的本地 Streamable HTTP MCP 服务器,带有多个工具。

  • mcp_groq_agent.ipynb:一个智能体,用于发现并调用这些工具。

设置

使用 Python 3.10 或更高版本。在终端中进入本项目文件夹,创建 虚拟环境,并安装服务器和笔记本所需的全部依赖 (如有必要,请将 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 .env
GROQ_API_KEY=replace_with_your_groq_key
GROQ_MODEL=openai/gpt-oss-20b

切勿提交或分享 .env 文件;它已被 .gitignore 排除。

Related MCP server: Codex Harness MCP

运行 MCP 服务器

在一个终端中启动 MCP 服务器,并让它保持运行:

source .venv/bin/activate
.venv/bin/python app.py

Streamable HTTP 端点现在可通过以下地址访问:

http://127.0.0.1:8000/mcp

保持该终端处于打开状态。想停止服务器时,按 Ctrl+C。

运行智能体笔记本

在第二个终端中:

cd /Users/somenathmandal/Documents/transfer/grok-playground/MCP
source .venv/bin/activate
jupyter lab mcp_groq_agent.ipynb

如果 Jupyter 提示,请选择 .venv Python 内核,然后从上到下 运行这些单元格。该笔记本直接连接到 http://127.0.0.1:8000/mcp;它从不 启动或导入 app.py。Groq API 密钥从 .env 加载,且从不 存储在笔记本中。

各部分如何连接

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 连接单元格之前,服务器必须处于运行状态。如果 笔记本报告连接错误,请首先确认服务器终端显示 Uvicorn 正在 http://127.0.0.1:8000 上运行。

笔记本还会防范偶尔从笔记本启动器继承的过期证书文件环境变量。 仅在引用的路径不存在时,它才会移除证书变量; 有效的自定义证书设置会被保留。

MCP

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP-compatible AI clients to invoke CLI-driven agent tools over Streamable HTTP, including shell execution, file operations, patching, image viewing, web search, and nested agent tasks, with permission modes and real-time progress streaming.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes 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.
      -