# Client सुविधाएँ: Sampling, Roots, Elicitation, Pagination — MCP और Agent-to-Agent Protocols

Source: https://www.geekswithgeeks.com/hi/mcp-a2a/m-client-features

> जानें server client से क्या माँग सकता है, और लंबी सूचियाँ कैसे पृष्ठित होती हैं।

## Servers वापस माँग सकते हैं

MCP सिर्फ़ client-से-server नहीं है। Client ऐसी सुविधाएँ दे सकता है जो server माँग सके, यदि client ने उन्हें घोषित किया हो: **sampling** (server host से अपनी ओर से LLM completion चलवाता है, इसलिए server को model keys नहीं चाहिए और user नियंत्रण में रहकर अनुमोदन दे सकता है), **roots** (host server को बताता है कि वह किन folders या URIs में काम कर सकता है) और **elicitation** (server host के ज़रिए user से छूटी जानकारी माँगता है)। `tools/list` जैसी लंबी सूचियाँ **cursor-आधारित pagination** उपयोग करती हैं: response में `nextCursor` होता है जिसे तब तक वापस भेजते हैं जब तक कोई शेष न रहे। चूँकि ये प्रवाह server को प्रभावित करने देते हैं कि मॉडल क्या देखे और करे, hosts को इन्हें **अनुरोध** मानना चाहिए, उचित जगह user को दिखाना चाहिए और सीमाएँ लागू करनी चाहिए।

## Cursor pagination, चलाकर

मैंने यह सादे Python 3 (सिर्फ़ standard library) से चलाया। पृष्ठ आकार 2 के साथ पाँच items तीन पृष्ठों में आते हैं। Client लौटा cursor तब तक भेजता रहता है जब तक `nextCursor` `None` न हो।

```python
def paginate(items, cursor=None, page_size=2):
    start = int(cursor) if cursor else 0
    chunk = items[start:start + page_size]
    nxt = str(start + page_size) if start + page_size < len(items) else None
    return {"items": chunk, "nextCursor": nxt}

tools = ["a", "b", "c", "d", "e"]
cursor, pages = None, []
while True:
    page = paginate(tools, cursor)
    pages.append(page["items"])
    cursor = page["nextCursor"]
    if cursor is None:
        break
print(pages)

```

Output:

```
[['a', 'b'], ['c', 'd'], ['e']]
```

**Quiz:** Sampling server को क्या करने देता है?

- [ ] Authentication छोड़ना
- [ ] डिस्क पर कोई भी file पढ़ना
- [x] Host से LLM completion चलवाना, user के नियंत्रण में
- [ ] Protocol संस्करण बदलना

*Answer:* Host से LLM completion चलवाना, user के नियंत्रण में. Server client का मॉडल उधार लेता है; host समीक्षा और अनुमोदन कर सकता है।
