Skip to main content

fastmcp.server.tasks.routing

Task routing helper for MCP components. Provides unified task mode enforcement and docket routing logic.

Functions

check_background_task

Check task mode and submit to background if requested. Args:
  • component: The MCP component
  • task_type: Type of task (“tool”, “resource”, “template”, “prompt”)
  • arguments: Arguments for tool/prompt/template execution
  • task_meta: Task execution metadata. If provided, execute as background task.
Returns:
  • CreateTaskResult if submitted to docket, None for sync execution
Raises:
  • McpError: If mode=“required” but no task metadata, or mode=“forbidden” but task metadata is present