π The fast, Pythonic way to build MCP servers and clients.
Discover skills through mounted servers (#6067)
nate nowackc891330e5108
diff --git a/docs/servers/skills.mdx b/docs/servers/skills.mdxindex 9987646d5..40f62197b 100644--- a/docs/servers/skills.mdx+++ b/docs/servers/skills.mdx@@ -49,21 +49,18 @@ Refer to supporting files by their path relative to the skill folder, as `refere## Serve the folder-`SkillsDirectoryProvider` publishes every skill folder under a root directory. Setting `experimental_skills=True` on it, and registering `SkillsExtension` with the same provider instance, also turns on Skills discovery.+`SkillsDirectoryProvider` publishes every skill folder under a root directory. Setting `experimental_skills=True` on it also turns on Skills discovery: the provider registers `SkillsExtension` on the server for you.```pythonfrom pathlib import Pathfrom fastmcp import FastMCPfrom fastmcp.server.providers.skills import SkillsDirectoryProvider-from fastmcp.skills.extension import SkillsExtension-SKILLS_DIR = Path(__file__).parent / "skills"mcp = FastMCP("Team Skills")skills = SkillsDirectoryProvider(SKILLS_DIR, experimental_skills=True)mcp.add_provider(skills)-mcp.add_extension(SkillsExtension(providers=[skills]))if __name__ == "__main__":mcp.run(transport="http", port=8000)@@ -71,7 +68,7 @@ if __name__ == "__main__":Save this as `server.py` next to the `skills/` folder and run `python server.py`. The server can carry tools, resources, and prompts as usual; skills are one more provider.-To serve skills as resources only, leave out `experimental_skills=True` and the `SkillsExtension` line. To turn discovery off again later, remove both.+To serve skills as resources only, leave out `experimental_skills=True`.## Read skills as resources@@ -229,7 +226,6 @@ A skill doesn't have to live in a folder. `Skill` holds a skill's files in memorfrom fastmcp import FastMCPfrom fastmcp.skills.provider import SkillCatalogProviderfrom fastmcp.skills import Skill-from fastmcp.skills.extension import SkillsExtensionrelease_notes = Skill(name="release-notes",@@ -243,7 +239,6 @@ review = Skill.from_package("my_package", "skills/review")mcp = FastMCP("Skills")skills = SkillCatalogProvider([release_notes, deploy, review])mcp.add_provider(skills)-mcp.add_extension(SkillsExtension(providers=[skills]))```The constructor writes `SKILL.md` from `name`, `description`, `instructions`, and any extra `frontmatter`. `Skill.from_directory()` and `Skill.from_package()` read a folder once and keep its exact bytes, so later edits to the folder don't change the served skill. Every `Skill` is validated when you create it: frontmatter follows the same strict rules as discovery mode, and a folder's name must match the `name` in its `SKILL.md`.@@ -373,12 +368,21 @@ Without the flag, the provider keeps its permissive resource-mode behavior: fronSkills discovery respects the same rules as resource reads. A skill is omitted from `skills/list` when any of its files is hidden from the caller or denied by `Middleware.check_resource_access`, the hook that [`AuthMiddleware`](/servers/authorization) and the default `on_read_resource` use. Implement custom resource authorization in that hook so discovery can apply it; restrictions applied in other middleware hooks are invisible to discovery.+## Mounted servers++<VersionBadge version="4.2.0" />++Skills follow a [mounted server](/servers/composition) to its parent. The parent's `skills/list` includes the child's skills at the URIs the parent serves them at, so `mount(child, namespace="team")` turns `skill://review/SKILL.md` into `skill://team/review/SKILL.md`, and every file in the manifest moves with it. This works through any depth of mounts.++The parent lists a mounted skill only when it routes every file back to the child and the caller passes the parent's own access checks. A parent resource that shadows one of the files, or a parent middleware rule that denies one, hides the skill. Two mounts that publish the same skill URI hide each other's copy.++To limit discovery to specific providers instead, register the extension yourself with `mcp.add_extension(SkillsExtension(providers=[...]))`. An explicit registration replaces the automatic one and doesn't include mounted servers.+## Current limits-Skills discovery currently serves skills from `SkillsDirectoryProvider` and `SkillCatalogProvider` instances registered directly on the server you run.+Skills discovery serves skills from `SkillsDirectoryProvider` and `SkillCatalogProvider` instances registered on the server you run or on servers mounted into it.-- `SkillsExtension` raises when the server or the skills provider has transforms, including namespaces, or when the provider is not registered directly on the same server.-- Skills in a [mounted server](/servers/composition) are served as resources through the parent, but the parent does not list them in `skills/list`.+- A skill provider added with a namespace or other transforms is left out of `skills/list`. To namespace skills, mount a server that holds the provider. A server with server-level transforms lists no skills.- A proxy in front of the server forwards the skill files as resources, but not `skills/list` or `skills/get`.- The optional `directoryRead` capability is not implemented.diff --git a/fastmcp_slim/fastmcp/server/providers/skills/directory_provider.py b/fastmcp_slim/fastmcp/server/providers/skills/directory_provider.pyindex bc648dead..a8d29d9ec 100644--- a/fastmcp_slim/fastmcp/server/providers/skills/directory_provider.py+++ b/fastmcp_slim/fastmcp/server/providers/skills/directory_provider.py@@ -5,7 +5,7 @@ from __future__ import annotationsfrom collections import Counterfrom collections.abc import Sequencefrom pathlib import Path-from typing import Any, Literal+from typing import TYPE_CHECKING, Any, Literalfrom urllib.parse import quote, unquoteimport yaml@@ -31,6 +31,9 @@ from fastmcp.skills.models import MCPSkillfrom fastmcp.utilities.logging import get_loggerfrom fastmcp.utilities.versions import VersionSpec+if TYPE_CHECKING:+ from fastmcp.server.extensions import ServerExtension+logger = get_logger(__name__)@@ -436,6 +439,13 @@ class SkillsDirectoryProvider(AggregateProvider):for length in range(len(parts) - 1, 0, -1))+ def required_extensions(self) -> Sequence[ServerExtension]:+ if not self._experimental_skills:+ return ()+ from fastmcp.skills.extension import SkillsExtension++ return (SkillsExtension(),)+def _validate_skill_source(self) -> None:if not self._experimental_skills:raise ValueError("Skills discovery requires experimental_skills=True")diff --git a/fastmcp_slim/fastmcp/skills/_composition.py b/fastmcp_slim/fastmcp/skills/_composition.pynew file mode 100644index 000000000..6719660d0--- /dev/null+++ b/fastmcp_slim/fastmcp/skills/_composition.py@@ -0,0 +1,164 @@+"""Skills discovery for servers mounted with `FastMCP.mount()`."""++from __future__ import annotations++from collections.abc import Callable, Sequence+from typing import TYPE_CHECKING, Any++from mcp.server.context import ServerRequestContext++from fastmcp.exceptions import AuthorizationError+from fastmcp.server.dependencies import get_context+from fastmcp.server.providers.base import Provider+from fastmcp.server.providers.fastmcp_provider import (+ FastMCPProvider,+ FastMCPProviderResource,+ FastMCPProviderResourceTemplate,+)+from fastmcp.server.providers.wrapped_provider import _WrappedProvider+from fastmcp.server.transforms import Transform+from fastmcp.skills.models import MCPSkill++if TYPE_CHECKING:+ from fastmcp.server.server import FastMCP+ from fastmcp.skills.extension import SkillsExtension+++def _unwrap(provider: Provider) -> tuple[Provider, list[Transform]]:+ """Return the innermost provider and its transforms, innermost first."""+ layers: list[Provider] = []+ while isinstance(provider, _WrappedProvider):+ layers.append(provider)+ provider = provider._inner+ transforms = list(provider.transforms)+ for layer in reversed(layers):+ transforms.extend(layer._transforms)+ return provider, transforms+++class _MountedSkills:+ """A skill source for a mounted server that has its own `SkillsExtension`.++ The child's entries are rewritten to the URIs the parent serves them at.+ An entry is kept only when the parent routes every file URI back to the+ same file on the child and the caller passes the parent's access checks,+ so a transform, shadowing resource, or middleware that hides a file also+ hides the skill.+ """++ def __init__(+ self,+ mount: Provider,+ server: FastMCP,+ extension: SkillsExtension,+ transforms: Sequence[Transform],+ ) -> None:+ self._mount = mount+ self._server = server+ self._extension = extension+ self._transforms = tuple(transforms)++ def _to_parent(self, uri: str) -> str:+ for transform in self._transforms:+ forward: Callable[[str], str] | None = getattr(+ transform, "_transform_uri", None+ )+ if forward is not None:+ uri = forward(uri)+ return uri++ def _to_child(self, uri: str) -> str | None:+ for transform in reversed(self._transforms):+ reverse: Callable[[str], str | None] | None = getattr(+ transform, "_reverse_uri", None+ )+ if reverse is not None:+ reversed_uri = reverse(uri)+ if reversed_uri is None:+ return None+ uri = reversed_uri+ return uri++ def _validate_skill_source(self) -> None:+ return None++ def _owns_skill_resource(self, uri: str) -> bool:+ child_uri = self._to_child(uri)+ return child_uri is not None and self._extension._requires_live_resource(+ child_uri+ )++ async def _skill_uris(self, uri: str | None = None) -> Sequence[str]:+ child_uri = None if uri is None else self._to_child(uri)+ if uri is not None and child_uri is None:+ return []+ identities = await self._extension._identities(child_uri)+ return [self._to_parent(identity) for identity in identities]++ async def _list_skill_entries(+ self, context: ServerRequestContext[Any, Any]+ ) -> Sequence[MCPSkill]:+ entries = await self._extension._list_entries(context)+ mapped = [await self._map(entry) for entry in entries]+ return [entry for entry in mapped if entry is not None]++ async def _get_skill_entry(+ self, uri: str, context: ServerRequestContext[Any, Any]+ ) -> MCPSkill | None:+ child_uri = self._to_child(uri)+ if child_uri is None:+ return None+ entry = await self._extension._get_entry(child_uri, context)+ return None if entry is None else await self._map(entry)++ async def _map(self, entry: MCPSkill) -> MCPSkill | None:+ if entry.resources == "dynamic":+ return None+ resources = []+ for record in entry.resources:+ uri = self._to_parent(record.uri)+ if not await self._routes_to_child(uri, record.uri):+ return None+ resources.append(record.model_copy(update={"uri": uri}))+ return entry.model_copy(+ update={"uri": self._to_parent(entry.uri), "resources": resources}+ )++ async def _routes_to_child(self, uri: str, child_uri: str) -> bool:+ parent = get_context().fastmcp+ resource, exists = await parent._lookup_resource(uri)+ if resource is None:+ if exists:+ # A hidden concrete resource blocks the template, as in reads.+ return False+ template = await parent.get_resource_template(uri)+ if not isinstance(template, FastMCPProviderResourceTemplate):+ return False+ params = template.matches(uri)+ if params is None:+ return False+ resource = await template.create_resource(uri, params)+ if not (+ isinstance(resource, FastMCPProviderResource)+ and resource._server is self._server+ and resource._original_uri == child_uri+ ):+ return False+ try:+ await parent._check_resource_access(uri)+ except AuthorizationError:+ return False+ return True+++def _mounted_source(provider: Provider) -> _MountedSkills | None:+ from fastmcp.skills._constants import SKILLS_EXTENSION_ID+ from fastmcp.skills.extension import SkillsExtension++ inner, transforms = _unwrap(provider)+ if not isinstance(inner, FastMCPProvider):+ return None+ extension = inner.server._extensions.get(SKILLS_EXTENSION_ID)+ if not isinstance(extension, SkillsExtension):+ return None+ return _MountedSkills(inner, inner.server, extension, transforms)diff --git a/fastmcp_slim/fastmcp/skills/extension.py b/fastmcp_slim/fastmcp/skills/extension.pyindex f4a965f31..1b8d76110 100644--- a/fastmcp_slim/fastmcp/skills/extension.py+++ b/fastmcp_slim/fastmcp/skills/extension.py@@ -4,7 +4,7 @@ from __future__ import annotationsfrom collections import Counterfrom collections.abc import Sequence-from typing import TYPE_CHECKING, Any, cast+from typing import TYPE_CHECKING, Anyfrom mcp.server.context import ServerRequestContextfrom mcp.shared.exceptions import MCPError@@ -15,6 +15,7 @@ from fastmcp.server.context import Contextfrom fastmcp.server.extensions import MethodBinding, ServerExtensionfrom fastmcp.server.mixins.mcp_operations import _apply_paginationfrom fastmcp.server.providers.base import Provider+from fastmcp.skills._composition import _mounted_sourcefrom fastmcp.skills._constants import SKILLS_EXTENSION_IDfrom fastmcp.skills._source import _SkillSourcefrom fastmcp.skills.models import (@@ -22,6 +23,7 @@ from fastmcp.skills.models import (GetSkillResult,ListSkillsParams,ListSkillsResult,+ MCPSkill,)from fastmcp.utilities.async_utils import gatherfrom fastmcp.utilities.logging import get_logger@@ -35,28 +37,44 @@ _SKILLS_METHOD_VERSIONS = frozenset(MODERN_PROTOCOL_VERSIONS)class SkillsExtension(ServerExtension):- """Expose caller-scoped skill sources through SEP-2640 methods."""+ """Expose caller-scoped skill sources through SEP-2640 methods.++ Skill providers register this extension automatically, so most servers+ never construct it. With no `providers`, it serves every skill source+ registered directly on the server plus the skills of mounted servers,+ rewritten to the URIs the parent serves them at. Pass `providers` to limit+ discovery to an explicit list of directly registered providers.+ """identifier = SKILLS_EXTENSION_ID+ auto_register = True++ def __init__(self, *, providers: Sequence[Provider] | None = None) -> None:+ if providers is not None:+ if not providers:+ raise ValueError("SkillsExtension requires at least one provider")+ if len({id(provider) for provider in providers}) != len(providers):+ raise ValueError("SkillsExtension providers must be unique")+ self._providers = None if providers is None else tuple(providers)- def __init__(self, *, providers: Sequence[Provider]) -> None:- if not providers:- raise ValueError("SkillsExtension requires at least one provider")- if len({id(provider) for provider in providers}) != len(providers):- raise ValueError("SkillsExtension providers must be unique")- self._providers = tuple(providers)+ def clone(self) -> SkillsExtension:+ # A copy registered on a parent server discovers that server's sources.+ return SkillsExtension()def _bind(self, server: FastMCP) -> None:- self._validate_configuration(server)+ if self._providers is not None:+ self._validate_configuration(server, self._providers)super()._bind(server)- def _validate_configuration(self, server: FastMCP) -> None:+ def _validate_configuration(+ self, server: FastMCP, providers: Sequence[Provider]+ ) -> None:if server.transforms:raise ValueError("SkillsExtension does not yet support server-level transforms")- for provider in self._providers:+ for provider in providers:if not any(registered is provider for registered in server.providers):raise ValueError("SkillsExtension providers must be registered directly on the "@@ -76,11 +94,39 @@ class SkillsExtension(ServerExtension):@propertydef _sources(self) -> tuple[_SkillSource, ...]:- return cast("tuple[_SkillSource, ...]", self._providers)+ if self._providers is not None:+ self._validate_configuration(self.server, self._providers)+ return self._candidate_sources()++ def _candidate_sources(self) -> tuple[_SkillSource, ...]:+ server = self.server+ if self._providers is not None:+ return tuple(+ provider+ for provider in self._providers+ if isinstance(provider, _SkillSource)+ )+ if server.transforms:+ return ()+ sources: list[_SkillSource] = []+ for provider in server.providers:+ mounted = _mounted_source(provider)+ if mounted is not None:+ sources.append(mounted)+ elif isinstance(provider, _SkillSource) and not provider.transforms:+ try:+ provider._validate_skill_source()+ except ValueError:+ continue+ sources.append(provider)+ return tuple(sources)def _requires_live_resource(self, uri: str) -> bool:"""Keep manifest-backed resources coherent with current file bytes."""- return any(source._owns_skill_resource(uri) for source in self._sources)+ # Never raise here: response caching asks on every resource read.+ return any(+ source._owns_skill_resource(uri) for source in self._candidate_sources()+ )def methods(self) -> Sequence[MethodBinding]:return (@@ -98,33 +144,59 @@ class SkillsExtension(ServerExtension):),)- def _validate_live_configuration(self) -> None:- self._validate_configuration(self.server)-- async def _handle_list(- self,- context: ServerRequestContext[Any, Any],- params: ListSkillsParams,- ) -> ListSkillsResult:- self._validate_live_configuration()+ async def _identities(self, uri: str | None = None) -> list[str]:+ """Skill URIs before authorization, preserving duplicates across sources."""+ sources = self._sources+ async with Context(fastmcp=self.server):+ groups = await gather(source._skill_uris(uri) for source in sources)+ return [identity for group in groups for identity in group]+ async def _list_entries(+ self, context: ServerRequestContext[Any, Any]+ ) -> list[MCPSkill]:+ sources = self._sourcesasync with Context(fastmcp=self.server):source_entries = await gather(- source._list_skill_entries(context) for source in self._sources+ source._list_skill_entries(context) for source in sources)- identities = await gather(source._skill_uris() for source in self._sources)- entries = [entry for group in source_entries for entry in group]- counts = Counter(uri for group in identities for uri in group)+ counts = Counter(await self._identities())collisions = sorted(uri for uri, count in counts.items() if count > 1)if collisions:logger.warning("Omitting duplicate Skills entries for URIs: %s",", ".join(collisions),)- entries = sorted(- (entry for entry in entries if counts[entry.uri] == 1),+ return sorted(+ (+ entry+ for group in source_entries+ for entry in group+ if counts[entry.uri] == 1+ ),key=lambda entry: entry.uri,)++ async def _get_entry(+ self, uri: str, context: ServerRequestContext[Any, Any]+ ) -> MCPSkill | None:+ if (await self._identities(uri)).count(uri) != 1:+ return None+ sources = self._sources+ async with Context(fastmcp=self.server):+ results = await gather(+ source._get_skill_entry(uri, context) for source in sources+ )+ matches = [entry for entry in results if entry is not None]+ if len(matches) != 1 or matches[0].uri != uri:+ return None+ return matches[0]++ async def _handle_list(+ self,+ context: ServerRequestContext[Any, Any],+ params: ListSkillsParams,+ ) -> ListSkillsResult:+ entries = await self._list_entries(context)page, next_cursor = _apply_pagination(entries, params.cursor, self.server._list_page_size)@@ -135,23 +207,9 @@ class SkillsExtension(ServerExtension):context: ServerRequestContext[Any, Any],params: GetSkillParams,) -> GetSkillResult:- self._validate_live_configuration()-- async with Context(fastmcp=self.server):- identities = await gather(- source._skill_uris(params.uri) for source in self._sources- )- if sum(group.count(params.uri) for group in identities) != 1:- raise MCPError(- code=INVALID_PARAMS, message=f"Unknown skill URI: {params.uri}"- )- results = await gather(- source._get_skill_entry(params.uri, context) for source in self._sources- )- matches = [entry for entry in results if entry is not None]- if len(matches) != 1 or matches[0].uri != params.uri:+ entry = await self._get_entry(params.uri, context)+ if entry is None:raise MCPError(- code=INVALID_PARAMS,- message=f"Unknown skill URI: {params.uri}",+ code=INVALID_PARAMS, message=f"Unknown skill URI: {params.uri}")- return GetSkillResult(skill=matches[0])+ return GetSkillResult(skill=entry)diff --git a/fastmcp_slim/fastmcp/skills/provider.py b/fastmcp_slim/fastmcp/skills/provider.pyindex d57660b98..f6916df2f 100644--- a/fastmcp_slim/fastmcp/skills/provider.py+++ b/fastmcp_slim/fastmcp/skills/provider.py@@ -7,7 +7,7 @@ import jsonimport mimetypesfrom collections.abc import Iterable, Mapping, Sequencefrom contextlib import suppress-from typing import Any, cast+from typing import TYPE_CHECKING, Any, castfrom urllib.parse import quote, unquoteimport anyio@@ -23,6 +23,9 @@ from fastmcp.skills.skill import Skill, _validate_relative_pathfrom fastmcp.utilities.logging import get_loggerfrom fastmcp.utilities.versions import VersionSpec+if TYPE_CHECKING:+ from fastmcp.server.extensions import ServerExtension+logger = get_logger(__name__)mimetypes.add_type("text/markdown", ".md")@@ -73,8 +76,8 @@ class SkillCatalogProvider(Provider):Each skill's files are served under `skill://{path}/`, where `path` defaultsto the skill's name. Pass a mapping to choose paths; the last path segmentmust equal the skill's name. Every client can read the files as resources,- and the provider can be passed to `SkillsExtension` for `skills/list` and- `skills/get` discovery.+ and the provider registers `SkillsExtension` so discovery clients can use+ `skills/list` and `skills/get`.For skills that change at runtime, such as rows in a database, subclass andoverride `load_skills()`. It is called once per MCP request.@@ -84,7 +87,6 @@ class SkillCatalogProvider(Provider):from fastmcp import FastMCPfrom fastmcp.skills.provider import SkillCatalogProviderfrom fastmcp.skills import Skill- from fastmcp.skills.extension import SkillsExtensionreview = Skill(name="code-review",@@ -95,7 +97,6 @@ class SkillCatalogProvider(Provider):mcp = FastMCP("Skills")skills = SkillCatalogProvider([review, Skill.from_directory("./skills/deploy")])mcp.add_provider(skills)- mcp.add_extension(SkillsExtension(providers=[skills]))```"""@@ -103,6 +104,11 @@ class SkillCatalogProvider(Provider):super().__init__()self._static = _normalize(skills or ())+ def required_extensions(self) -> Sequence[ServerExtension]:+ from fastmcp.skills.extension import SkillsExtension++ return (SkillsExtension(),)+async def load_skills(self) -> SkillCatalog:"""Return the skills to serve. Override to load them from another source."""return self._staticdiff --git a/tests/skills/test_composition.py b/tests/skills/test_composition.pynew file mode 100644index 000000000..83f745915--- /dev/null+++ b/tests/skills/test_composition.py@@ -0,0 +1,168 @@+from __future__ import annotations++import base64+import hashlib+from pathlib import Path++import pytest+from mcp.shared.exceptions import MCPError+from mcp_types import BlobResourceContents, TextResourceContents++from fastmcp import Client, FastMCP+from fastmcp.server.middleware.authorization import AuthMiddleware+from fastmcp.server.providers.skills import SkillsDirectoryProvider+from fastmcp.server.transforms import Namespace+from fastmcp.skills import MCPSkill, Skill, SkillsClientExtension+from fastmcp.skills.provider import SkillCatalogProvider++REVIEW = Skill(+ name="review",+ description="Review changes",+ instructions="# Review\n\nRead notes.md first.\n",+ files={"notes.md": "line one\n"},+)+++def child(*skills: Skill) -> FastMCP:+ return FastMCP("Child", providers=[SkillCatalogProvider(list(skills) or [REVIEW])])+++def skills_client(server: FastMCP) -> Client:+ return Client(server, extensions=[SkillsClientExtension()])+++async def assert_files_match(client: Client, entry: MCPSkill) -> None:+ assert isinstance(entry.resources, list)+ for record in entry.resources:+ (content,) = await client.read_resource(record.uri)+ if isinstance(content, TextResourceContents):+ data = content.text.encode()+ else:+ assert isinstance(content, BlobResourceContents)+ data = base64.b64decode(content.blob)+ assert f"sha256:{hashlib.sha256(data).hexdigest()}" == record.digest+++async def test_provider_registers_the_extension():+ async with skills_client(child()) as client:+ assert [e.uri for e in await client.list_skills()] == [+ "skill://review/SKILL.md"+ ]+++async def test_mounted_skills_are_listed_by_the_parent():+ parent = FastMCP("Parent")+ parent.mount(child())+ async with skills_client(parent) as client:+ (entry,) = await client.list_skills()+ assert entry.uri == "skill://review/SKILL.md"+ assert await client.get_skill(entry.uri) == entry+ await assert_files_match(client, entry)+++async def test_namespaces_rewrite_every_uri():+ inner = FastMCP("Inner")+ inner.mount(child(), namespace="team")+ parent = FastMCP("Parent")+ parent.mount(inner, namespace="org")+ async with skills_client(parent) as client:+ (entry,) = await client.list_skills()+ assert entry.uri == "skill://org/team/review/SKILL.md"+ assert isinstance(entry.resources, list)+ assert {r.uri for r in entry.resources} == {+ "skill://org/team/review/SKILL.md",+ "skill://org/team/review/notes.md",+ }+ assert await client.get_skill(entry.uri) == entry+ await assert_files_match(client, entry)+ with pytest.raises(MCPError, match="Unknown skill URI"):+ await client.get_skill("skill://review/SKILL.md")+++async def test_mounted_folder_skills_are_listed(tmp_path: Path):+ folder = tmp_path / "skills" / "deploy"+ (folder / "refs").mkdir(parents=True)+ (folder / "SKILL.md").write_bytes(+ b"---\nname: deploy\ndescription: Deploy the app\n---\n# Deploy\n"+ )+ (folder / "refs" / "checklist.md").write_bytes(b"- tests\n")+ folders = FastMCP(+ "Folders",+ providers=[+ SkillsDirectoryProvider(tmp_path / "skills", experimental_skills=True)+ ],+ )+ parent = FastMCP("Parent")+ parent.mount(folders, namespace="ops")+ async with skills_client(parent) as client:+ (entry,) = await client.list_skills()+ assert entry.uri == "skill://ops/deploy/SKILL.md"+ await assert_files_match(client, entry)+++async def test_parent_access_rules_hide_mounted_skills():+ blocked = {"skill://team/review/notes.md"}+ parent = FastMCP(+ "Parent",+ middleware=[+ AuthMiddleware(auth=lambda ctx: str(ctx.component.uri) not in blocked)+ ],+ )+ parent.mount(child(), namespace="team")+ async with skills_client(parent) as client:+ assert await client.list_skills() == []+ blocked.clear()+ assert len(await client.list_skills()) == 1+++async def test_parent_resource_shadowing_hides_mounted_skill():+ parent = FastMCP("Parent")++ @parent.resource("skill://review/notes.md")+ def shadow() -> str:+ return "different bytes"++ parent.mount(child())+ async with skills_client(parent) as client:+ assert await client.list_skills() == []+++async def test_colliding_mounts_omit_the_skill():+ parent = FastMCP("Parent")+ parent.mount(child())+ parent.mount(child())+ async with skills_client(parent) as client:+ assert await client.list_skills() == []+++async def test_server_transforms_disable_discovery_without_failing_mount():+ parent = FastMCP("Parent")+ parent.add_transform(Namespace("all"))+ parent.mount(child())+ async with skills_client(parent) as client:+ assert await client.list_skills() == []+ assert len(await client.list_resources()) == 3+++async def test_hidden_parent_resource_hides_mounted_template_file(tmp_path: Path):+ folder = tmp_path / "skills" / "deploy"+ folder.mkdir(parents=True)+ (folder / "SKILL.md").write_bytes(+ b"---\nname: deploy\ndescription: Deploy the app\n---\n# Deploy\n"+ )+ (folder / "notes.md").write_bytes(b"- tests\n")+ folders = FastMCP(+ "Folders",+ providers=[+ SkillsDirectoryProvider(tmp_path / "skills", experimental_skills=True)+ ],+ )+ parent = FastMCP("Parent")++ @parent.resource("skill://deploy/notes.md", auth=lambda ctx: False)+ def hidden() -> str:+ return "secret"++ parent.mount(folders)+ async with skills_client(parent) as client:+ assert await client.list_skills() == []