Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions AI_TEST_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# AI端图片数据接收测试说明

## 📋 测试目的
验证AI端是否能正确接收到通过MCP协议传输的图片数据,以及数据格式是否符合标准。

## 🚀 快速测试(推荐)

### 方法1:使用修复版测试脚本
```bash
# 1. 进入项目目录
cd /Users/lizhenmin/Documents/Cline/MCP/mcp-feedback-enhanced

# 2. 激活虚拟环境
source venv/bin/activate

# 3. 运行修复版测试(解决大数据传输问题)
python simple_ai_test_fixed.py
```

### 方法2:使用完整模拟器
```bash
# 1. 进入项目目录
cd /Users/lizhenmin/Documents/Cline/MCP/mcp-feedback-enhanced

# 2. 激活虚拟环境
source venv/bin/activate

# 3. 运行完整模拟器
python simulate_ai_client.py
```

## 📊 测试流程

1. **脚本启动**:自动启动MCP服务器进程
2. **连接初始化**:建立MCP协议连接
3. **工具调用**:AI调用`interactive_feedback`工具
4. **等待数据**:等待60-120秒接收用户反馈
5. **数据分析**:分析接收到的图片数据
6. **结果报告**:生成详细的测试报告

## 🔍 测试期间操作

当脚本显示"等待用户反馈"时,你可以:

1. **通过Augment Code界面**上传图片
2. **通过其他MCP客户端**发送图片数据
3. **等待超时**查看基础功能

## 📈 预期结果

### ✅ 成功情况
```
🎉 发现图片!
MIME: image/png
Base64长度: 99,328 字符
文件大小: 72.7 KB
格式: ✅ PNG
保存为: ai_test_image_1.png

📊 测试结果:
文本项目: 1
图片项目: 1

🎉 成功!AI端接收到了 1 张图片
✅ 图片数据传输正常
✅ MCP协议工作正常
```

### ⚠️ 超时情况
```
📊 测试结果:
文本项目: 1
图片项目: 0

⚠️ 没有接收到图片数据
💡 可能是超时或没有上传图片
```

## 🔧 验证要点

脚本会自动验证以下内容:

### 1. MCP协议格式
- ✅ `type: "image"`
- ✅ `data: "base64字符串"`
- ✅ `mimeType: "image/png"`

### 2. 数据完整性
- ✅ Base64解码成功
- ✅ 文件头格式正确
- ✅ 文件大小合理

### 3. 图片格式支持
- ✅ PNG格式
- ✅ JPEG格式
- ✅ GIF格式
- ✅ 其他格式检测

## 📁 输出文件

测试成功时会生成:
- `ai_test_image_1.png` - 接收到的第一张图片
- `ai_test_image_2.png` - 接收到的第二张图片
- 等等...

## 🐛 故障排除

### 问题1:服务器启动失败
```bash
# 检查虚拟环境
source venv/bin/activate
python -c "import mcp_feedback_enhanced; print('OK')"
```

### 问题2:连接超时
```bash
# 检查端口占用
lsof -i :8765
```

### 问题3:没有接收到图片
- 确认在等待期间上传了图片
- 检查图片格式是否支持
- 查看控制台错误信息

## 📝 测试记录

建议记录以下信息:
- [ ] 测试时间
- [ ] 上传的图片格式和大小
- [ ] 接收到的数据项数量
- [ ] Base64数据长度
- [ ] 解码后的文件大小
- [ ] 是否生成了测试文件

## 🎯 测试目标

通过这个测试,我们要验证:
1. ✅ MCP服务器能正确处理图片数据
2. ✅ AI端能接收到完整的图片数据
3. ✅ 数据格式符合MCP ImageContent标准
4. ✅ Base64编码/解码工作正常
5. ✅ 图片文件可以正确重建

---

**准备好了吗?运行测试脚本开始验证吧!** 🚀
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ follow mcp-feedback-enhanced instructions
| `MCP_WEB_PORT` | Web UI port | `1024-65535` | `8765` |
| `MCP_DESKTOP_MODE` | Desktop application mode | `true`/`false` | `false` |
| `MCP_LANGUAGE` | Force UI language | `zh-TW`/`zh-CN`/`en` | Auto-detect |
| `MCP_AI_CLIENT` | AI client type identification | `cursor`/`augment`/custom | `cursor` |

**`MCP_WEB_HOST` Explanation**:
- `127.0.0.1` (default): Local access only, higher security
Expand All @@ -192,6 +193,17 @@ follow mcp-feedback-enhanced instructions
4. System default language
5. Fallback to default language (Traditional Chinese)

