-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.Related to FastMCP server implementation or server-side functionality.
Description
Description
Logging in the lifespan is never emitted. With a fastapi server this doesn't happen.
import logging
from fastmcp import FastMCP
from contextlib import asynccontextmanager
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastMCP): # noqa: ANN201, ARG001
"""Application lifespan handler"""
logger.info("Starting MCP API...")
yield
logger.info("Closing MCP API...")
mcp = FastMCP(
name="MCP",
host="0.0.0.0",
port=8050,
stateless_http=True,
lifespan=lifespan,
)
mcp.run(transport="streamable-http", show_banner=False, log_level="INFO")
Example Code
Version Information
FastMCP version: 2.12.4
MCP version: 1.14.1
Python version: 3.12.9
Platform: macOS-15.6.1-arm64-arm-64bit
Metadata
Metadata
Assignees
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.Related to FastMCP server implementation or server-side functionality.