feat(files): update save_file tool description and enforce size limit for base64 payloads
This commit is contained in:
@@ -16,6 +16,11 @@ import (
|
||||
thoughttypes "git.warky.dev/wdevs/amcs/internal/types"
|
||||
)
|
||||
|
||||
// maxBase64ToolBytes is the maximum base64 payload accepted by save_file via
|
||||
// the MCP tool interface. For larger files use POST /files (binary) and pass
|
||||
// the returned amcs://files/{id} URI as content_uri instead.
|
||||
const maxBase64ToolBytes = 10 << 20 // 10 MB of base64 ≈ 7.5 MB decoded
|
||||
|
||||
type FilesTool struct {
|
||||
store *store.DB
|
||||
sessions *session.ActiveProjects
|
||||
@@ -75,6 +80,11 @@ func (t *FilesTool) Save(ctx context.Context, req *mcp.CallToolRequest, in SaveF
|
||||
if uri != "" && b64 != "" {
|
||||
return nil, SaveFileOutput{}, errInvalidInput("provide content_uri or content_base64, not both")
|
||||
}
|
||||
if len(b64) > maxBase64ToolBytes {
|
||||
return nil, SaveFileOutput{}, errInvalidInput(
|
||||
"content_base64 exceeds the 10 MB MCP tool limit; upload the file via POST /files and pass the returned amcs://files/{id} URI as content_uri instead",
|
||||
)
|
||||
}
|
||||
|
||||
var content []byte
|
||||
var mediaTypeFromSource string
|
||||
|
||||
Reference in New Issue
Block a user