连接MCP与视觉AI模型的网关服务,支持图像处理和纯文本对话
Project description
MCP Vision Gateway (视觉AI网关)
一个连接MCP与视觉AI模型的网关服务,支持通过URL或Base64编码方式发送图像。
安装
pip install mcp-vision-gateway
功能
工具 (Tools)
-
vision_query: 向视觉AI模型发送带图像的查询- 支持通过URL引用图像
- 支持通过base64编码传递图像
- 可自定义模型、温度等参数
-
upload_image_from_url: 从URL下载图像并转换为base64- 方便后续使用base64方式传递图像
-
list_available_models: 列出可用的AI模型
环境变量配置
设置以下环境变量来配置默认参数:
VISION_API_BASE: API基础URL (默认: https://api.ssopen.top)VISION_API_KEY: API密钥 (必须设置)VISION_DEFAULT_MODEL: 默认模型 (默认: gpt-4o)VISION_DEBUG: 调试模式 (设置为"true"启用)
在阿里云百炼中使用
在阿里云百炼平台的MCP服务配置中,使用以下JSON:
{
"mcpServers": {
"vision-gateway": {
"command": "uvx",
"args": ["mcp-vision-gateway"],
"env": {
"VISION_API_KEY": "你的API密钥",
"VISION_DEFAULT_MODEL": "gpt-4o"
}
}
}
}
本地运行
安装后,在设置好环境变量的情况下,可以通过以下方式运行:
# 使用uvx
uvx mcp-vision-gateway
# 使用包提供的命令
mcp-vision-gateway
# 使用Python -m
python -m mcp_vision_gateway
使用示例
使用URL传递图像
vision_query(
prompt="描述这张图片",
image_url="https://example.com/image.jpg"
)
使用Base64传递图像
# 先从URL获取图像的base64
base64_image = upload_image_from_url("https://example.com/image.jpg")
# 然后使用base64图像
vision_query(
prompt="描述这张图片",
image_base64=base64_image
)
指定自定义参数
vision_query(
prompt="描述这张图片",
image_url="https://example.com/image.jpg",
model="gpt-4o-mini",
temperature=0.5,
max_tokens=500,
api_key="自定义API密钥"
)
许可证
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_vision_gateway-0.1.2.tar.gz.
File metadata
- Download URL: mcp_vision_gateway-0.1.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c58ac27073d26850ba8f7d8feeb5df76bbf6d7bfa97fa4dda56866442858bc1
|
|
| MD5 |
6ee8150d462ab0886b71793b40bd959f
|
|
| BLAKE2b-256 |
952fed0852964e7fce0967337670442b1fe79a0447a9dbf5a9aca9752500ad4c
|
File details
Details for the file mcp_vision_gateway-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mcp_vision_gateway-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2b167cf5f610ed52e98afae25afc5fd90f079e61c26c28bd237fa3832c2e60e
|
|
| MD5 |
a34fe695d5ee7eeb10694af7715e59b8
|
|
| BLAKE2b-256 |
7b84d6ef5cac18d523e96edd38dc5ffb1c922414c54ccf66517c1cf2854f6a87
|