mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-12-02 16:01:26 +01:00
147 lines
5 KiB
Text
147 lines
5 KiB
Text
---
|
|
title: skills
|
|
sidebarTitle: skills
|
|
---
|
|
|
|
# `fastmcp.client.mixins.skills`
|
|
|
|
|
|
Skills-extension methods for the FastMCP client.
|
|
|
|
## Classes
|
|
|
|
### `ClientSkillsMixin` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L47" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
|
|
Mixin providing SEP-2640 Skills methods for `Client`.
|
|
|
|
|
|
**Methods:**
|
|
|
|
#### `list_skills_mcp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L78" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
list_skills_mcp(self: Client) -> ListSkillsResult
|
|
```
|
|
|
|
Send one `skills/list` request and return its protocol result.
|
|
|
|
**Args:**
|
|
- `cursor`: Optional pagination cursor from a previous result.
|
|
- `cache_mode`: Response-cache behavior for this call.
|
|
|
|
**Returns:**
|
|
- The complete protocol result, including cache and pagination fields.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If the client is disconnected or Skills was not negotiated.
|
|
- `MCPError`: If the server rejects the request.
|
|
|
|
|
|
#### `list_skills` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
list_skills(self: Client, max_pages: int = AUTO_PAGINATION_MAX_PAGES) -> list[MCPSkill]
|
|
```
|
|
|
|
Retrieve every page returned by `skills/list`.
|
|
|
|
**Args:**
|
|
- `max_pages`: Maximum number of pages to fetch before raising.
|
|
- `cache_mode`: Response-cache behavior for the first page.
|
|
|
|
**Returns:**
|
|
- Every skill entry returned across the server's pages.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If Skills was not negotiated or the page limit is reached.
|
|
- `MCPError`: If the server rejects a request.
|
|
|
|
|
|
#### `get_skill_mcp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L167" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_skill_mcp(self: Client, uri: str) -> GetSkillResult
|
|
```
|
|
|
|
Send a `skills/get` request and return its protocol result.
|
|
|
|
**Args:**
|
|
- `uri`: URI of the skill's `SKILL.md` resource.
|
|
- `cache_mode`: Response-cache behavior for this call.
|
|
|
|
**Returns:**
|
|
- The complete protocol result, including cache fields.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If the client is disconnected or Skills was not negotiated.
|
|
- `MCPError`: If the server rejects the request.
|
|
|
|
|
|
#### `list_skill_resources` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L211" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
list_skill_resources(self: Client) -> list[mcp_types.Resource]
|
|
```
|
|
|
|
List the skills a server publishes as `skill://.../SKILL.md` resources.
|
|
|
|
Use this for servers that serve skills as resources but not through the
|
|
Skills extension, such as FastMCP 4.1 and earlier. Pass a returned
|
|
resource's `uri` to `read_skill()` to fetch the whole skill.
|
|
|
|
When skill paths overlap, advertised manifests distinguish supporting
|
|
`SKILL.md` files from independent skills. Entries are kept if their
|
|
containing skill's manifest is unavailable or invalid.
|
|
|
|
**Returns:**
|
|
- The `SKILL.md` resource of each skill, in the server's order.
|
|
|
|
|
|
#### `get_skill` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L269" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_skill(self: Client, uri: str) -> MCPSkill
|
|
```
|
|
|
|
Retrieve one skill entry by its `SKILL.md` resource URI.
|
|
|
|
**Args:**
|
|
- `uri`: URI of the skill's `SKILL.md` resource.
|
|
- `cache_mode`: Response-cache behavior for this call.
|
|
|
|
**Returns:**
|
|
- The skill entry returned by the server.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If the client is disconnected or Skills was not negotiated.
|
|
- `MCPError`: If the server rejects the request.
|
|
|
|
|
|
#### `read_skill` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/client/mixins/skills.py#L291" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
read_skill(self: Client, uri: str) -> Skill
|
|
```
|
|
|
|
Fetch every file of a skill, verify each one, and return a `Skill`.
|
|
|
|
The manifest comes from `skills/get` when the Skills extension was
|
|
negotiated, and otherwise from the `_manifest` resource that FastMCP
|
|
skill providers serve next to the files. Every file must match the
|
|
size and SHA-256 digest the manifest promised. When an extension entry
|
|
is available, the parsed frontmatter must also match that entry.
|
|
|
|
**Args:**
|
|
- `uri`: URI of the skill's `SKILL.md` resource.
|
|
- `cache_mode`: Response-cache behavior for the `skills/get` request.
|
|
|
|
**Returns:**
|
|
- The skill, with the exact bytes of every file.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If the client is disconnected.
|
|
- `ValueError`: If the manifest is unusable, a file does not match it,
|
|
or the files do not form a valid skill.
|
|
- `MCPError`: If the server rejects a request.
|
|
|