A Go implementation of a Model Context Protocol (MCP) server with calculator and greeting functionality. This implementation follows the official MCP specification.
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
git clone https://github.com/akhidasTech/mcpcalculator.git
cd mcpcalculator
go mod download
go run main.go
The server will start on port 8080.
Tools and resources follow the JSON-RPC 2.0 specification:
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "add",
"params": {"a": 5, "b": 3}
}'
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "greeting",
"params": {"name": "John"}
}'
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>
}
}
This implementation follows the Model Context Protocol specification:
This implementation follows MCP security guidelines:
Contributions are welcome! Please feel free to submit a Pull Request.
A Go implementation of MCP server with calculator and greeting functionality
No releases published
No packages published