Skip to main content

连接MCP与视觉AI模型的网关服务,支持图像处理和纯文本对话

Project description

MCP Vision Gateway (视觉AI网关)

一个连接MCP与视觉AI模型的网关服务,支持纯文本对话和图像分析(通过URL或Base64编码)。

安装

pip install mcp-vision-gateway

功能

工具 (Tools)

  • vision_query: 向AI模型发送查询,支持纯文本对话和图像分析

    • 支持通过URL引用图像
    • 支持通过image_ref引用图像(推荐方式)
    • 支持通过base64编码传递图像
    • 可自定义模型、温度等参数
  • upload_image_from_url: 从URL下载图像并获取引用ID

    • 返回一个图像引用ID而非base64字符串
    • 避免传输大量base64文本
  • upload_local_image: 从本地文件读取图像并获取引用ID

    • 返回一个图像引用ID而非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

使用示例

1. 纯文本对话

vision_query(
    prompt="你好,请问今天的天气如何?"
)

2. 使用URL传递图像

vision_query(
    prompt="描述这张图片",
    image_url="https://example.com/image.jpg"
)

3. 使用图像引用ID(推荐方式)

# 从本地文件获取图像引用ID
image_id = upload_local_image("C:/Users/YourName/Pictures/photo.jpg")

# 或从URL获取图像引用ID
# image_id = upload_image_from_url("https://example.com/image.jpg")

# 使用图像引用ID进行查询
vision_query(
    prompt="描述这张图片",
    image_ref=image_id
)

4. 指定自定义参数

vision_query(
    prompt="描述这张图片",
    image_ref=image_id,
    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

mcp_vision_gateway-0.1.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_vision_gateway-0.1.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_vision_gateway-0.1.3.tar.gz.

File metadata

  • Download URL: mcp_vision_gateway-0.1.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for mcp_vision_gateway-0.1.3.tar.gz
Algorithm Hash digest
SHA256 92b7b7760e1a345a9a592cd99e62f32bdc48f32563fc7326f3b76c26198980b0
MD5 bafd7c2c86c54149cce91e794f629da7
BLAKE2b-256 940330b9f31cee8d82a570ae19fd4380a54c3dd6b1c45aec1e6ae01a83c26cb1

See more details on using hashes here.

File details

Details for the file mcp_vision_gateway-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_vision_gateway-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61c18e10ee55727316334eb22aa7885a5062e19ef7895130b736a70ce2847f42
MD5 4e7e424826384647e07daabbdbd1cac6
BLAKE2b-256 51d50ac16c6d5153f4e079ec3c054e0e4699eb3d8cd4b7497fd053776db2e0a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page