forked from HomeLab/unraid-mcp
feat(dx): add fastmcp.json configs, module-level tool registration, tool timeout
- Add fastmcp.http.json and fastmcp.stdio.json declarative server configs for streamable-http (:6970) and stdio transports respectively - Move register_all_modules() to module level in server.py so `fastmcp run server.py --reload` discovers the fully-wired mcp object without going through run_server() — tools registered exactly once - Add timeout=120 to @mcp.tool() decorator as a global safety net; any hung subaction returns a clean MCP error instead of hanging forever - Document fastmcp run --reload, fastmcp list, fastmcp call in README - Bump version 1.0.1 → 1.1.0 Co-authored-by: Claude <claude@anthropic.com>
This commit is contained in:
@@ -85,6 +85,10 @@ mcp = FastMCP(
|
||||
# Note: SubscriptionManager singleton is defined in subscriptions/manager.py
|
||||
# and imported by resources.py - no duplicate instance needed here
|
||||
|
||||
# Register all modules at import time so `fastmcp run server.py --reload` can
|
||||
# discover the fully-configured `mcp` object without going through run_server().
|
||||
# run_server() no longer calls this — tools are registered exactly once here.
|
||||
|
||||
|
||||
def register_all_modules() -> None:
|
||||
"""Register all tools and resources with the MCP instance."""
|
||||
@@ -103,6 +107,9 @@ def register_all_modules() -> None:
|
||||
raise
|
||||
|
||||
|
||||
register_all_modules()
|
||||
|
||||
|
||||
def run_server() -> None:
|
||||
"""Run the MCP server with the configured transport."""
|
||||
# Validate required configuration before anything else
|
||||
@@ -125,9 +132,6 @@ def run_server() -> None:
|
||||
"Only use this in trusted networks or for development."
|
||||
)
|
||||
|
||||
# Register all modules
|
||||
register_all_modules()
|
||||
|
||||
logger.info(
|
||||
f"Starting Unraid MCP Server on {UNRAID_MCP_HOST}:{UNRAID_MCP_PORT} using {UNRAID_MCP_TRANSPORT} transport..."
|
||||
)
|
||||
|
||||
@@ -1722,7 +1722,7 @@ UNRAID_ACTIONS = Literal[
|
||||
def register_unraid_tool(mcp: FastMCP) -> None:
|
||||
"""Register the single `unraid` tool with the FastMCP instance."""
|
||||
|
||||
@mcp.tool()
|
||||
@mcp.tool(timeout=120)
|
||||
async def unraid(
|
||||
action: UNRAID_ACTIONS,
|
||||
subaction: str,
|
||||
|
||||
Reference in New Issue
Block a user