MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / Prompts

Method Prompts

mcp/client.go:1153–1160  ·  view source on GitHub ↗

Prompts provides an iterator for all prompts available on the server, automatically fetching pages and managing cursors. The params argument can set the initial cursor. Iteration stops at the first encountered error, which will be yielded.

(ctx context.Context, params *ListPromptsParams)

Source from the content-addressed store, hash-verified

1151// The params argument can set the initial cursor.
1152// Iteration stops at the first encountered error, which will be yielded.
1153func (cs *ClientSession) Prompts(ctx context.Context, params *ListPromptsParams) iter.Seq2[*Prompt, error] {
1154 if params == nil {
1155 params = &ListPromptsParams{}
1156 }
1157 return paginate(ctx, params, cs.ListPrompts, func(res *ListPromptsResult) []*Prompt {
1158 return res.Prompts
1159 })
1160}
1161
1162// paginate is a generic helper function to provide a paginated iterator.
1163func paginate[P listParams, R listResult[T], T any](ctx context.Context, params P, listFunc func(context.Context, P) (R, error), items func(R) []*T) iter.Seq2[*T, error] {

Callers 3

TestListFunction · 0.80
Example_promptsFunction · 0.80
mainFunction · 0.80

Calls 1

paginateFunction · 0.85

Tested by 2

TestListFunction · 0.64
Example_promptsFunction · 0.64