GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
21
Forks
0
Issues
0
Rational Calculator MCP Server
This project integrates a C++ rational number calculator with a Go-based Model Context Protocol (MCP) server. The Go server exposes the C++ calculator as an MCP tool, allowing other MCP-compatible clients, such as gemini_cli, to perform rational number arithmetic.
Project Structure
RationalSystem/: A Git submodule containing the C++ rational number calculator library.server/: Contains the Go MCP server implementation.Makefile: Provides commands for building both the C++ calculator and the Go server.
Features
- Rational Number Arithmetic: Utilizes a C++ library for precise calculations with rational numbers.
- Model Context Protocol (MCP) Integration: Exposes the calculator functionality as an MCP tool, enabling seamless integration with MCP-compatible systems like
gemini_cli. - Standard I/O Communication: The MCP server communicates via standard input/output (stdio)
- Simple Build Process: A
Makefilesimplifies the compilation and setup.
Getting Started
Prerequisites
- Go (version 1.24.5 or higher)
- C++ Compiler (g++ recommended)
- Git
Setup
Clone the repository:
git clone --recurse-submodules https://github.com/Socrad/rationalCalcServer.git cd rationalCalcServerIf you cloned without
--recurse-submodules, initialize and update the submodule:git submodule update --init --recursiveBuild the project:
TheMakefilewill compile both the C++ rational calculator and the Go MCP server.make allThis will create
server/rational_calculator(the C++ executable) andserver/mcp_server(the Go executable).
Integration with gemini_cli
This MCP server is designed to be integrated with gemini_cli as a custom tool. After building the mcp_server executable, you can configure gemini_cli's settings.json (or similar configuration file) to register this server as a tool provider.
Note: The exact configuration might vary based on your gemini_cli version and setup. Refer to gemini_cli documentation for precise tool registration details.
Once configured, the gemini_cli (and the underlying LLM) will be able to automatically invoke the rational_calculator tool for rational number operations.
Usage (MCP Tool)
Once the server is running and registered with an MCP client (like gemini_cli), you can interact with the rational_calculator tool. The tool expects three arguments: operand1 (string), operator (string), and operand2 (string).
Tool Name: rational_calculator
Description: Performs calculations with integers and rational numbers. Use this tool for everyday arithmetic and comparisons.
The tool will return the result of the operation as a string.
Cleaning Up
To remove the compiled binaries:
make clean
Dependencies
The rationalCalcServer project relies on the following external repositories and tools:
- RationalSystem: Provides the
Rationalclass andcalculator_main.cppfor rational number arithmetic and comparison operations. Licensed under the MIT License. - MCP Go SDK: Implements the Model Context Protocol (MCP) server to expose
calculator_main.cppoperations as tools for LLM clients. Licensed under the MIT License. - Go: Requires Go 1.18 or higher for building the MCP server.
- C++17 Compiler: Requires a C++17-compatible compiler (e.g., GCC, Clang) to build the
rational_calculatorexecutable. - CMake (optional): Used to build the
RationalSystemcomponents if included in the build process.
Acknowledgements
This project builds upon the following open-source contributions:
- RationalSystem: For the robust
Rationalclass implementation, developed with assistance from Google's Gemini. - Model Context Protocol (MCP): For the standardized protocol enabling LLM integration, maintained by Anthropic and the Go team.
License
Distributed under the MIT License. See LICENSE for more information.