Provides a sentiment analysis tool based on the Hugging Face MCP Course, offering polarity scoring, subjectivity assessment, and overall sentiment classification (positive, negative, or neutral) for text inputs.
Model Context Protocol (MCP) Test Lab
This project demonstrates the use of Model Context Protocol (MCP) and how it works with langgraph to build an agent. There are two parts to this project.
The first demonstrates the use of MCP for sentiment analysis and is based on the Hugging Face MCP Course. Instead of using the gradio library in the HuggingFace course, this project utilizes the fastmcp library to implement an MCP server and client.
The second part implements an MCP agent that connects to various tools, including mathematical operations and sentiment analysis capabilities, allowing for a more complex AI assistant. This part makes use of the langgraph library to create an agent that can interact with these tools.
Overview
This project demonstrates different implementations of the Model Context Protocol (MCP) with a focus on sentiment analysis and agent capabilities:
mcp-sentiment/: Contains the MCP server implementation (app_fastmcp.py) and various client implementations using different transport protocols (stdio, SSE, and streamable-http) for sentiment analysis. See mcp-sentiment/README.md for more details.
mcp-agent/: Implements agent functionality with specialized tools for mathematical operations and sentiment analysis, along with a client to interact with these agent capabilities. See mcp-agent/README.md for more details.
tests/: Comprehensive test suite validating all components of the system, including client implementations across different transport protocols, agent functionality, math tools, and sentiment analysis capabilities.
Related MCP server: MCP-PIF Server
Codebase Directory Structure
Setup Instructions
To set up the project, follow these steps:
Clone the repository:
git clone https://github.com/jimthompson5802/mcp_testlab.git cd mcp_testlabCreate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`Install system dependencies (if needed):
For macOS, you may need to install Graphviz:
brew install graphvizFor Linux, you can install Graphviz using your package manager, e.g.:
sudo apt-get install graphvizsetup environment variables for CFLAGS and LDFLAGS:
# For macOS with Homebrew export CFLAGS="-I/opt/homebrew/include" export LDFLAGS="-L/opt/homebrew/lib"Install the required packages:
pip install -r requirements.txt
Unit Tests
Unit tests are provided to ensure the functionality of the MCP server and client. To run the tests, use the following command:
Sample output:
