Skip to main content
Glama
synabreu

Hello Plugins

by synabreu

Hello, Plugins! — Python OpenAI Plugin

这是一个调用 hello_plugins 工具时会精确返回 Hello, Plugins! 的最小 OpenAI Plugin 示例。

OpenAI Plugin 可以由 Skill、MCP 服务器或两者组成。该项目是需要可执行代码的最小形态,因此只使用一个 Python MCP 服务器。由于不会直接调用 OpenAI API,因此也不需要 OPENAI_API_KEY。

项目结构

hello-plugins-python/
├── server.py          # MCP 서버와 hello_plugins 도구
├── test_server.py     # 반환 문자열 테스트
├── requirements.txt  # 고정된 Python 의존성
├── pyproject.toml
├── Dockerfile
└── README.md

Related MCP server: hello-mcp

在 Windows 11 / PowerShell 中运行

需要 Python 3.10 或更高版本。

cd hello-plugins-python
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python server.py

运行后 MCP Streamable HTTP 地址如下:

http://localhost:8000/mcp

如果因 PowerShell 执行策略导致虚拟环境激活失败,请先仅在当前终端中执行以下命令:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

在 macOS / Linux 中运行

cd hello-plugins-python
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python server.py

测试

python -m pytest -q
python verify_mcp.py

预期结果:

1 passed
MCP verification passed: Hello, Plugins!

使用 MCP Inspector 验证

如果已安装 Node.js,请运行以下命令:

npx @modelcontextprotocol/inspector

在 Inspector 中将 Transport 选择为 Streamable HTTP,并在 URL 中输入 http://localhost:8000/mcp。连接后调用 hello_plugins 工具,将返回以下字符串:

Hello, Plugins!

作为个人 Plugin 连接到 ChatGPT Work

由于 ChatGPT 无法直接访问本地 PC 的 localhost,要进行测试,需要将 /mcp 端点部署为公共 HTTPS 地址,或使用 OpenAI Secure MCP Tunnel。

  1. 将服务器部署到公共 HTTPS 环境。

  2. 在 ChatGPT 中开启 Settings → Security and login → Developer mode。

  3. 在 Plugins 界面点击 +,输入 https://YOUR-DOMAIN/mcp。

  4. 安装生成的个人 Plugin。

  5. 在 Work 聊天中选择 @Hello Plugins,并输入“输出插件的问候语”。

Docker 运行

docker build -t hello-plugins .
docker run --rm -p 8000:8000 hello-plugins

核心代码

@mcp.tool(
    name="hello_plugins",
    description="Return the exact greeting 'Hello, Plugins!'. This tool is read-only.",
)
def hello_plugins() -> str:
    return "Hello, Plugins!"

参考

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A minimal Model Context Protocol server that facilitates network-based client connections using Streamable HTTP transport. It provides a greeting tool and is optimized for consistent deployment across local environments, Docker, and Kubernetes.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A minimal learning-focused MCP server that demonstrates core primitives like tools and resources through simple greeting functions. It provides a foundational example for connecting AI models to external data using both Streamable HTTP and stdio transports.
    10 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A minimal MCP server offering a hello_world tool that returns a greeting and current UTC time via streamable HTTP.
    -
  • A
    license
    A
    quality
    A
    maintenance
    A minimal MCP server that provides health/status checks and multilingual greetings via the server_info and greet tools.
    2
    MIT