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

Function encodeCursor

mcp/server.go:1545–1553  ·  view source on GitHub ↗

encodeCursor encodes a unique identifier (UID) into a opaque pagination cursor by serializing a pageToken struct.

(uid string)

Source from the content-addressed store, hash-verified

1543// encodeCursor encodes a unique identifier (UID) into a opaque pagination cursor
1544// by serializing a pageToken struct.
1545func encodeCursor(uid string) (string, error) {
1546 var buf bytes.Buffer
1547 token := pageToken{LastUID: uid}
1548 encoder := gob.NewEncoder(&buf)
1549 if err := encoder.Encode(token); err != nil {
1550 return "", fmt.Errorf("failed to encode page token: %w", err)
1551 }
1552 return base64.URLEncoding.EncodeToString(buf.Bytes()), nil
1553}
1554
1555// decodeCursor decodes an opaque pagination cursor into the original pageToken struct.
1556func decodeCursor(cursor string) (*pageToken, error) {

Callers 2

paginateListFunction · 0.85
getCursorFunction · 0.85

Calls 1

BytesMethod · 0.80

Tested by 1

getCursorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…