MCP Calculator Demo logo

MCP Calculator Demo

by pijush2022

This project demonstrates a calculator service using the MCP framework. It includes a server providing arithmetic operations and a client for evaluating simple and complex mathematical expressions.

View on GitHub

Last updated: N/A

What is MCP Calculator Demo?

This is a calculator service built using the MCP (Model Control Protocol) framework. It consists of a server that performs basic arithmetic operations and a client that can send requests to the server to evaluate both simple and complex mathematical expressions.

How to use MCP Calculator Demo?

First, clone the repository and install the dependencies using pip install -r requirements.txt. Then, start the server by running python calculator_server.py. In a separate terminal, run the client using python client.py. You can then input arithmetic operations or complex expressions in the client terminal.

Key features of MCP Calculator Demo

  • Basic arithmetic operations (addition, subtraction, multiplication, division)

  • Support for both simple operations and complex expressions

  • Error handling for division by zero

  • Server-Sent Events (SSE) communication between client and server

  • Support for parentheses in expressions

  • RPN (Reverse Polish Notation) evaluation for complex expressions

Use cases of MCP Calculator Demo

  • Performing basic arithmetic calculations

  • Evaluating complex mathematical expressions

  • Demonstrating the use of the MCP framework

  • Implementing a client-server architecture with SSE communication

FAQ from MCP Calculator Demo

What is MCP?

MCP stands for Model Control Protocol, a framework used in this project for handling operations.

What operations are supported?

The calculator supports addition, subtraction, multiplication, and division, both in simple and complex expressions.

How does the client communicate with the server?

Communication between the client and server is done via Server-Sent Events (SSE).

What happens if I try to divide by zero?

The server has error handling in place to catch division by zero and will return an error message.

What is the Shunting-Yard algorithm used for?

The client implements the Shunting-Yard algorithm for parsing complex mathematical expressions.