Demo of new MCP sampling with tools feature
This demo has a client app that uses Microsoft.Extensions.AI to connect to GitHub models.
It connects to the MCP server which supports two tools:
- play_craps
- roll_die
It creates a chat client and adds the "play_craps" tool from the server to the chat client.
Then it accepts a prompt from the user and sends it to the chat client.
If the user asks to play a game of craps, the hope is that the LLM will use the tool provided.
The "play_craps" tool of the server will use sampling with tools feature of MCP to play a game of craps.
It will send a sampling request to the client with the prompt: "We are playing a standard game of craps. Roll the dice to establish the point and return the point." And will pass the tool "roll_die".
The hope is that the LLM will request the "roll_die" tool twice to complete the task and return the response.
From there, the "play_craps" tool will issue sampling with tools calls to the client with the prompt: "We are playing a standard game of craps. The point is "x". Roll the dice and report if the player has won or lost or pushed."
The hope is that the LLM will request the "roll_die" tool twice to complete the task and return the response.
The tool will repeat this step until the game is won or lost.