MCP Calculator Demo
Description
# MCP Calculator Demo A demonstration project showcasing a calculator service using the MCP (Model Control Protocol) framework. This project consists of a server that provides basic arithmetic operations and a client that can evaluate both simple and complex mathematical…
About
# MCP Calculator Demo A demonstration project showcasing a calculator service using the MCP (Model Control Protocol) framework. This project consists of a server that provides basic arithmetic operations and a client that can evaluate both simple and complex mathematical expressions. ## Project Structure -…
Details
- Author
- pijush2022
- Downloads
- 172
- Categories
- Other
Jump to
- Basic arithmetic: addition, subtraction, multiplication, division
- Supports simple tool syntax and complex expressions
- Error handling for division by zero
- Server-Sent Events (SSE) communication
- Parentheses support in expressions
- RPN evaluation for complex expressions
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP Calculator DemoCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Clone the repository, create a virtual environment with Python 3.7+, install dependencies from requirements.txt, then start the server with python calculator_server.py (defaults to http://127.0.0.1:5005). In a separate terminal, run python client.py to interact using commands like add 2 3 or complex expressions such as (5+7)*2.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp calculator demo": {
"MCP-server-with-client-demo-for-calculator-with-SSE-": {
"command": "python",
"args": [
"-m",
"venv",
".venv"
]
}
}
}
}
McpServers
{
"MCP-server-with-client-demo-for-calculator-with-SSE-": {
"command": "python",
"args": [
"-m",
"venv",
".venv"
]
}
}
MCP Calculator Demo
A demonstration project showcasing a calculator service using the MCP (Model Control Protocol) framework. This project consists of a server that provides basic arithmetic operations and a client that can evaluate both simple and complex mathematical expressions.Project Structure
-calculator_server.py: The MCP server that provides arithmetic operations
- client.py: The client application that connects to the server and processes user input
- requirements.txt: Project dependencies
Features
- Basic arithmetic operations (addition, subtraction, multiplication, division) - Support for both simple operations (e.g., "add 2 3") 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 expressionsPrerequisites
- Python 3.7+ - pip (Python package manager)Installation
1. Clone the repository 2. Create and activate a virtual environment: ``bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
`
3. Install dependencies:
`bash
pip install -r requirements.txt
`
Usage
Starting the Server
Run the calculator server:
`bash
python calculator_server.py
`
The server will start on http://127.0.0.1:5005 by default.
Running the Client
In a separate terminal, run the client:
`bash
python client.py
`
Available Operations
The calculator supports the following operations:
1. Direct tool syntax:
- add 2 3
- subtract 5 2
- multiply 4 3
- divide 10 2
2. Complex expressions:
- 5+7-2
- 5+7-23
- (5+7)2
- 10/2+34
Example Usage
`
» add 2 3
Result: 5
» 5+7-23
Result: 6
» (5+7)*2
Result: 24
» divide 10 0
Error: Division by zero.
``
Technical Details
- The server uses FastMCP for handling MCP operations - Communication between client and server is done via Server-Sent Events (SSE) - The client implements the Shunting-Yard algorithm for parsing complex expressions - Error handling is implemented for invalid expressions and division by zeroDependencies
- fastapi - uvicorn - sse-starlette - fastmcp>=0.1.0 - llama-index - llama-index-llms-anthropic - anthropic - python-dotenv - requests - sseclient-py - uvLicense
This project is open source and available under the MIT License.Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



