- Home
- MCP servers
- MCP Calculator Server
MCP Calculator Server
- python
0
GitHub Stars
python
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"kumartheashwani-vault-python-mcp-server": {
"command": "python",
"args": [
"server.py"
],
"env": {
"MCP_HTTP_MODE": "1",
"LOGGING_CONFIG": "stdio",
"MCP_STDIO_MODE": "1"
}
}
}
}You can run a lightweight MCP server that exposes a basic calculator tool. It supports common arithmetic operations and can be deployed in various environments, including local development, containers, or Smithery integrations through different communication modes.
How to use
To perform calculations, connect to the MCP Calculator Server with your MCP client. You will access the calculator tool through the MCP protocol using the supported endpoints and modes. You can choose between a local stdio tool workflow for Smithery or a HTTP-based workflow for containerized or remote deployments. Use the calculator to add, subtract, multiply, and divide numbers, and rely on built-in error handling for invalid operations or malformed input.
How to install
Prerequisites you need before starting:
- Python 3.8+ (recommended)
- A virtual environment tool (optional but recommended)
Installation steps
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Run in HTTP mode (recommended for production)
To run the server in pure HTTP mode, use the HTTP entry point that starts the HTTP server. This workflow is suitable for production, containers, and environments that require reliable HTTP endpoints.
# Set environment variable to ensure only HTTP mode runs
export MCP_HTTP_MODE=1 # On Windows: set MCP_HTTP_MODE=1
uvicorn server:app --host 0.0.0.0 --port 8000
Smithery mode (stdio mode for local tool integration)
For Smithery integration as a local tool, run in stdio mode. This mode communicates via standard input/output and should be configured with the required logging settings.
# Set environment variable to ensure only stdio mode runs
export MCP_STDIO_MODE=1 # On Windows: set MCP_STDIO_MODE=1
python server.py
Dual mode (development only)
If you want to test both HTTP and stdio interfaces simultaneously during development, start the server without forcing a mode. This mode may exit early if stdin is closed and is not recommended for production.
# No environment variables set - runs both modes
python server.py
Notes on deployment
For production or Smithery integrations, prefer HTTP mode for endpoints or stdio mode for local tool workflows. Ensure environment variables are set according to your chosen mode to prevent conflicts between interfaces.
Security and troubleshooting
The server validates input and provides clear error messages for invalid operations or parameter issues. If you encounter timeouts or conflicts, verify that you are running in a single mode appropriate for your deployment and that the correct environment variables are set for that mode.
Available tools
calculator
A basic calculator tool that supports add, subtract, multiply, and divide operations through MCP protocol endpoints.