Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

fix: type narrowing for skills resource contents (#3023)

Bill Easton17d3f13f245a
diff --git a/src/fastmcp/utilities/skills.py b/src/fastmcp/utilities/skills.py
index 3c7e3c9bf..ae018d47d 100644
--- a/src/fastmcp/utilities/skills.py
+++ b/src/fastmcp/utilities/skills.py
@@ -7,6 +7,8 @@ from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING
+import mcp.types
+
if TYPE_CHECKING:
from fastmcp.client import Client
@@ -101,7 +103,7 @@ async def get_skill_manifest(client: Client, skill_name: str) -> SkillManifest:
raise ValueError(f"Could not read manifest for skill: {skill_name}")
content = result[0]
- if hasattr(content, "text"):
+ if isinstance(content, mcp.types.TextResourceContents):
try:
manifest_data = json.loads(content.text)
except json.JSONDecodeError as e:
@@ -197,9 +199,9 @@ async def download_skill(
file_path.parent.mkdir(parents=True, exist_ok=True)
# Write content
- if hasattr(content, "text"):
+ if isinstance(content, mcp.types.TextResourceContents):
file_path.write_text(content.text)
- elif hasattr(content, "blob"):
+ elif isinstance(content, mcp.types.BlobResourceContents):
# Handle base64-encoded binary content
import base64