mlcartifact-MCP生态系统的共享存储层
不要通过LLM路由大数据。 让MCP服务器将文件写入共享存储,只交换一个ID。LLM决定下一步做什么,而不会看到原始数据。
 
版权所有(c)2026 Michael Lechner。根据MIT许可证获得许可。
德语版
______________________________________________________________________
问题:大数据不属于LLM环境
想象一下,一个返回50000行的SQLMCP服务器。或者生成2MB PDF的报告生成器。如果这些结果流经LLM的上下文窗口,您将:
- 废弃代币 -大规模
- 命中上下文限制 -经常
- 把一切都慢下来 -不必要的
软骨炎 解决方案是:共享工件存储。MCP服务器将其输出直接写入其中,并仅告知LLM: *“完成。工件ID: abc123.列:名称、总数、日期。"*
______________________________________________________________________
MCP服务器到服务器数据交换模式
LLM: "Run the quarterly SQL report and turn it into a PDF."
MCP Server A (SQL) mlcartifact MCP Server B (PDF)
| | |
|-- write_artifact() -->| |
| report.csv (2MB) | |
||大数据从未流经LLM。 仅交换工件ID。LLM进行编排——它不携带数据。
______________________________________________________________________
为什么选择gRPC和工件模式?
超越简单的本地文件存储, mlcartifact 使用gRPC优先的方法来解决分布式MCP生态系统的独特挑战:
- 无缝便携:服务可以在主机、Docker容器或远程服务器上运行。它们都通过gRPC连接,不需要共享卷或复杂的文件系统权限。
- 增强安全性(沙盒):MCP服务器不需要对主机的文件系统进行广泛访问。它们只与Artifact API交互,在您的数据和潜在的不受信任的工具之间提供了一个安全的边界。
- 多服务器数据交换:启用“共享内存”模式,其中服务器A写入数据,服务器B读取数据,由LLM仅使用ID进行编排。
- 丰富的元数据和生命周期:自动处理MIME类型、源跟踪和 自动过期.
比较:gRPC API与本地文件系统
| 特点 | mlcartifact (gRPC) | 本地文件系统(/tmp等等) |
|---|---|---|
| 孤立 | 高 (API定义的边界) | 低 (需要广泛的操作系统权限) |
| 可移植性 | 通用 (基于网络) | 主机已锁定 (需要共享卷) |
| 多用户 | 内置范围 | 手动权限管理 |
| 清理 | 自动(基于TTL) | 需要手动或定时作业 |
| 演出 | 网络延迟(ms) | 磁盘I/O速度 |
| 复杂性 | 需要服务器进程 | 无需额外进程 |
权衡:虽然gRPC引入了较小的网络延迟并需要运行服务器进程,但在生产MCP环境中,安全性、多服务器编排和简化部署方面的好处通常远远超过这些成本。
______________________________________________________________________
此存储库中有什么
| 组件 | 描述 |
|---|---|
artifact-server | MCP+gRPC服务器。储存和供应文物。会说stdio和SSE。 |
artifact-cli | 命令行工具,用于上传、下载、列出和删除工件。 |
| 去图书馆 | import "github.com/hmsoft0815/mlcartifact/client" -直接嵌入任何MCP服务器。 |
| TypeScript客户端 | npm install @hmsoft0815/mlcartifact-client -使用Connect RPC的通用客户端(节点、浏览器、边缘)。 |
| Rust SDK | 可用于 client-rust/ -gRPC客户端使用Tonic。 |
生态系统及相关项目
- 沃尔米尔肖 -一个“瑞士军刀”MCP服务器,可以执行作为工件存储在
mlcartifact它允许动态工具执行,LLM将脚本写入工件存储wollmilchsau在安全的环境中执行它。
______________________________________________________________________
文档
- Go客户端库指南 -面向Go开发者的全面指南。
- Python客户端 -Python开发人员的实现和使用。
- gRPC API参考 -gRPC协议的详细技术参考。
______________________________________________________________________
快速开始
安装
# via install script (Linux/macOS)
curl -sfL https://raw.githubusercontent.com/hmsoft0815/mlcartifact/main/scripts/install.sh | sh
# or via Go
go install github.com/hmsoft0815/mlcartifact/cmd/artifact-server@latest
go install github.com/hmsoft0815/mlcartifact/cmd/artifact-cli@latest预建 .deb, .rpm,以及二进制文件 ****.
启动服务器
# stdio mode (for Claude Desktop / MCP)
artifact-server -data-dir ~/mlcartifact/storage
# SSE/HTTP mode (for remote MCP servers)
artifact-server -addr :8082 -grpc-addr :9590 -data-dir ~/mlcartifact/storage在MCP服务器中使用Go库
看 Go客户端库指南 详细用法和示例。
import "github.com/hmsoft0815/mlcartifact/client"
// Connect (reads ARTIFACT_GRPC_ADDR env var, defaults to :9590)
c, _ := client.NewClient()
defer c.Close()
// Store a large result - returns an ID, not the data
resp, _ := c.Write(ctx, "report.csv", csvData,
client.WithMimeType("text/csv"),
client.WithExpiresHours(24),
)
// Tell the LLM: "Done. ID: abc123. Columns: name, total, date."
fmt.Println("artifact_id:", resp.Id)______________________________________________________________________
Claude桌面集成
{
"mcpServers": {
"mlcartifact": {
"command": "/path/to/artifact-server",
"args": ["-data-dir", "/your/artifacts"]
}
}
}或者通过SSE连接到正在运行的实例(推荐,但需要在使用之前启动服务器):
{
"mcpServers": {
"mlcartifact": {
"sse": { "url": "http://localhost:8082/sse" }
}
}
}______________________________________________________________________
MCP工具
| 工具 | 说明 |
|---|---|
write_artifact | 保存文件-返回ID |
read_artifact | 按ID或文件名检索文件 |
list_artifacts | 列出存储的工件 |
delete_artifact | 永久删除 |
______________________________________________________________________
CLI使用情况
artifact-cli create ./report.csv --name "Q1 Report" --expires 72
artifact-cli download abc123 ./local-copy.csv
artifact-cli list
artifact-cli delete abc123通过连接 ARTIFACT_GRPC_ADDR env为(默认值: localhost:9590)或 -addr 旗帜。
______________________________________________________________________
服务器配置
| 标志 | 默认值 | 描述 |
|---|---|---|
-addr | _(空)_ | SSE监听地址(例如。 127.0.0.1:8080 对于本地, :8080 为所有人)。空=标准输入模式。 |
-grpc-addr | :9590 | gRPC侦听地址(例如。 127.0.0.1:9590 对于本地, :9590 为所有人)。 |
-data-dir | ~/mlcartifact/storage | 存储目录 |
-mcp-list-limit | 100 | 最多项目数 list_artifacts |
环境变量(库):
| 变量 | 描述 |
|---|---|
ARTIFACT_GRPC_ADDR | gRPC服务器地址(默认值: :9590) |
ARTIFACT_SOURCE | 默认源标记 |
ARTIFACT_USER_ID | 默认用户ID |
______________________________________________________________________
存储布局
~/mlcartifact/storage/
├── global/
│ ├── {id}_{filename}
│ └── {id}_{filename}.json # metadata sidecar
└── users/
└── {user_id}/
├── {id}_{filename}
└── {id}_{filename}.json______________________________________________________________________
发展
task test # run all tests
task build # build all binaries
task build-server # server only______________________________________________________________________
运行示例
该存储库包含所有支持语言的“Hello World”示例。这些示例演示了完整的生命周期:编写3个工件,删除一个,检索/验证其他工件。
要一次运行所有示例(需要一个正在运行的服务器):
# 1. Start the server in one terminal
artifact-server -addr :8082 -grpc-addr :9590
# 2. Run examples in another terminal
make run-examples或者运行特定示例:
make run-example-gomake run-example-pythonmake run-example-tsmake run-example-rust
______________________________________________________________________
路线图
- \[x\] Types/Node.js SDK
- \[x\] 开发包 (httpx+connectrpc)
- \[x\] Docker镜像 -预配置服务器
- \[x\] Rust SDK (基于补品)
- \[ \] Web仪表板 -直观地浏览和管理工件
______________________________________________________________________
许可证
麻省理工学院许可证-版权所有(c)2026 莱西纳
