4.4 · Lesson (Optional)

Connect a Python Agent

The repository includes a small Python agent, agent/main.py. It connects to your MCP server, gives your tools to an LLMA model trained on text to predict the next token, and so to generate language., and runs the tools that the LLM chooses.

annotations=The agent connects to your server as a client, and asks it for its toolsEach tool is described to the LLM with its name, description, and parameters. The LLM sees nothing else about the toolThe loop gives the agent a limited number of steps for one questionThe LLM reasons about the question and the results so far. It either asks for tools or answersIf the LLM asks for no tools, it has enough, and its reply is the answerEach tool the LLM asked for is run on your server, and the result is given back to the LLM for the next step layout="side"

annotations=The agent connects to your server as a client, and asks it for its toolsEach tool is described to the LLM with its name, description, and parameters. The LLM sees nothing else about the toolThe loop gives the agent a limited number of steps for one questionThe LLM reasons about the question and the results so far. It either asks for tools or answersIf the LLM asks for no tools, it has enough, and its reply is the answerEach tool the LLM asked for is run on your server, and the result is given back to the LLM for the next step layout="stack"