Calculator Tools MCP Server
Provides tools for storing and listing news articles in a Neo4j graph database, enabling persistent storage and retrieval of article data.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Calculator Tools MCP Serverconvert 30 Celsius to Fahrenheit"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server - Calculator Tools
A containerized Model Context Protocol (MCP) server built with Python and FastMCP. This server provides practical utility tools for temperature conversion and percentage calculations through an HTTP-based interface.
Author: Yogesh Kadiya
Overview
This MCP server exposes multiple utility tools for common calculations and news fetching:
Available Tools
Celsius to Fahrenheit Converter
Function:
convert_celsius_to_fahrenheit(celsius: float) -> strDescription: Converts temperature values from Celsius to Fahrenheit scale
Input: Temperature in degrees Celsius
Output: Formatted string with both Celsius and Fahrenheit values (2 decimal places)
Example:
120°C is equal to 248.00°FError Handling: Catches and reports conversion errors
Percentage Calculator
Function:
calculate_percentage(part: float, total: float) -> strDescription: Calculates what percentage a given part represents of the total
Inputs:
part: The portion or subset valuetotal: The whole or 100% value
Output: Formatted string showing the percentage (2 decimal places)
Example:
25 is 50.00% of 50Error Handling: Prevents division by zero errors
Latest News Fetcher
Function:
get_latest_news(query: str = "technology", language: str = "en", max_results: int = 5) -> strDescription: Fetches the latest news articles based on a search query from NewsAPI
Inputs:
query: Search topic (e.g., "technology", "sports", "business", "python programming")language: ISO 639-1 language code (default: "en" for English)max_results: Maximum number of articles to return, 1-100 (default: 5)
Output: Formatted string containing article titles, descriptions, sources, publication dates, and URLs
Example: Returns top 5 articles about Python programming in English
Error Handling: Handles network timeouts, connection errors, and API errors gracefully
Top Headlines Fetcher
Function:
get_top_headlines(country: str = "us", category: str = "general", max_results: int = 5) -> strDescription: Fetches top headlines for a specific country and category from NewsAPI
Inputs:
country: ISO 2-letter country code (e.g., "us", "uk", "in", "fr", "de", "ca")category: News category - business, entertainment, general, health, science, sports, technologymax_results: Maximum number of articles to return, 1-100 (default: 5)
Output: Formatted string containing headline articles with details
Example: Returns top 5 technology headlines from the United States
Error Handling: Validates inputs and handles API errors
Additional Features
Dynamic Greeting Resource:
greeting://{name}- Provides personalized greetingsPrompt Generation: Create greeting prompts in different styles (friendly, formal, casual)
News API Integration
The news fetching tools use NewsAPI.org (free tier) to provide real-time news data:
API Endpoint: https://newsapi.org/v2/
Free Tier: 100 requests per day
Setup:
Sign up for a free account at https://newsapi.org/
Go to the API Keys section in your NewsAPI dashboard.
Create a new API key if you don't already have one, or generate a replacement key when required.
Set the environment variable for your runtime environment:
macOS/Linux:
export NEWSAPI_KEY="your_api_key"Windows PowerShell:
$env:NEWSAPI_KEY = "your_api_key"Docker: use
-e NEWSAPI_KEY=your_api_keywhen running the container
If no API key is set, the tools will use the default demo key with limited functionality.
Example Usage:
# Get latest technology news
get_latest_news("artificial intelligence", language="en", max_results=10)
# Get top headlines from the UK in sports category
get_top_headlines(country="uk", category="sports", max_results=5)Project Structure
mcp-server/
├── server.py # Main FastMCP server with tool definitions
├── tools/
│ ├── __init__.py
│ ├── calculator.py # Calculator tool implementations
│ └── server.py # Flask application with socket handling
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
├── justfile # Local task runner commands
└── README.md # This fileTechnologies Used
FastMCP: FastAPI-based Model Context Protocol server framework
Flask: Lightweight web framework for HTTP endpoints
Python 3.11: Programming language and runtime
Docker: Containerization for deployment
uvicorn: ASGI server for HTTP transport
Just: Simple task runner for project commands
Getting Started
Prerequisites
Python 3.11 or higher
Docker (optional, for containerized deployment)
pip or uv package manager
Installation
Clone the Repository
git clone https://github.com/yogeskk2/mcp-server.git cd mcp-serverInstall Dependencies
pip install -r requirements.txtSet Environment Variables (Optional)
export MCP_HOST=0.0.0.0 export MCP_PORT=8000
Running the Server
Option 1: Direct Python Execution
python server.pyThe server will start on http://localhost:8000 with streamable HTTP transport.
Option 2: Docker Container
Build the Docker Image
docker build -t mcp-server .Run the Container
docker run -p 8000:8000 \ -e MCP_HOST=0.0.0.0 \ -e MCP_PORT=8000 \ mcp-server
The server will be accessible at http://localhost:8000
Policy enforcement: None — OPA integration and policy rules have been removed from this repository.
Usage
Calling Tools
Once the server is running, you can invoke the tools via MCP client:
Example 1: Temperature Conversion
{
"tool": "convert_celsius_to_fahrenheit",
"arguments": {
"celsius": 0
}
}Response: "0°C is equal to 32.00°F"
Example 2: Percentage Calculation
{
"tool": "calculate_percentage",
"arguments": {
"part": 25,
"total": 100
}
}Response: "25 is 25.00% of 100"
Server Endpoints
Status Check:
GET /statusResponse:
{"status": "MCP server is running"}
Main MCP Handler:
http://localhost:8000(POST requests via streamable HTTP transport)
Configuration
Configuration settings are defined in tools/server.py:
HOST = '0.0.0.0' # Server listening address
PORT = 5000 # Flask server port
DEBUG = True # Debug modeEnvironment Variables
MCP_HOST: MCP server hostname (default:0.0.0.0)MCP_PORT: MCP server port (default:8000)
API Documentation
MCP Tools
Tool | Parameters | Returns | Purpose |
|
|
| Convert Celsius to Fahrenheit |
|
|
| Calculate percentage of part relative to total |
|
|
| Store a news article node in Neo4j |
|
|
| List stored articles from Neo4j |
Resources
Resource | Parameters | Purpose |
|
| Generate personalized greeting |
Prompts
Prompt | Parameters | Purpose |
|
| Create styled greeting prompts |
Error Handling
Both calculation tools include robust error handling:
Temperature Converter: Catches and reports conversion exceptions
Percentage Calculator: Validates that total is not zero before calculation
Development
Project Layout
Main Server: server.py - FastMCP server initialization and tool definitions
Flask App: tools/server.py - Secondary HTTP server with socket handling
Calculator Tools: tools/calculator.py - Calculator tool implementations
Adding New Tools
To add new tools to the MCP server, edit server.py and use the @mcp.tool() decorator:
@mcp.tool()
def your_tool(param1: str, param2: int) -> str:
"""Tool description"""
# Implementation
return resultDependencies
See requirements.txt for a complete list. Key dependencies:
mcp==1.27.1- Model Context Protocol libraryFlask- Web frameworkuvicorn- ASGI serverrequests- HTTP client librarynumpy- Numerical computingpandas- Data manipulationflask-socketio- WebSocket support
Deployment
Docker Deployment
The project includes a Dockerfile for containerization. The image:
Uses Python 3.11-slim as base
Installs dependencies from
requirements.txtExposes port 8000
Runs the MCP server on startup
Running Tests
To verify the server is working:
# After starting the server, in another terminal:
curl http://localhost:5000/statusExpected response:
{
"status": "MCP server is running"
}Troubleshooting
Issue | Solution |
Port already in use | Change |
Dependencies missing | Run |
Docker build fails | Ensure Docker is running and |
Connection refused | Verify server is running and check |
Future Enhancements
Add additional utility tools (unit conversions, calculations)
Implement caching for frequently used calculations
Add logging and monitoring capabilities
Create a web dashboard for tool testing
Add comprehensive unit tests
License
This project is provided as-is for educational and commercial use.
Author
Yogesh Kadiya
Support
For issues, questions, or suggestions, please refer to the project documentation or contact the author.
Dependencies
The required Python dependencies are listed in requirements.txt. Make sure to install them if you are running the server outside of Docker.
Contributing
If you would like to contribute to this project, please fork the repository and submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/yogeshkk2/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server