Skip to content

Commit ede391f

Browse files
committed
internal/mcp: resource template iterator
Add Client.ResourceTemplates Test forthcoming. Change-Id: I35e8ee8fabdf8fa216456ab3fcd0c8a7de9287c8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/680255 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
1 parent 8a9bccd commit ede391f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/mcp/client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,19 @@ func (cs *ClientSession) Resources(ctx context.Context, params *ListResourcesPar
383383
})
384384
}
385385

386+
// ResourceTemplates provides an iterator for all resource templates available on the server,
387+
// automatically fetching pages and managing cursors.
388+
// The `params` argument can set the initial cursor.
389+
// Iteration stops at the first encountered error, which will be yielded.
390+
func (cs *ClientSession) ResourceTemplates(ctx context.Context, params *ListResourceTemplatesParams) iter.Seq2[ResourceTemplate, error] {
391+
if params == nil {
392+
params = &ListResourceTemplatesParams{}
393+
}
394+
return paginate(ctx, params, cs.ListResourceTemplates, func(res *ListResourceTemplatesResult) []*ResourceTemplate {
395+
return res.ResourceTemplates
396+
})
397+
}
398+
386399
// Prompts provides an iterator for all prompts available on the server,
387400
// automatically fetching pages and managing cursors.
388401
// The `params` argument can set the initial cursor.

0 commit comments

Comments
 (0)