JH-MES MCP Gateway Bridge
JH-MES 智能工厂 MCP 网关的 STDIO 桥接服务。将标准 MCP STDIO 协议转发到 Java HTTP 网关,使 AI 客户端(Cursor / Cherry Studio / 通义灵码 / 魔搭 MCP 广场)能够调用 MES 业务接口。
工作原理
AI 客户端 (Cursor / Cherry Studio / 魔搭MCP广场)
│ STDIO (JSON-RPC over stdin/stdout)
▼
jh-mes-mcp (Python 桥接包, PyPI: jh-mes-mcp)
│ HTTP POST (Streamable HTTP / JSON-RPC 2.0)
▼
http://mom.azk168.cn/mcp-gateway/mcp (Java MCP 网关, Spring Boot)
│ RestTemplate
▼
jhmes:9090 / jerp:9091 (MES 业务服务)
提供的工具
| 工具 | 说明 |
|---|---|
list_tools |
列出网关上所有可用的业务接口工具(名称、描述、参数定义) |
call_tool |
调用指定业务接口工具,传入工具名和 JSON 参数 |
使用流程:AI 先调 list_tools 了解有哪些能力,再调 call_tool 执行具体业务操作。
快速开始
安装
pip install jh-mes-mcp
本地运行
# 默认连接线上网关
jh-mes-mcp
# 指定网关地址
JH_MES_GATEWAY_URL=http://localhost:9093/mcp-gateway/mcp jh-mes-mcp
MCP 客户端配置
Cursor / VS Code / Cherry Studio(mcp.json):
{
"mcpServers": {
"jh-mes": {
"command": "uvx",
"args": ["jh-mes-mcp"],
"env": {
"JH_MES_GATEWAY_URL": "http://mom.azk168.cn/mcp-gateway/mcp"
}
}
}
}
Claude Desktop(~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"jh-mes": {
"command": "uvx",
"args": ["jh-mes-mcp"],
"env": {
"JH_MES_GATEWAY_URL": "http://mom.azk168.cn/mcp-gateway/mcp"
}
}
}
}
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
JH_MES_GATEWAY_URL |
http://mom.azk168.cn/mcp-gateway/mcp |
Java MCP 网关地址 |
JH_MES_TIMEOUT |
30 |
HTTP 请求超时(秒) |
发布到 PyPI
# 1. 安装构建工具
pip install build twine
# 2. 构建包
cd mcp-bridge
python -m build
# 3. 上传到 PyPI
twine upload dist/*
# 或使用 TestPyPI 测试
twine upload --repository testpypi dist/*
魔搭 MCP 广场部署
方式一:仅分发展示(推荐)
提供 SSE URL 供外部 AI 客户端接入:
{
"mcpServers": {
"jh-mes": {
"type": "sse",
"url": "http://mom.azk168.cn/mcp-gateway/mcp"
}
}
}
在 魔搭 MCP 广场 创建时选择「仅分发展示」,填入上述 URL。
方式二:可托管部署
通过 GitHub 仓库由魔搭平台托管运行:
- 将本项目推到 GitHub
- 登录 魔搭 MCP 广场 → 创建 MCP
- 创建类型选择 「GitHub 快速创建」
- 填写:
- 来源地址:GitHub 仓库 URL
- 托管类型:可托管部署
- 平台自动读取
pyproject.toml进行构建部署
技术栈
| 组件 | 技术 |
|---|---|
| Python 桥接包 | FastMCP (mcp SDK v1/v2 兼容) + httpx |
| Java MCP 网关 | Spring Boot 2.1.2 + MyBatis-Plus |
| 协议 | JSON-RPC 2.0 + Streamable HTTP (MCP 2025-06-18) |
| 打包 | hatchling + PyPI |
项目结构
mcp-bridge/
├── pyproject.toml # PyPI 打包配置
├── README.md # 本文件
└── src/
└── jh_mes_mcp/
├── __init__.py
├── server.py # 静态版(list_tools + call_tool)
└── server_dynamic.py # 动态版(启动时加载所有业务工具为独立 MCP 工具)
切换版本:
# 使用动态版(每个业务工具作为独立 MCP 工具暴露)
copy server_dynamic.py server.py
# 恢复静态版(通用 list_tools + call_tool)
# 用备份覆盖即可
Metadata
Release files for jh-mes-mcp 1.0.34
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jh_mes_mcp-1.0.34.tar.gz | 81.5 kB | Without provenance | Details for jh_mes_mcp-1.0.34.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jh_mes_mcp-1.0.34-py3-none-any.whl | Python 3 | none | any | Details for jh_mes_mcp-1.0.34-py3-none-any.whl |
Total release size: 169.6 kB
Release files / jh_mes_mcp-1.0.34.tar.gz
| Download URL | jh_mes_mcp-1.0.34.tar.gz |
|---|---|
| Size | 81.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
391366473934e10c725c3fdc287bb865d7284fbaa20c92b101123619838f005a
|
|
BLAKE2b-256 checksum How to use checksums |
3eb631ae1d1e45226cc7ac30ecb84f174e1a7f80a97e4c8427628e7b6b24a668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / jh_mes_mcp-1.0.34-py3-none-any.whl
| Download URL | jh_mes_mcp-1.0.34-py3-none-any.whl |
|---|---|
| Size | 88.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6eb97a17fe75c4ebd51956673ec7c709fc3cfa23e9367d130e181850b9101b4c
|
|
BLAKE2b-256 checksum How to use checksums |
74f2779b13205a0668e6d201dccc08aa098f50caafe645a2dff1633bf29295a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Security for jh-mes-mcp 1.0.34
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.