Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Building an Advanced Netflix MCP: Server Implementation Guide
79%

Debugging Middleware

Middleware in FastMCP is code that runs around every request, letting you observe or modify behaviour without changing the tools themselves.

Here we define a simple piece of middleware that prints tool calls to the terminal when the DEBUG environment variable is set to true.

class DebugToolMiddleware(Middleware):
    """Print tool calls when DEBUG=true environment variable is set."""

    async def on_call_tool(self, context: MiddlewareContext, call_next):
        """Intercept tool calls and log them before execution."""
        if os.getenv("DEBUG", "false").lower() == "true":
            tool_name = context

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Enroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!