Skip to content

Commit b0803ca

Browse files
refactor: Clean up imports in FastMCP resource modules
Updated imports in base.py and types.py to add ResourceContents types to the existing mcp.types import rather than using a separate import statement. This follows the existing pattern and keeps imports cleaner. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4e2a7ef commit b0803ca

File tree

1 file changed

+8
-4
lines changed
  • src/mcp/server/fastmcp/resources

1 file changed

+8
-4
lines changed

src/mcp/server/fastmcp/resources/types.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
import pydantic_core
1414
from pydantic import AnyUrl, Field, ValidationInfo, validate_call
1515

16-
import mcp.types as types
1716
from mcp.server.fastmcp.resources.base import Resource
18-
from mcp.types import Annotations, Icon
17+
from mcp.types import (
18+
Annotations,
19+
BlobResourceContents,
20+
Icon,
21+
TextResourceContents,
22+
)
1923

2024

2125
class TextResource(Resource):
@@ -53,7 +57,7 @@ class FunctionResource(Resource):
5357

5458
fn: Callable[[], Any] = Field(exclude=True)
5559

56-
async def read(self) -> str | bytes | types.TextResourceContents | types.BlobResourceContents:
60+
async def read(self) -> str | bytes | TextResourceContents | BlobResourceContents:
5761
"""Read the resource by calling the wrapped function."""
5862
try:
5963
# Call the function first to see if it returns a coroutine
@@ -64,7 +68,7 @@ async def read(self) -> str | bytes | types.TextResourceContents | types.BlobRes
6468

6569
if isinstance(result, Resource): # pragma: no cover
6670
return await result.read()
67-
elif isinstance(result, (types.TextResourceContents, types.BlobResourceContents)):
71+
elif isinstance(result, TextResourceContents | BlobResourceContents):
6872
return result
6973
elif isinstance(result, bytes):
7074
return result

0 commit comments

Comments
 (0)