mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-19 20:14:17 +02:00
chore: Update SDK documentation (#2945)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
This commit is contained in:
parent
16ffc9432f
commit
7d40b1dd4c
8 changed files with 383 additions and 0 deletions
32
docs/python-sdk/fastmcp-server-providers-skills-__init__.mdx
Normal file
32
docs/python-sdk/fastmcp-server-providers-skills-__init__.mdx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers.skills`
|
||||
|
||||
|
||||
Skills providers for exposing agent skills as MCP resources.
|
||||
|
||||
This module provides a two-layer architecture for skill discovery:
|
||||
|
||||
- **SkillProvider**: Handles a single skill folder, exposing its files as resources.
|
||||
- **SkillsDirectoryProvider**: Scans a directory, creates a SkillProvider per folder.
|
||||
- **Vendor providers**: Platform-specific providers for Claude, Cursor, VS Code, Codex,
|
||||
Gemini, Goose, Copilot, and OpenCode.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from pathlib import Path
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.providers.skills import ClaudeSkillsProvider, SkillProvider
|
||||
|
||||
mcp = FastMCP("Skills Server")
|
||||
|
||||
# Load a single skill
|
||||
mcp.add_provider(SkillProvider(Path.home() / ".claude/skills/pdf-processing"))
|
||||
|
||||
# Or load all skills in a directory
|
||||
mcp.add_provider(ClaudeSkillsProvider()) # Uses ~/.claude/skills/
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: claude_provider
|
||||
sidebarTitle: claude_provider
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers.skills.claude_provider`
|
||||
|
||||
|
||||
Claude-specific skills provider for Claude Code skills.
|
||||
|
||||
## Classes
|
||||
|
||||
### `ClaudeSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/claude_provider.py#L11" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Provider for Claude Code skills from ~/.claude/skills/.
|
||||
|
||||
A convenience subclass that sets the default root to Claude's skills location.
|
||||
|
||||
**Args:**
|
||||
- `reload`: If True, re-scan on every request. Defaults to False.
|
||||
- `supporting_files`: How supporting files are exposed\:
|
||||
- "template"\: Accessed via ResourceTemplate, hidden from list_resources().
|
||||
- "resources"\: Each file exposed as individual Resource in list_resources().
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: directory_provider
|
||||
sidebarTitle: directory_provider
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers.skills.directory_provider`
|
||||
|
||||
|
||||
Directory scanning provider for discovering multiple skills.
|
||||
|
||||
## Classes
|
||||
|
||||
### `SkillsDirectoryProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/directory_provider.py#L19" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Provider that scans directories and creates a SkillProvider per skill folder.
|
||||
|
||||
This extends AggregateProvider to combine multiple SkillProviders into one.
|
||||
Each subdirectory containing a main file (default: SKILL.md) becomes a skill.
|
||||
Can scan multiple root directories - if a skill name appears in multiple roots,
|
||||
the first one found wins.
|
||||
|
||||
**Args:**
|
||||
- `roots`: Root directory(ies) containing skill folders. Can be a single path
|
||||
or a sequence of paths.
|
||||
- `reload`: If True, re-discover skills on each request. Defaults to False.
|
||||
- `main_file_name`: Name of the main skill file. Defaults to "SKILL.md".
|
||||
- `supporting_files`: How supporting files are exposed in child SkillProviders\:
|
||||
- "template"\: Accessed via ResourceTemplate, hidden from list_resources().
|
||||
- "resources"\: Each file exposed as individual Resource in list_resources().
|
||||
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
---
|
||||
title: skill_provider
|
||||
sidebarTitle: skill_provider
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers.skills.skill_provider`
|
||||
|
||||
|
||||
Basic skill provider for handling a single skill folder.
|
||||
|
||||
## Classes
|
||||
|
||||
### `SkillResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
A resource representing a skill's main file or manifest.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
read(self) -> str | bytes | ResourceResult
|
||||
```
|
||||
|
||||
Read the resource content.
|
||||
|
||||
|
||||
### `SkillFileTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L61" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
A template for accessing files within a skill.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L66" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
read(self, arguments: dict[str, Any]) -> str | bytes | ResourceResult
|
||||
```
|
||||
|
||||
Read a file from the skill directory.
|
||||
|
||||
|
||||
#### `create_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
create_resource(self, uri: str, params: dict[str, Any]) -> Resource
|
||||
```
|
||||
|
||||
Create a resource for the given URI and parameters.
|
||||
|
||||
Note: This is not typically used since _read() handles file reading directly.
|
||||
Provided for compatibility with the ResourceTemplate interface.
|
||||
|
||||
|
||||
### `SkillFileResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
A resource representing a specific file within a skill.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L138" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
read(self) -> str | bytes | ResourceResult
|
||||
```
|
||||
|
||||
Read the file content.
|
||||
|
||||
|
||||
### `SkillProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L162" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Provider that exposes a single skill folder as MCP resources.
|
||||
|
||||
Each skill folder must contain a main file (default: SKILL.md) and may
|
||||
contain additional supporting files.
|
||||
|
||||
Exposes:
|
||||
- A Resource for the main file (skill://{name}/SKILL.md)
|
||||
- A Resource for the synthetic manifest (skill://{name}/_manifest)
|
||||
- Supporting files via ResourceTemplate or Resources (configurable)
|
||||
|
||||
**Args:**
|
||||
- `skill_path`: Path to the skill directory.
|
||||
- `main_file_name`: Name of the main skill file. Defaults to "SKILL.md".
|
||||
- `supporting_files`: How supporting files (everything except main file and
|
||||
manifest) are exposed to clients\:
|
||||
- "template"\: Accessed via ResourceTemplate, hidden from list_resources().
|
||||
Clients discover files by reading the manifest first.
|
||||
- "resources"\: Each file exposed as individual Resource in list_resources().
|
||||
Full enumeration upfront.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `skill_info` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/skill_provider.py#L254" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
skill_info(self) -> SkillInfo
|
||||
```
|
||||
|
||||
Get the loaded skill info.
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
title: vendor_providers
|
||||
sidebarTitle: vendor_providers
|
||||
---
|
||||
|
||||
# `fastmcp.server.providers.skills.vendor_providers`
|
||||
|
||||
|
||||
Vendor-specific skills providers for various AI coding platforms.
|
||||
|
||||
## Classes
|
||||
|
||||
### `CursorSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L11" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Cursor skills from ~/.cursor/skills/.
|
||||
|
||||
|
||||
### `VSCodeSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L29" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
VS Code skills from ~/.copilot/skills/.
|
||||
|
||||
|
||||
### `CodexSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L47" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Codex skills from /etc/codex/skills/ and ~/.codex/skills/.
|
||||
|
||||
Scans both system-level and user-level directories. System skills take
|
||||
precedence if duplicates exist.
|
||||
|
||||
|
||||
### `GeminiSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L73" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Gemini skills from ~/.gemini/skills/.
|
||||
|
||||
|
||||
### `GooseSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Goose skills from ~/.config/agents/skills/.
|
||||
|
||||
|
||||
### `CopilotSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L109" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
GitHub Copilot skills from ~/.copilot/skills/.
|
||||
|
||||
|
||||
### `OpenCodeSkillsProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/skills/vendor_providers.py#L127" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
OpenCode skills from ~/.config/opencode/skills/.
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: prompts_as_tools
|
||||
sidebarTitle: prompts_as_tools
|
||||
---
|
||||
|
||||
# `fastmcp.server.transforms.prompts_as_tools`
|
||||
|
||||
|
||||
Transform that exposes prompts as tools.
|
||||
|
||||
This transform generates tools for listing and getting prompts, enabling
|
||||
clients that only support tools to access prompt functionality.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.transforms import PromptsAsTools
|
||||
|
||||
mcp = FastMCP("Server")
|
||||
mcp.add_transform(PromptsAsTools(mcp))
|
||||
# Now has list_prompts and get_prompt tools
|
||||
```
|
||||
|
||||
|
||||
## Classes
|
||||
|
||||
### `PromptsAsTools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/prompts_as_tools.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Transform that adds tools for listing and getting prompts.
|
||||
|
||||
Generates two tools:
|
||||
- `list_prompts`: Lists all prompts from the provider
|
||||
- `get_prompt`: Gets a specific prompt with optional arguments
|
||||
|
||||
The transform captures a provider reference at construction and queries it
|
||||
for prompts when the generated tools are called. When used with FastMCP,
|
||||
the provider's auth and visibility filtering is automatically applied.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/prompts_as_tools.py#L66" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_tools(self, tools: Sequence[Tool]) -> Sequence[Tool]
|
||||
```
|
||||
|
||||
Add prompt tools to the tool list.
|
||||
|
||||
|
||||
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/prompts_as_tools.py#L74" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_tool(self, name: str, call_next: GetToolNext) -> Tool | None
|
||||
```
|
||||
|
||||
Get a tool by name, including generated prompt tools.
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: resources_as_tools
|
||||
sidebarTitle: resources_as_tools
|
||||
---
|
||||
|
||||
# `fastmcp.server.transforms.resources_as_tools`
|
||||
|
||||
|
||||
Transform that exposes resources as tools.
|
||||
|
||||
This transform generates tools for listing and reading resources, enabling
|
||||
clients that only support tools to access resource functionality.
|
||||
|
||||
Example:
|
||||
```python
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.transforms import ResourcesAsTools
|
||||
|
||||
mcp = FastMCP("Server")
|
||||
mcp.add_transform(ResourcesAsTools(mcp))
|
||||
# Now has list_resources and read_resource tools
|
||||
```
|
||||
|
||||
|
||||
## Classes
|
||||
|
||||
### `ResourcesAsTools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Transform that adds tools for listing and reading resources.
|
||||
|
||||
Generates two tools:
|
||||
- `list_resources`: Lists all resources and templates from the provider
|
||||
- `read_resource`: Reads a resource by URI
|
||||
|
||||
The transform captures a provider reference at construction and queries it
|
||||
for resources when the generated tools are called. When used with FastMCP,
|
||||
the provider's auth and visibility filtering is automatically applied.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L63" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
list_tools(self, tools: Sequence[Tool]) -> Sequence[Tool]
|
||||
```
|
||||
|
||||
Add resource tools to the tool list.
|
||||
|
||||
|
||||
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/resources_as_tools.py#L71" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_tool(self, name: str, call_next: GetToolNext) -> Tool | None
|
||||
```
|
||||
|
||||
Get a tool by name, including generated resource tools.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue