99 for skill in await skills.bind(client).list_skills():
1010 print(skill.uri, skill.frontmatter["description"])
1111
12- `bind(client)` returns a `BoundSkills`. Each verb validates that the server
13- advertises the extension before sending; `list_skills` and `read_directory`
14- follow `nextCursor` to completion, so one call returns every page's results.
12+ `bind(client)` returns a `BoundSkills`. Its catalog verbs — `list_skills`,
13+ `get_skill`, and `read_directory` — check that the server advertises the
14+ extension and validate its response; `list_skills` and `read_directory` follow
15+ `nextCursor` to completion, so one call returns every page's results.
16+ `read_skill_uri` is a thin `resources/read` alias that does neither — verify its
17+ result with `verify_skill_resource`.
1518"""
1619
1720from __future__ import annotations
@@ -68,9 +71,13 @@ def bind(self, client: Client) -> BoundSkills:
6871class BoundSkills :
6972 """The SEP-2640 verbs bound to one connected session.
7073
71- Obtain it from `Skills.bind(client)`. `list_skills` and `read_directory`
72- follow `nextCursor` to completion; every method validates the server's
73- response against the SEP-2640 conformance rules before returning it.
74+ Obtain it from `Skills.bind(client)`. The catalog verbs — `list_skills`,
75+ `get_skill`, and `read_directory` — check that the server advertises the
76+ extension and validate its response against the SEP-2640 conformance rules
77+ before returning; `list_skills` and `read_directory` also follow
78+ `nextCursor` to completion. `read_skill_uri` is the exception: a thin
79+ `resources/read` alias that neither checks advertisement nor validates —
80+ pair it with `verify_skill_resource`.
7481 """
7582
7683 def __init__ (self , session : ClientSession ) -> None :
@@ -88,8 +95,9 @@ async def list_skills(self, params: ListSkillsParams | None = None) -> list[Skil
8895 """Call `skills/list`, following `nextCursor` to completion, and validate the result.
8996
9097 Raises:
91- ValueError: If the server doesn't advertise the Skills extension, or
92- its response is not SEP-2640 conformant.
98+ ValueError: If the server doesn't advertise the Skills extension, its
99+ response is not SEP-2640 conformant, or it repeats a pagination cursor.
100+ MCPError: If the server returns an error response.
93101 """
94102 self ._require_extension ()
95103 base = params if params is not None else ListSkillsParams ()
@@ -118,6 +126,8 @@ async def get_skill(self, uri: str) -> Skill:
118126 Raises:
119127 ValueError: If the server doesn't advertise the Skills extension, its
120128 response names a different skill, or the skill is not conformant.
129+ MCPError: If the server returns an error response, such as `-32602`
130+ for a URI it does not serve.
121131 """
122132 self ._require_extension ()
123133 result = await self ._session .send_request (GetSkillRequest (params = GetSkillParams (uri = uri )), GetSkillResult )
@@ -133,6 +143,11 @@ async def read_skill_uri(self, uri: str) -> ReadResourceResult:
133143 file regardless of whether the skill was ever enumerated. Verify the
134144 result against a held `Skill` entry with `verify_skill_resource` before
135145 treating it as trusted content — this call does not verify anything itself.
146+
147+ Raises:
148+ MCPError: If the server returns an error response.
149+ RuntimeError: If the server returns an `InputRequiredResult`; this
150+ alias does not drive the input-required loop.
136151 """
137152 return await self ._session .read_resource (uri )
138153
@@ -141,7 +156,9 @@ async def read_directory(self, uri: str, params: ReadDirectoryParams | None = No
141156
142157 Raises:
143158 ValueError: If the server doesn't advertise the `directoryRead`
144- setting, or its response is not a valid child listing of `uri`.
159+ setting, its response is not a valid child listing of `uri`, or
160+ it repeats a pagination cursor.
161+ MCPError: If the server returns an error response.
145162 """
146163 self ._require_extension (directory_read = True )
147164 base = params if params is not None else ReadDirectoryParams (uri = uri )
0 commit comments