Navigation
MCP Calculator: Smart Automation & Custom Greetings - MCP Implementation

MCP Calculator: Smart Automation & Custom Greetings

Effortlessly power your MCP workflows with MCP Calculator: A Go-built server merging smart calculations and customizable greetings for seamless, high-performance automation.

Developer Tools
4.5(78 reviews)
117 saves
54 comments

Ranked in the top 9% of all AI tools in its category

About MCP Calculator

What is MCP Calculator: Smart Automation & Custom Greetings?

MCP Calculator is a Go-based server implementing the Model Context Protocol (MCP), designed to handle automated calculations and personalized greetings. It combines smart tool execution with customizable resource interactions, adhering strictly to the MCP specification. The server supports JSON-RPC 2.0 for seamless communication and includes robust error handling to ensure reliable operation.

How to use MCP Calculator: Smart Automation & Custom Greetings?

Getting started is straightforward:

  1. Clone the repository and install dependencies via Go modules.
  2. Run the server to start listening on port 8080.
  3. Send JSON-RPC requests to execute tools (e.g., addition) or access resources (e.g., greetings).

Example commands include using curl to trigger calculations or generate greetings with custom parameters.

MCP Calculator Features

Key Features of MCP Calculator: Smart Automation & Custom Greetings?

  • Full JSON-RPC 2.0 support: Enables standardized communication between clients and the server.
  • Dynamic tool execution: Register and run pre-built tools (like mathematical operations) on demand.
  • Resource management: Access and manipulate server-side resources via structured requests.
  • Capability negotiation: Servers advertise their supported functions during initialization.
  • Secure by design: Enforces user consent, data privacy controls, and validated tool execution.

Use cases of MCP Calculator: Smart Automation & Custom Greetings?

Ideal scenarios include:

  • Automating repetitive tasks (e.g., real-time calculations in dashboards)
  • Generating personalized user experiences (e.g., tailored welcome messages)
  • Testing MCP protocol integrations with minimal setup
  • Building microservices requiring secure, protocol-compliant tool execution

MCP Calculator FAQ

FAQ from MCP Calculator: Smart Automation & Custom Greetings?

Q: What Go version is required?
A: Go 1.21+ ensures compatibility with modern language features and performance optimizations.

Q: How do I handle errors?
A: Responses follow JSON-RPC 2.0 error formats, including standardized codes and descriptive messages for troubleshooting.

Q: Can I extend this with custom tools?
A: Absolutely! The modular design allows adding new tools by implementing the MCP protocol interfaces.

Q: Is authentication supported?
A: While not included out-of-the-box, the protocol supports adding authentication layers via middleware.

Content

MCP Calculator

A Go implementation of a Model Context Protocol (MCP) server with calculator and greeting functionality. This implementation follows the official MCP specification.

Features

  • Full JSON-RPC 2.0 implementation
  • MCP protocol support
  • Tool registration and execution
  • Resource handling
  • Server capability negotiation
  • Error handling according to spec

Project Structure

mcpcalculator/
├── mcp/
│   └── protocol/
│       ├── types.go    # Protocol types and structures
│       ├── server.go   # MCP server implementation
│       └── client.go   # MCP client implementation
├── main.go            # Example usage
├── go.mod             # Go module file
└── README.md          # Documentation

Requirements

  • Go 1.21 or higher

Installation

git clone https://github.com/akhidasTech/mcpcalculator.git
cd mcpcalculator
go mod download

Usage

Starting the Server

go run main.go

The server will start on port 8080.

Making Requests

Tools and resources follow the JSON-RPC 2.0 specification:

Add Tool

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "add",
    "params": {"a": 5, "b": 3}
  }'

Greeting Resource

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "greeting",
    "params": {"name": "John"}
  }'

Response Format

All responses follow the JSON-RPC 2.0 format:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": <result_value>
}

Or for errors:

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": <error_code>,
        "message": "error message",
        "data": <additional_data>
    }
}

Protocol Implementation

This implementation follows the Model Context Protocol specification:

  1. JSON-RPC 2.0 : All communication uses the JSON-RPC 2.0 protocol
  2. Capabilities : Server advertises its capabilities during initialization
  3. Tools : Implements the tool registration and execution protocol
  4. Resources : Implements the resource access protocol
  5. Error Handling : Uses standard error codes and formats

Security

This implementation follows MCP security guidelines:

  1. User Consent : Tools and resources require explicit invocation
  2. Data Privacy : No data is shared without explicit requests
  3. Tool Safety : Tool execution is controlled and validated
  4. Error Handling : Proper error reporting and handling

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related MCP Servers & Clients