server.py•1.14 kB
"""MCP server for Finizi B4B API."""
import sys
import structlog
from mcp.server import FastMCP
# Configure structured logging to stderr (not stdout, which is for MCP JSON)
# Use plain JSON format without colors for MCP compatibility
structlog.configure(
processors=[
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.JSONRenderer() # JSON output instead of colored console
],
logger_factory=structlog.PrintLoggerFactory(file=sys.stderr), # Log to stderr
)
logger = structlog.get_logger(__name__)
# Create MCP server instance - must be created before importing tools
mcp = FastMCP(
name="Finizi B4B API",
)
# Import all tool modules - they will register via decorators
# IMPORTANT: These imports must happen AFTER mcp is created
from .tools import auth # noqa: E402, F401
from .tools import entities # noqa: E402, F401
from .tools import invoices # noqa: E402, F401
from .tools import vendors # noqa: E402, F401
from .tools import products # noqa: E402, F401
logger.info("MCP Server initialized", tool_count=len(mcp._tool_manager._tools))