MCP Interaction Workflow: A Step-by-Step Example
23%
Step 6 - Integration: Composing the Final Answer
Once the MCP server finishes executing the tool, it sends a JSON-RPC response back to the client. The Client then unwraps this message and hands the raw data to the host application.
The Feedback Loop
The Host does not show this raw JSON to the user immediately. Instead, it performs a context injection step:
- It appends the tool's result to the LLM's conversation history.
- It sends a new internal prompt to the LLM, effectively saying:
Here is the data you requested from the 'get_air_quality' tool.
--
[..RAW JSON DATA..]
--
Now, use this to answer the user's original question.
The LLM then processes this new prompt, extracts the relevant information from the tool's output, and generates a final response for the user. For example:
The air quality in San Francisco is currently **Good**. The AQI is **42**, and PM2.5 levels are around **8 µg/m³**, which is well within the healthy range.
Post-Processing & Application Logic
Practical MCP with FastMCP & LangChain
Engineering the Agentic ExperienceEnroll 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!