**`MCP_AI_CLIENT` Explanation**:
- Used to identify the AI client type for customized response formats
- **Default**: `cursor` (standard MCP protocol)
- When set to `cursor`: Uses standard MCP protocol with separate text and image content (recommended for Cursor, Cline, Windsurf)
- When set to `augment`: Returns text content with embedded base64 image data for easy JavaScript extraction (recommended for Augment)
- When set to other values: Uses standard MCP protocol with separate text and image content
- Augment format includes special markers for programmatic parsing:
- Text content: Standard feedback text
- Image data: Embedded as `data:mime/type;base64,<data>` with `---END_IMAGE_N---` markers
- Extraction-friendly format for client-side processing

### Testing Options
```bash
# Version check
Expand Down Expand Up @@ -414,3 +426,9 @@ MIT License - See [LICENSE](LICENSE) file for details

---
**🌟 Welcome to Star and share with more developers!**



MCP_WEB_PORT=8765 MCP_AI_CLIENT=augment MCP_DEBUG=true \
uv run --directory "/Users/lizhenmin/Documents/Cline/MCP/mcp-feedback-enhanced" \
python -m mcp_feedback_enhanced 2>/tmp/mcp-fe.log
12 changes: 12 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pip install uv
| `MCP_WEB_PORT` | Web UI 端口 | `1024-65535` | `8765` |
| `MCP_DESKTOP_MODE` | 桌面应用程序模式 | `true`/`false` | `false` |
| `MCP_LANGUAGE` | 强制指定界面语言 | `zh-TW`/`zh-CN`/`en` | 自动检测 |
| `MCP_AI_CLIENT` | AI 客户端类型识别 | `cursor`/`augment`/自定义 | `cursor` |

**`MCP_WEB_HOST` 说明**:
- `127.0.0.1`(默认):仅本地访问,安全性较高
Expand All @@ -192,6 +193,17 @@ pip install uv
4. 系统默认语言
5. 回退到默认语言(繁体中文)

**`MCP_AI_CLIENT` 说明**:
- 用于识别 AI 客户端类型,提供定制化的响应格式
- **默认值**: `cursor`(标准 MCP 协议)
- 当设置为 `cursor` 时:使用标准 MCP 协议,文本和图片内容分别传输(推荐用于 Cursor、Cline、Windsurf)
- 当设置为 `augment` 时:返回包含嵌入式 base64 图片数据的文本内容,便于 JavaScript 提取(推荐用于 Augment)
- 当设置为其他值时:使用标准 MCP 协议,文本和图片内容分别传输
- Augment 格式包含特殊标记便于程序化解析:
- 文本内容:标准反馈文本
- 图片数据:嵌入为 `data:mime/type;base64,<data>` 格式,带有 `---END_IMAGE_N---` 标记
- 便于客户端提取的格式

### 测试选项
```bash
# 版本查询
Expand Down
14 changes: 13 additions & 1 deletion README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pip install uv
| `MCP_WEB_PORT` | Web UI 端口 | `1024-65535` | `8765` |
| `MCP_DESKTOP_MODE` | 桌面應用程式模式 | `true`/`false` | `false` |
| `MCP_LANGUAGE` | 強制指定介面語言 | `zh-TW`/`zh-CN`/`en` | 自動偵測 |
| `MCP_AI_CLIENT` | AI 客戶端類型識別 | `cursor`/`augment`/自訂 | `cursor` |

**`MCP_WEB_HOST` 說明**:
- `127.0.0.1`(預設):僅本地存取,安全性較高
Expand All @@ -183,7 +184,7 @@ pip install uv
- 用於強制指定介面語言,覆蓋系統自動偵測
- 支援的語言代碼:
- `zh-TW`:繁體中文
- `zh-CN`:簡體中文
- `zh-CN`:簡體中文
- `en`:英文
- 語言偵測優先順序:
1. 用戶在介面中保存的語言設定(最高優先級)
Expand All @@ -192,6 +193,17 @@ pip install uv
4. 系統預設語言
5. 回退到預設語言(繁體中文)

**`MCP_AI_CLIENT` 說明**:
- 用於識別 AI 客戶端類型,提供客製化的回應格式
- **預設值**: `cursor`(標準 MCP 協定)
- 當設定為 `cursor` 時:使用標準 MCP 協定,文字和圖片內容分別傳輸(推薦用於 Cursor、Cline、Windsurf)
- 當設定為 `augment` 時:回傳包含嵌入式 base64 圖片資料的文字內容,便於 JavaScript 提取(推薦用於 Augment)
- 當設定為其他值時:使用標準 MCP 協定,文字和圖片內容分別傳輸
- Augment 格式包含特殊標記便於程式化解析:
- 文字內容:標準回饋文字
- 圖片資料:嵌入為 `data:mime/type;base64,<data>` 格式,帶有 `---END_IMAGE_N---` 標記
- 便於客戶端提取的格式

