fix: remove -> str return annotations from all mcp.tool() functions
FastMCP generates an outputSchema from the return type annotation, which inflates the tools/list payload and triggers truncation in Claude Desktop. Dropping the annotations suppresses outputSchema generation entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -105,7 +105,7 @@ def register_filestation(
|
|||||||
delay = min(delay * 2, 2.0)
|
delay = min(delay * 2, 2.0)
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def list_shares() -> str:
|
async def list_shares():
|
||||||
"""List all shared folders visible to the authenticated user.
|
"""List all shared folders visible to the authenticated user.
|
||||||
|
|
||||||
Returns a formatted table with share name, path, and volume status.
|
Returns a formatted table with share name, path, and volume status.
|
||||||
@@ -163,7 +163,7 @@ def register_filestation(
|
|||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
sort_by: str = "name",
|
sort_by: str = "name",
|
||||||
sort_direction: str = "asc",
|
sort_direction: str = "asc",
|
||||||
) -> str:
|
):
|
||||||
"""List the contents of a directory on the NAS.
|
"""List the contents of a directory on the NAS.
|
||||||
|
|
||||||
Use share paths as returned by list_shares (e.g. "/dev", "/data"),
|
Use share paths as returned by list_shares (e.g. "/dev", "/data"),
|
||||||
@@ -265,7 +265,7 @@ def register_filestation(
|
|||||||
pattern: str,
|
pattern: str,
|
||||||
recursive: bool = True,
|
recursive: bool = True,
|
||||||
max_results: int = 200,
|
max_results: int = 200,
|
||||||
) -> str:
|
):
|
||||||
"""Search for files matching a glob pattern within a directory.
|
"""Search for files matching a glob pattern within a directory.
|
||||||
|
|
||||||
Starts an async DSM search task, polls until complete, then cleans up.
|
Starts an async DSM search task, polls until complete, then cleans up.
|
||||||
@@ -399,7 +399,7 @@ def register_filestation(
|
|||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def download(path: str) -> str:
|
async def download(path: str):
|
||||||
"""Download a single file from the NAS and return its content as base64.
|
"""Download a single file from the NAS and return its content as base64.
|
||||||
|
|
||||||
Files larger than 10 MB are rejected — use SFTP or another method instead.
|
Files larger than 10 MB are rejected — use SFTP or another method instead.
|
||||||
@@ -438,7 +438,7 @@ def register_filestation(
|
|||||||
)
|
)
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def get_info(path: str) -> str:
|
async def get_info(path: str):
|
||||||
"""Get detailed metadata for one or more files or folders on the NAS.
|
"""Get detailed metadata for one or more files or folders on the NAS.
|
||||||
|
|
||||||
Accepts a single path or a comma-separated list of paths.
|
Accepts a single path or a comma-separated list of paths.
|
||||||
@@ -539,7 +539,7 @@ def register_filestation(
|
|||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def check_exist(path: str) -> str:
|
async def check_exist(path: str):
|
||||||
"""Check whether one or more files or folders exist on the NAS.
|
"""Check whether one or more files or folders exist on the NAS.
|
||||||
|
|
||||||
Accepts a single path or a comma-separated list of paths.
|
Accepts a single path or a comma-separated list of paths.
|
||||||
@@ -602,7 +602,7 @@ def register_filestation(
|
|||||||
path: str,
|
path: str,
|
||||||
name: str,
|
name: str,
|
||||||
create_parents: bool = False,
|
create_parents: bool = False,
|
||||||
) -> str:
|
):
|
||||||
"""Create a new folder on the NAS.
|
"""Create a new folder on the NAS.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -634,7 +634,7 @@ def register_filestation(
|
|||||||
return f"Created: {created_path}"
|
return f"Created: {created_path}"
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def rename(path: str, new_name: str) -> str:
|
async def rename(path: str, new_name: str):
|
||||||
"""Rename a file or folder on the NAS.
|
"""Rename a file or folder on the NAS.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -665,7 +665,7 @@ def register_filestation(
|
|||||||
return f"Renamed to: {new_path}"
|
return f"Renamed to: {new_path}"
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def copy(src: str, dst: str, overwrite: bool = False) -> str:
|
async def copy(src: str, dst: str, overwrite: bool = False):
|
||||||
"""Copy a file or folder to a new location on the NAS.
|
"""Copy a file or folder to a new location on the NAS.
|
||||||
|
|
||||||
WARNING: Set overwrite=True only when you intentionally want to replace
|
WARNING: Set overwrite=True only when you intentionally want to replace
|
||||||
@@ -710,7 +710,7 @@ def register_filestation(
|
|||||||
return f"Copied to: {dest_folder}/{filename}"
|
return f"Copied to: {dest_folder}/{filename}"
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def move(src: str, dst: str, overwrite: bool = False) -> str:
|
async def move(src: str, dst: str, overwrite: bool = False):
|
||||||
"""Move a file or folder to a new location on the NAS.
|
"""Move a file or folder to a new location on the NAS.
|
||||||
|
|
||||||
WARNING: Set overwrite=True only when you intentionally want to replace
|
WARNING: Set overwrite=True only when you intentionally want to replace
|
||||||
@@ -755,7 +755,7 @@ def register_filestation(
|
|||||||
return f"Moved to: {dest_folder}/{filename}"
|
return f"Moved to: {dest_folder}/{filename}"
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def delete(path: str, confirmed: bool = False) -> str:
|
async def delete(path: str, confirmed: bool = False):
|
||||||
"""Delete a file or folder on the NAS.
|
"""Delete a file or folder on the NAS.
|
||||||
|
|
||||||
WARNING: This operation is irreversible. Without confirmed=True,
|
WARNING: This operation is irreversible. Without confirmed=True,
|
||||||
@@ -809,7 +809,7 @@ def register_filestation(
|
|||||||
mode: str = "add",
|
mode: str = "add",
|
||||||
format: str = "zip",
|
format: str = "zip",
|
||||||
password: str = "",
|
password: str = "",
|
||||||
) -> str:
|
):
|
||||||
"""Compress files or folders into an archive on the NAS.
|
"""Compress files or folders into an archive on the NAS.
|
||||||
|
|
||||||
Creates a new archive asynchronously. Progress is polled until the operation
|
Creates a new archive asynchronously. Progress is polled until the operation
|
||||||
@@ -879,7 +879,7 @@ def register_filestation(
|
|||||||
keep_dir: bool = True,
|
keep_dir: bool = True,
|
||||||
create_subfolder: bool = False,
|
create_subfolder: bool = False,
|
||||||
password: str = "",
|
password: str = "",
|
||||||
) -> str:
|
):
|
||||||
"""Extract an archive file to a destination folder on the NAS.
|
"""Extract an archive file to a destination folder on the NAS.
|
||||||
|
|
||||||
Supports ZIP and 7z archives. Runs asynchronously; progress is polled
|
Supports ZIP and 7z archives. Runs asynchronously; progress is polled
|
||||||
@@ -939,7 +939,7 @@ def register_filestation(
|
|||||||
content_base64: str,
|
content_base64: str,
|
||||||
overwrite: bool = False,
|
overwrite: bool = False,
|
||||||
create_parents: bool = True,
|
create_parents: bool = True,
|
||||||
) -> str:
|
):
|
||||||
"""Upload a file to a directory on the NAS from base64-encoded content.
|
"""Upload a file to a directory on the NAS from base64-encoded content.
|
||||||
|
|
||||||
WARNING: Set overwrite=True only when you intentionally want to replace
|
WARNING: Set overwrite=True only when you intentionally want to replace
|
||||||
|
|||||||
Reference in New Issue
Block a user