fastmcp-threading
Installation
SKILL.md
fastmcp-threading
Purpose
FastMCP by default utilizes the main thread's standard inputs and outputs to communicate via the MCP Protocol. This is a blocking loop. If you want to run a management API or dashboard (e.g., using Flask) alongside it in the same process, you cannot block the main thread with both loops.
Usage
Start the Flask application inside a separate background thread with daemon=True. This keeps the main thread free for FastMCP, while allowing the web server to handle background API requests natively.
import threading
from flask import Flask
from mcp.server.fastmcp import FastMCP
app = Flask("Management Interface")
mcp = FastMCP("Tool Service")