Skip to main content
Glama

MCP Sentiment Analysis Server

README.md3.65 kB
# 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](https://huggingface.co/learn/mcp-course/unit2/introduction). 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](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](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. ## Codebase Directory Structure ```plaintext mcp_testlab/ ├── mcp-sentiment/ │ ├── app_fastmcp.py │ ├── mcp_client_multi-transport.py │ ├── mcp_client_stdio.py │ ├── mcp_client_sse.py │ └── mcp_client_streamable.py ├── mcp-agent/ │ ├── agent_client.py │ ├── math_tools.py │ └── sentiment_tools.py ├── tests/ │ ├── test_00multi_transport.py │ ├── test_agent_client.py │ ├── test_client_stdio.py │ ├── test_client_sse.py │ ├── test_client_streamable.py │ ├── test_math_tools.py │ └── test_sentiment_analysis.py ├── requirements.txt ├── README.md ├── LICENSE ├── .gitignore └── .gitattributes ``` ## Setup Instructions To set up the project, follow these steps: 1. Clone the repository: ```bash git clone https://github.com/jimthompson5802/mcp_testlab.git cd mcp_testlab ``` 2. Create a virtual environment: ```bash python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` ``` 3. Install system dependencies (if needed): - For macOS, you may need to install Graphviz: ```bash brew install graphviz ``` - For Linux, you can install Graphviz using your package manager, e.g.: ```bash sudo apt-get install graphviz ``` - setup environment variables for CFLAGS and LDFLAGS: ```bash # For macOS with Homebrew export CFLAGS="-I/opt/homebrew/include" export LDFLAGS="-L/opt/homebrew/lib" ``` 4. Install the required packages: ```bash 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: ```bash $ pytest -v --cov tests ``` Sample output: ![](./images/mcp_unit_tests1.png)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jimthompson5802/mcp_testlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server