Sponsored by Deepsite.site

MCP-ChatBot

Created By
muralianand123458 months ago
Simple MCP Client-Server example
Content

MCP-ChatBot

A versatile chatbot application that uses MCP (Modular Capability Protocol) to interact with multiple service backends.

MCP Chatbot License Python Docker

Overview

MCP-ChatBot is a containerized application that demonstrates the use of Modular Capability Protocol (MCP) to enable LLM interactions with external services. This implementation includes a weather service backend and a Streamlit-based frontend that allows users to query for weather information through natural language.

Features

  • Containerized Architecture: Separate containers for the MCP server and client application
  • Weather Service Integration: Real-time weather data using WeatherAPI
  • Streamlit UI: Clean, responsive user interface for interacting with the chatbot
  • Extensible Design: Ready to add more MCP servers for additional capabilities
  • GPT-4o Integration: Powered by OpenAI's GPT-4o model for natural language understanding

Architecture

The application consists of two main components:

  1. MCP Server: A FastMCP-based service that handles weather data retrieval
  2. Streamlit Client: A web-based UI for interacting with the chatbot

Getting Started

Prerequisites

  • Docker and Docker Compose
  • WeatherAPI Key (sign up at WeatherAPI)
  • OpenAI API Key (sign up at OpenAI)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/MCP-ChatBot.git
cd MCP-ChatBot
  1. Create an .env file based on the example:
cp .env.example .env
  1. Edit the .env file and add your API keys:
PYTHONUNBUFFERED=1
OPENAI_API_KEY=your_openai_api_key_here
WEATHER_API_KEY=your_weather_api_key_here
  1. Launch the application using Docker Compose:
docker-compose up --build
  1. Access the Streamlit UI at: http://localhost:8501

Usage

Once the application is running, you can interact with the chatbot through the Streamlit interface:

  1. Type natural language queries about weather in the text input
  2. Examples:
    • "What's the weather like in New York?"
    • "How hot is it in Tokyo right now?"
    • "Tell me about the weather in London"

Extending the Application

Adding New MCP Servers

  1. Create a new server file in the servers directory
  2. Add the new service to the docker-compose.yml file
  3. Update the client.py to include the new server in the agent configuration

Example of adding a new server in client.py:

server_1 = MCPServerHTTP(url="http://mcp_server:8001/sse")
server_2 = MCPServerHTTP(url="http://new_server:8002/sse")  # New server

return Agent("openai:gpt-4o", mcp_servers=[server_1, server_2])

Development

Project Structure

MCP-ChatBot/
├── .env.example             # Example environment variables
├── .gitignore               # Git ignore file
├── client.py                # Streamlit client application
├── docker-compose.yml       # Docker Compose configuration
├── Dockerfile.client        # Dockerfile for Streamlit client
├── Dockerfile.server        # Dockerfile for MCP server
├── LICENSE                  # MIT license
├── README.md                # Project documentation
└── servers/                 # MCP server implementations
    └── server.py            # Weather service implementation

Technology Stack

  • FastMCP: Framework for creating MCP servers
  • Streamlit: Web framework for the UI
  • Pydantic-AI: Agent system for LLM interactions
  • Docker: Containerization platform
  • OpenAI GPT-4o: LLM for natural language processing

Troubleshooting

Common Issues

  1. Connection Failed: Ensure that all services are up and running. The client has a retry mechanism, but if it fails, restart the application.

  2. API Key Errors: Verify that you've added valid API keys to the .env file.

  3. Docker Network Issues: If containers can't communicate, check the Docker network configuration and ensure the service names match in the code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Created by Murali Anand © 2025

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
WindsurfThe new purpose-built IDE to harness magic
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Serper MCP ServerA Serper MCP Server
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。