This repo provides three ready-to-run examples:
- chatbot.py β Minimal OpenAI chatbot loop (paste your API key and run).
- agent_handler.py β Implements a custom AgentHandler using Merge MCP's Python SDK.
- mcp_client.py β Async MCP client that connects to an MCP server, lists tools, and can call them.
# Clone repo
git clone https://github.com/merge-api/agent-handler-chat-demo.git
cd agent-handler-chat-demo
# Install dependencies
pip install -r requirements.txt
# Run chatbot
python chatbot.py
# Run agent handler (server mode)
python agent_handler.py
# Run MCP client
python mcp_client.py- Replace
your_api_key_herewith your OpenAI API key inchatbot.pyandagent_handler.py. - Replace
<auth_token>,<tool_pack_id>,<registered_user_id>inmcp_client.pywith your values.
agent-handler-chat-demo/
βββ README.md
βββ requirements.txt
βββ chatbot.py
βββ agent_handler.py
βββ mcp_client.py
- chatbot.py: Simple interactive chatbot using OpenAI's API
- agent_handler.py: MCP-compatible agent handler server
- mcp_client.py: Async MCP client for connecting to MCP servers
- requirements.txt: Python dependencies
- README.md: This file with setup instructions