Skip to content

wolfdancer/mcp-example.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This project is based on the code from the Deeplearning training class: MCP: Build Rich-Context AI Apps with Anthropic.

The goal is to clean up the flow in the code with the following modifications

  • Use value in response.stop_reason as the control of the flow, instead of checking to see if the response has only 1 text content. This allows further error checking and should be easier to expand
  • More explicit generate->tool use->generate loop by processing all the contents in the responses and create the complete user content for the next loop
  • Ehanced the chat_loop() to remember the history for a smoother expeirence. For example, the user can type "retrieve the third item for me please" and with the history the bot will know which one the user is referring to.

Initialize

After cloning the project, the following command will help set up the environment

# Install uv if not already
brew install uv

# create local environment
uv venv
source .venv/bin/activate

# install packages
uv pip install .

# set up Anthropic API set
# create a file .env with the following content
ANTHROPIC_API_KEY=sk-ant-...<your API key from https://console.anthropic.com/settings/keys> 

# start chat bot
uv run chat.py

About

Example code for MCP client and server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •