feat(files): introduce upload_file tool for staging files and enhance save_file documentation
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user