fix: make query parameter of tool search_inbox optional

This commit is contained in:
Acbox
2026-03-04 22:26:24 +08:00
parent 54f42074ef
commit 674e8c6ce9
4 changed files with 4 additions and 7 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ WHERE bot_id = sqlc.arg(bot_id)
-- name: SearchInboxItems :many
SELECT * FROM bot_inbox
WHERE bot_id = sqlc.arg(bot_id)
AND content ILIKE '%' || sqlc.arg(query) || '%'
AND (sqlc.narg(query)::text IS NULL OR content ILIKE '%' || sqlc.narg(query)::text || '%')
AND (sqlc.narg(start_time)::timestamptz IS NULL OR created_at >= sqlc.narg(start_time)::timestamptz)
AND (sqlc.narg(end_time)::timestamptz IS NULL OR created_at <= sqlc.narg(end_time)::timestamptz)
AND (sqlc.narg(include_read)::boolean IS NULL OR sqlc.narg(include_read)::boolean = TRUE OR is_read = FALSE)
+1 -1
View File
@@ -246,7 +246,7 @@ func (q *Queries) MarkInboxItemsRead(ctx context.Context, arg MarkInboxItemsRead
const searchInboxItems = `-- name: SearchInboxItems :many
SELECT id, bot_id, source, header, content, action, is_read, created_at, read_at FROM bot_inbox
WHERE bot_id = $1
AND content ILIKE '%' || $2 || '%'
AND ($2::text IS NULL OR content ILIKE '%' || $2::text || '%')
AND ($3::timestamptz IS NULL OR created_at >= $3::timestamptz)
AND ($4::timestamptz IS NULL OR created_at <= $4::timestamptz)
AND ($5::boolean IS NULL OR $5::boolean = TRUE OR is_read = FALSE)
+1 -1
View File
@@ -198,7 +198,7 @@ func (s *Service) Search(ctx context.Context, botID string, req SearchRequest) (
}
params := sqlc.SearchInboxItemsParams{
BotID: botUUID,
Query: pgtype.Text{String: req.Query, Valid: true},
Query: textOrNull(req.Query),
MaxCount: int32(limit),
}
if req.StartTime != nil {
+1 -4
View File
@@ -65,7 +65,7 @@ func (e *Executor) ListTools(ctx context.Context, session mcpgw.ToolSessionConte
"description": "Whether to include already-read items (default true)",
},
},
"required": []string{"query"},
"required": []string{},
},
},
}, nil
@@ -80,9 +80,6 @@ func (e *Executor) CallTool(ctx context.Context, session mcpgw.ToolSessionContex
}
query := mcpgw.StringArg(arguments, "query")
if query == "" {
return mcpgw.BuildToolErrorResult("query is required"), nil
}
botID := strings.TrimSpace(session.BotID)
if botID == "" {
return mcpgw.BuildToolErrorResult("bot_id is required"), nil