### 測試選項
```bash
# 版本查詢
Expand Down
145 changes: 145 additions & 0 deletions detect_mcp_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/usr/bin/env python3
"""
检测MCP客户端协议版本
"""

import sys
from pathlib import Path

# 添加项目路径
sys.path.insert(0, str(Path(__file__).parent / "src"))

from mcp.types import TextContent, ImageContent


def detect_mcp_version():
"""检测MCP协议版本和客户端支持情况"""
print("🔍 检测MCP协议版本和客户端支持")

# 1. 检查MCP types模块
print("\n1️⃣ 检查MCP types模块")
try:
import mcp.types as types
print(f" mcp.types模块: ✅ 可用")

# 检查可用的类型
available_types = []
for attr_name in dir(types):
if not attr_name.startswith('_'):
attr = getattr(types, attr_name)
if isinstance(attr, type):
available_types.append(attr_name)

print(f" 可用类型: {', '.join(sorted(available_types))}")

# 检查关键类型
key_types = ['TextContent', 'ImageContent', 'EmbeddedResource', 'BlobResourceContents']
for key_type in key_types:
if hasattr(types, key_type):
print(f" {key_type}: ✅ 支持")
else:
print(f" {key_type}: ❌ 不支持")

except ImportError as e:
print(f" mcp.types模块: ❌ 导入失败 - {e}")
return False

# 2. 测试ImageContent创建
print("\n2️⃣ 测试ImageContent创建")
try:
test_image = ImageContent(
type="image",
data="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1Pe",
mimeType="image/png"
)
print(f" ImageContent创建: ✅ 成功")
print(f" 类型: {type(test_image)}")
print(f" 属性: type={test_image.type}, mimeType={test_image.mimeType}")

# 检查序列化
if hasattr(test_image, 'model_dump'):
dump = test_image.model_dump()
print(f" 序列化方法: model_dump() ✅")
print(f" 序列化结果: {list(dump.keys())}")
elif hasattr(test_image, 'dict'):
dump = test_image.dict()
print(f" 序列化方法: dict() ✅")
print(f" 序列化结果: {list(dump.keys())}")
else:
print(f" 序列化方法: ❌ 无标准方法")

except Exception as e:
print(f" ImageContent创建: ❌ 失败 - {e}")
return False

# 3. 检查FastMCP版本
print("\n3️⃣ 检查FastMCP版本")
try:
from fastmcp import FastMCP
print(f" FastMCP: ✅ 可用")

# 尝试获取版本信息
if hasattr(FastMCP, '__version__'):
print(f" 版本: {FastMCP.__version__}")
else:
print(f" 版本: 未知")

except ImportError as e:
print(f" FastMCP: ❌ 导入失败 - {e}")

# 4. 检查MCP协议特性
print("\n4️⃣ 检查MCP协议特性")

# 检查是否支持2025-06-18特性
features_2025_06_18 = {
"ImageContent": hasattr(types, 'ImageContent'),
"EmbeddedResource": hasattr(types, 'EmbeddedResource'),
"BlobResourceContents": hasattr(types, 'BlobResourceContents'),
}

supported_features = sum(features_2025_06_18.values())
total_features = len(features_2025_06_18)

print(f" 2025-06-18特性支持: {supported_features}/{total_features}")
for feature, supported in features_2025_06_18.items():
status = "✅" if supported else "❌"
print(f" {feature}: {status}")

# 5. 协议版本推断
print("\n5️⃣ 协议版本推断")

if supported_features == total_features:
version_estimate = "2025-06-18或更新"
compatibility = "完全兼容"
image_support = "应该完全支持ImageContent"
elif supported_features >= total_features * 0.7:
version_estimate = "接近2025-06-18"
compatibility = "部分兼容"
image_support = "可能部分支持ImageContent"
else:
version_estimate = "2025-06-18之前"
compatibility = "有限兼容"
image_support = "可能不支持ImageContent显示"

print(f" 估计协议版本: {version_estimate}")
print(f" 兼容性: {compatibility}")
print(f" 图片支持: {image_support}")

# 6. 建议
print("\n6️⃣ 建议")

if supported_features == total_features:
print(" ✅ 您的MCP环境支持最新特性")
print(" 💡 如果图片仍无法显示,问题可能在客户端渲染层")
print(" 🔧 建议:检查MCP客户端的ImageContent处理实现")
else:
print(" ⚠️ 您的MCP环境可能不完全支持最新特性")
print(" 💡 建议升级到最新版本的MCP Python SDK")
print(" 🔧 或者使用向后兼容的文本格式传输图片信息")

return True


if __name__ == "__main__":
success = detect_mcp_version()
sys.exit(0 if success else 1)
Loading
Loading