feat(files): introduce upload_file tool for staging files and enhance save_file documentation

This commit is contained in:
2026-03-31 00:30:56 +02:00
parent 3819eb4fee
commit acd780ac9c
7 changed files with 157 additions and 28 deletions

View File

@@ -47,7 +47,7 @@ func logToolCall[In any, Out any](logger *slog.Logger, toolName string, handler
result, out, err := handler(ctx, req, in)
completionAttrs := append([]any{}, attrs...)
completionAttrs = append(completionAttrs, slog.Duration("duration", time.Since(start)))
completionAttrs = append(completionAttrs, slog.String("duration", formatLogDuration(time.Since(start))))
if err != nil {
completionAttrs = append(completionAttrs, slog.String("error", err.Error()))
logger.Error("mcp tool completed", completionAttrs...)
@@ -70,6 +70,18 @@ func truncateArgs(args any) string {
return string(b[:maxLoggedArgBytes]) + fmt.Sprintf("… (%d bytes total)", len(b))
}
func formatLogDuration(d time.Duration) string {
if d < 0 {
d = -d
}
totalMilliseconds := d.Milliseconds()
minutes := totalMilliseconds / 60000
seconds := (totalMilliseconds / 1000) % 60
milliseconds := totalMilliseconds % 1000
return fmt.Sprintf("%02d:%02d:%03d", minutes, seconds, milliseconds)
}
func setToolSchemas[In any, Out any](tool *mcp.Tool) error {
if tool.InputSchema == nil {
inputSchema, err := jsonschema.For[In](toolSchemaOptions)