-
Notifications
You must be signed in to change notification settings - Fork 12
feat: use MinIO to storage chart image #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
添加MinIO对象存储支持,将图表图片存储为URL而非Base64数据 重构所有图表工具使用统一的generateChartImageForTool方法 更新文档说明MinIO配置和故障排查指南 添加环境变量配置和调试日志支持
将返回的HTML img标签改为纯文本文件地址显示,提高兼容性
神速~ |
src/tools/boxplot.ts
Outdated
height, | ||
theme, | ||
"png", | ||
"generateboxplot_chart", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥缺了一个下划线?
src/utils/imageHandler.ts
Outdated
|
||
/** | ||
* 统一的图片生成和处理方法 | ||
* 根据配置自动决定返回base64图片数据还是MinIO URL的img标签 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中英文,中文和数字之间加一个空格。下同~
src/utils/imageHandler.ts
Outdated
content: [ | ||
{ | ||
type: "text", | ||
text: `Chart image is available at: ${result}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url 也是直接返回,不用加一段描述文本。
src/utils/render.ts
Outdated
return !!( | ||
process.env.MINIO_ACCESS_KEY && | ||
process.env.MINIO_SECRET_KEY && | ||
process.env.MINIO_ENDPOINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minio 需要这么多配置?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access_key跟secret_key是必须有的
src/utils/render.ts
Outdated
} | ||
|
||
// Fallback to base64 if MinIO is not configured | ||
return `data:image/png;base64,${buffer.toString("base64")}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个写法不好,方法不纯粹,这个方法可以统一返回 buffer,至于 buffer 怎么处理,可以在外层如处理。
minio 只能本地启动软件,然后使用吗?感觉这个用法稍显复杂啊,有没有更简单的用法。 |
@Susuperli 有兴趣加一个微信,看我主页有微信号。我们电话聊一下这个 PR。 |
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 |
There was a problem hiding this comment.
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:** |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base64
TROUBLESHOOTING.md
Outdated
@@ -0,0 +1,90 @@ | |||
# Troubleshooting Empty Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移除,后续按需加。
src/utils/imageHandler.ts
Outdated
/** | ||
* MCP内容类型 | ||
*/ | ||
export interface MCPContent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mcp sdk。
src/utils/imageHandler.ts
Outdated
* @param toolName 工具名称(用于调试日志) | ||
* @returns MCP响应内容 | ||
*/ | ||
export async function generateChartImageForTool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
合并成一个方法:generateChartImage
src/utils/render.ts
Outdated
@@ -1,7 +1,10 @@ | |||
import fs from "node:fs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 这个文件基本不变,保持纯函数。
- minio 的单独一个文件,所有相关都放这里面,按需 export。
将`generateChartImageForTool`合并到`generateChartImage`中,简化代码结构 将MinIO相关逻辑抽离到单独模块 更新所有工具文件使用新的统一函数 优化README文档并移除过时的TROUBLESHOOTING文件
更新对象存储提供商集成部分,将标题改为更通用的描述并添加MinIO的详细集成信息
代码有冲突了~ |
MinIO
to save the chart image base64 and return the url. #10添加MinIO对象存储支持,将图表图片存储为URL而非Base64数据
重构所有图表工具使用统一的generateChartImageForTool方法
更新文档说明MinIO配置和故障排查指南
添加环境变量配置和调试日志支持