@zzp123/mcp-zentao 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +4 -5
- package/dist/index.js +32 -24
- package/package.json +1 -1
- package/scripts/get_clipboard.ps1 +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.1] - 2025-11-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **修复 Windows 剪贴板图片读取问题**
|
|
12
|
+
- 替换为新的 PowerShell 脚本 `scripts/get_clipboard.ps1`
|
|
13
|
+
- 使用 `Add-Type` 加载 `System.Drawing` 程序集,确保正确处理图片
|
|
14
|
+
- 改进错误处理,提供更详细的错误信息
|
|
15
|
+
- 使用 `-ExecutionPolicy Bypass` 确保脚本可以执行
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Windows 平台现在使用外部 PowerShell 脚本文件而非内联脚本
|
|
19
|
+
- 优化了 base64 转换流程,确保内存流正确关闭
|
|
20
|
+
|
|
8
21
|
## [1.6.0] - 2025-11-05
|
|
9
22
|
|
|
10
23
|
### Changed - 重大更新
|
package/README.md
CHANGED
|
@@ -15,11 +15,10 @@ npm install @zzp123/mcp-zentao -g
|
|
|
15
15
|
|
|
16
16
|
查看完整的版本更新历史,请访问 [CHANGELOG.md](./CHANGELOG.md)
|
|
17
17
|
|
|
18
|
-
**最新版本**: v1.6.
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- ⚠️ Breaking Change: getModules 返回类型变更
|
|
18
|
+
**最新版本**: v1.6.1
|
|
19
|
+
- 修复 Windows 剪贴板图片读取问题
|
|
20
|
+
- 使用新的 PowerShell 脚本确保正确读取剪贴板图片
|
|
21
|
+
- 改进错误处理和日志输出
|
|
23
22
|
|
|
24
23
|
**主要版本**:
|
|
25
24
|
- v1.4.1 - 修复 uploadImageFromClipboard 返回值问题
|
package/dist/index.js
CHANGED
|
@@ -1017,41 +1017,49 @@ server.tool("uploadImageFromClipboard", {
|
|
|
1017
1017
|
// 读取系统剪贴板图片
|
|
1018
1018
|
let fileBuffer;
|
|
1019
1019
|
let finalFilename;
|
|
1020
|
-
// Windows: 使用 PowerShell
|
|
1020
|
+
// Windows: 使用 PowerShell 脚本读取剪贴板
|
|
1021
1021
|
if (process.platform === 'win32') {
|
|
1022
|
-
console.log('[uploadImageFromClipboard] Windows平台,使用PowerShell
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1022
|
+
console.log('[uploadImageFromClipboard] Windows平台,使用PowerShell脚本读取剪贴板...');
|
|
1023
|
+
// 使用外部 PowerShell 脚本
|
|
1024
|
+
const scriptPath = path.join(process.cwd(), 'scripts', 'get_clipboard.ps1');
|
|
1025
|
+
console.log(`[uploadImageFromClipboard] 脚本路径: ${scriptPath}`);
|
|
1026
|
+
try {
|
|
1027
|
+
const result = execSync(`powershell -ExecutionPolicy Bypass -File "${scriptPath}"`, {
|
|
1028
|
+
encoding: 'utf8',
|
|
1029
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
1030
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
1031
|
+
}).trim();
|
|
1032
|
+
if (!result || result.includes('NoImage') || result.includes('Error')) {
|
|
1033
|
+
console.error('[uploadImageFromClipboard] 剪贴板中没有图片');
|
|
1034
|
+
return {
|
|
1035
|
+
content: [{
|
|
1036
|
+
type: "text",
|
|
1037
|
+
text: JSON.stringify({
|
|
1038
|
+
error: "剪贴板中没有图片",
|
|
1039
|
+
tip: "请先复制图片,不要粘贴到输入框,直接告诉我'上传'"
|
|
1040
|
+
}, null, 2)
|
|
1041
|
+
}],
|
|
1042
|
+
isError: true
|
|
1043
|
+
};
|
|
1032
1044
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
if (!result || result.includes('NoImage') || result.includes('Error')) {
|
|
1040
|
-
console.error('[uploadImageFromClipboard] 剪贴板中没有图片');
|
|
1045
|
+
fileBuffer = Buffer.from(result, 'base64');
|
|
1046
|
+
finalFilename = filename || `clipboard_${Date.now()}.png`;
|
|
1047
|
+
console.log(`[uploadImageFromClipboard] 已读取剪贴板图片,大小: ${fileBuffer.length} bytes`);
|
|
1048
|
+
}
|
|
1049
|
+
catch (err) {
|
|
1050
|
+
console.error('[uploadImageFromClipboard] Windows读取剪贴板失败:', err);
|
|
1041
1051
|
return {
|
|
1042
1052
|
content: [{
|
|
1043
1053
|
type: "text",
|
|
1044
1054
|
text: JSON.stringify({
|
|
1045
|
-
error: "
|
|
1046
|
-
|
|
1055
|
+
error: "读取剪贴板失败",
|
|
1056
|
+
details: err.message,
|
|
1057
|
+
tip: "请确保已复制图片到剪贴板,并且 PowerShell 脚本存在于 scripts/get_clipboard.ps1"
|
|
1047
1058
|
}, null, 2)
|
|
1048
1059
|
}],
|
|
1049
1060
|
isError: true
|
|
1050
1061
|
};
|
|
1051
1062
|
}
|
|
1052
|
-
fileBuffer = Buffer.from(result, 'base64');
|
|
1053
|
-
finalFilename = filename || `clipboard_${Date.now()}.png`;
|
|
1054
|
-
console.log(`[uploadImageFromClipboard] 已读取剪贴板图片,大小: ${fileBuffer.length} bytes`);
|
|
1055
1063
|
}
|
|
1056
1064
|
// macOS: 使用 pngpaste
|
|
1057
1065
|
else if (process.platform === 'darwin') {
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
2
|
+
Add-Type -AssemblyName System.Drawing
|
|
3
|
+
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
4
|
+
if ($img) {
|
|
5
|
+
$ms = New-Object System.IO.MemoryStream
|
|
6
|
+
$img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
7
|
+
$bytes = $ms.ToArray()
|
|
8
|
+
$ms.Close()
|
|
9
|
+
$base64 = [Convert]::ToBase64String($bytes)
|
|
10
|
+
Write-Output $base64
|
|
11
|
+
} else {
|
|
12
|
+
Write-Error "NoImage"
|
|
13
|
+
}
|