Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

The Context Object
51%

What is the MCP Context?

When your MCP tool function runs, it runs inside a session, a live connection between a client (like Claude Desktop) and your server. The Context object in FastMCP is a handle to that session. It lets your tool function perform actions beyond just returning a result: it can send log messages back to the client, remember state across multiple tool calls, report progress on long operations, and even read other resources from the server.

Think of it like this: without context, your tool is a pure function — data goes in and data comes out, and that's it. With context, your tool becomes session-aware — it can talk back to the client while it's working and remember state between calls.

The Context object provides a clean interface to access MCP features within your functions.

These features include:

  • Logging (sending debug, info, warning, and error messages back to the client)

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!