Skip to content

Conversation

Susuperli
Copy link
Collaborator

@Susuperli Susuperli commented Jul 28, 2025

添加MinIO对象存储支持,将图表图片存储为URL而非Base64数据
重构所有图表工具使用统一的generateChartImageForTool方法
更新文档说明MinIO配置和故障排查指南
添加环境变量配置和调试日志支持

添加MinIO对象存储支持,将图表图片存储为URL而非Base64数据
重构所有图表工具使用统一的generateChartImageForTool方法
更新文档说明MinIO配置和故障排查指南
添加环境变量配置和调试日志支持
@Susuperli
Copy link
Collaborator Author

image

将返回的HTML img标签改为纯文本文件地址显示,提高兼容性
@hustcc
Copy link
Owner

hustcc commented Jul 28, 2025

神速~

height,
theme,
"png",
"generateboxplot_chart",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥缺了一个下划线?


/**
* 统一的图片生成和处理方法
* 根据配置自动决定返回base64图片数据还是MinIO URL的img标签
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中英文,中文和数字之间加一个空格。下同~

content: [
{
type: "text",
text: `Chart image is available at: ${result}`,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url 也是直接返回,不用加一段描述文本。

return !!(
process.env.MINIO_ACCESS_KEY &&
process.env.MINIO_SECRET_KEY &&
process.env.MINIO_ENDPOINT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minio 需要这么多配置?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access_key跟secret_key是必须有的

}

// Fallback to base64 if MinIO is not configured
return `data:image/png;base64,${buffer.toString("base64")}`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个写法不好,方法不纯粹,这个方法可以统一返回 buffer,至于 buffer 怎么处理,可以在外层如处理。

@hustcc hustcc changed the title feat(图表生成): 实现MinIO集成和统一图片处理逻辑 feat: use MinIO to storage chart image Jul 28, 2025
@hustcc
Copy link
Owner

hustcc commented Jul 28, 2025

minio 只能本地启动软件,然后使用吗?感觉这个用法稍显复杂啊,有没有更简单的用法。

@hustcc
Copy link
Owner

hustcc commented Jul 28, 2025

@Susuperli 有兴趣加一个微信,看我主页有微信号。我们电话聊一下这个 PR。

@hustcc
Copy link
Owner

hustcc commented Jul 28, 2025

Readme 的 contributors 中,加一下自己吧,可以放到第二个,贡献第二。

README.md Outdated
- ✅ **Reduced token usage** - URLs are much shorter than Base64 data
- ✅ **Permanent accessibility** - Charts remain available long-term
- ✅ **Easy sharing** - Send URLs to others to view charts
- ✅ **Better UX** - Most MCP clients handle URLs better than Base64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除,内容精炼到 feature 部分即可。

README.md Outdated
MINIO_BUCKET_NAME=mcp-echarts
```

3. **Test the connection:**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除。

README.md Outdated

### Fallback Behavior

If MinIO is not configured or unavailable, the system automatically falls back to Base64 data output, ensuring compatibility.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base64

@@ -0,0 +1,90 @@
# Troubleshooting Empty Results
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除,后续按需加。

/**
* MCP内容类型
*/
export interface MCPContent {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mcp sdk。

* @param toolName 工具名称(用于调试日志)
* @returns MCP响应内容
*/
export async function generateChartImageForTool(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并成一个方法:generateChartImage

@@ -1,7 +1,10 @@
import fs from "node:fs";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 这个文件基本不变,保持纯函数。
  2. minio 的单独一个文件,所有相关都放这里面,按需 export。

liyongzhi02 added 4 commits July 29, 2025 16:25
将`generateChartImageForTool`合并到`generateChartImage`中,简化代码结构
将MinIO相关逻辑抽离到单独模块
更新所有工具文件使用新的统一函数
优化README文档并移除过时的TROUBLESHOOTING文件
更新对象存储提供商集成部分,将标题改为更通用的描述并添加MinIO的详细集成信息
@hustcc
Copy link
Owner

hustcc commented Jul 29, 2025

代码有冲突了~

@Susuperli Susuperli merged commit a9739d4 into hustcc:main Jul 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use MinIO to save the chart image base64 and return the url.
2 participants