internal/mcp: add pagination for prompts
Change-Id: Ib231427299dbfe807fb80ad8da6ba16d4a8fde03 Reviewed-on: https://go-review.googlesource.com/c/tools/+/676615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
parent
4e9d520c2e
commit
d0bc3bc890
1 changed files with 31 additions and 2 deletions
|
|
@ -179,8 +179,17 @@ func (s *Server) Sessions() iter.Seq[*ServerSession] {
|
|||
func (s *Server) listPrompts(_ context.Context, _ *ServerSession, params *ListPromptsParams) (*ListPromptsResult, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
var cursor string
|
||||
if params != nil {
|
||||
cursor = params.Cursor
|
||||
}
|
||||
prompts, nextCursor, err := paginateList(s.prompts, cursor, s.opts.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := new(ListPromptsResult)
|
||||
for p := range s.prompts.all() {
|
||||
res.NextCursor = nextCursor
|
||||
for _, p := range prompts {
|
||||
res.Prompts = append(res.Prompts, p.Prompt)
|
||||
}
|
||||
return res, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue