About Example Go MCP Server
Example Go MCP Server is an MCP server published by slashben in the Developer Tools category: example implementation of a calculator MCP server in Golang. It has been installed 0 times through Conduid.
The repository has 1 stars and 0 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues (0) before depending on it in production.
Install
npx example-go-mcp-serverThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Example Go MCP Server
Powered by Claude · Grounded in docs
Security checks
- ·README presentNot checked yet.
- ·License declaredNot checked yet.
- ·Tests presentNot checked yet.
- ·Dependencies pinnedNot checked yet.
- ·No dynamic code executionNot checked yet.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
Example Go MCP Server
A simple Model Context Protocol (MCP) server that provides basic mathematical operations. This project is based on the mark3labs MCP Go library and Kubescape MCP implementation pattern and demonstrates how to create custom MCP tools.
Features
The server exposes four mathematical operation tools:
- add: Adds two numbers together
- sub: Subtracts the second number from the first
- mul: Multiplies two numbers together
- div: Divides the first number by the second (with zero division protection)
Project Structure
example-go-mcp-server/
├── cmd/
│ ├── root.go # Root command using Cobra
│ └── mcpserver.go # MCP server command
├── internal/
│ └── mcpserver/
│ └── server.go # Main MCP server implementation
├── main.go # Application entry point
├── go.mod # Go module file
└── README.md # This file
Installation
- Clone the repository:
git clone <repository-url>
cd example-go-mcp-server
- Install dependencies:
go mod tidy
- Build the application:
go build -o example-go-mcp-server
Usage
Running the MCP Server
Start the MCP server:
./example-go-mcp-server mcpserver
Or run directly with Go:
go run main.go mcpserver
Available Tools
The server provides the following tools that can be called via MCP:
Addition (add)
- Parameters:
a(required): First number to addb(required): Second number to add
- Example Response:
{
"operation": "addition",
"a": 5,
"b": 3,
"result": 8
}
Subtraction (sub)
- Parameters:
a(required): Number to subtract fromb(required): Number to subtract
- Example Response:
{
"operation": "subtraction",
"a": 10,
"b": 4,
"result": 6
}
Multiplication (mul)
- Parameters:
a(required): First number to multiplyb(required): Second number to multiply
- Example Response:
{
"operation": "multiplication",
"a": 6,
"b": 7,
"result": 42
}
Division (div)
- Parameters:
a(required): Number to be divided (dividend)b(required): Number to divide by (divisor)
- Example Response:
{
"operation": "division",
"a": 15,
"b": 3,
"result": 5
}
Development
Adding New Tools
To add a new mathematical operation:
- Add a new tool definition in
createMathTools()function - Add a case in the
CallTool()switch statement - Implement the handler function (e.g.,
handlePow()for power operation)
Error Handling
The server includes comprehensive error handling:
- Parameter validation
- Type conversion safety
- Division by zero protection
- JSON marshaling error handling
Logging
The server logs all MCP tool inputs and responses to a single file in the temp directory:
- Location:
{temp_dir}/example-go-mcp-server/mcp_server.log - Format: JSON lines with timestamp, operation, input, output, and error information
- Purpose: Debugging, monitoring, and audit trail
- Append Mode: All new log entries are appended to the same file
Dependencies
github.com/mark3labs/mcp-go: MCP protocol implementationgithub.com/spf13/cobra: CLI framework
License
This project is open source and available under the MIT License.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
References
This implementation is based on the Kubescape MCP server pattern:
README mirrored from the source repository 4 months ago. The original is authoritative.