A production-ready implementation of a Model Context Protocol (MCP) server written in Go. This server provides various utility tools accessible through the MCP protocol.
-
π§ 5 Useful Tools:
echo- Echo text with optional uppercase conversionreverse- Reverse any text string (supports Unicode)hash- Generate MD5 or SHA256 hashesuuid- Generate UUID v4 identifierstimestamp- Get current timestamps in various formats
-
π Bearer Token Authentication - Secure your server with API tokens
-
π³ Docker Support - Easy containerization
-
π§ͺ Full Test Coverage - Comprehensive unit tests
-
ποΈ Clean Architecture - Modular and maintainable code structure
-
βοΈ Configurable - Via command-line flags or environment variables
- Go 1.22+ or Docker
# Clone the repository
git clone https://github.com/podanypepa/mcpserver.git
cd mcpserver
# Install dependencies
go mod download
# Run the server
go run main.gomake help # Show all available commands
make run # Run the server
make test # Run tests
make build # Build binary# Build the image
docker build -t mcpserver .
# Run the container
docker run -p 8080:8080 -e MCP_TOKEN=secret123 mcpserverConfigure the server using command-line flags or environment variables:
| Flag | Environment Variable | Default | Description |
|---|---|---|---|
-addr |
MCP_ADDR |
:8080 |
HTTP listen address |
-token |
MCP_TOKEN |
"" |
Bearer token for authentication |
-path |
MCP_PATH |
/mcp |
Base path for MCP endpoints |
# With custom port and token
go run main.go -addr=":3000" -token="my-secret-token"
# Using environment variables
export MCP_TOKEN="my-secret-token"
export MCP_ADDR=":3000"
go run main.goEchoes text back, optionally in uppercase.
{
"method": "tools/call",
"params": {
"name": "echo",
"arguments": {
"text": "Hello, World!",
"uppercase": true
}
}
}Reverses any text string (Unicode-safe).
{
"method": "tools/call",
"params": {
"name": "reverse",
"arguments": {
"text": "Hello, World!"
}
}
}Generates MD5 or SHA256 hash.
{
"method": "tools/call",
"params": {
"name": "hash",
"arguments": {
"text": "Hello, World!",
"algorithm": "sha256"
}
}
}Generates a new UUID v4.
{
"method": "tools/call",
"params": {
"name": "uuid",
"arguments": {}
}
}Returns current timestamp in various formats.
{
"method": "tools/call",
"params": {
"name": "timestamp",
"arguments": {
"format": "RFC3339"
}
}
}Supported formats: RFC3339, Unix, UnixMilli
# Run tests
make test
# Run tests with coverage
make test-coverage
# View coverage in browser
open coverage.html# Format code
make fmt
# Run linter
make lint
# Install golangci-lint (if needed)
brew install golangci-lint
# Build binary
make buildThe send.sh script demonstrates how to interact with the server:
# Make sure the server is running
go run main.go -token="secret123"
# In another terminal, run the example script
./send.shYou can also use curl directly:
curl -X POST http://127.0.0.1:8080/mcp/messages \
-H 'Authorization: Bearer secret123' \
-H 'Content-Type: application/json' \
-H 'Mcp-Protocol-Version: 2025-06-18' \
--data '{
"jsonrpc":"2.0",
"id":1,
"method":"tools/call",
"params":{
"name":"echo",
"arguments":{"text":"Hello","uppercase":true}
}
}'.
βββ main.go # Application entry point
βββ tools/
β βββ tools.go # Tool implementations
β βββ tools_test.go # Tool tests
βββ Makefile # Build automation
βββ Dockerfile # Container definition
βββ .github/
β βββ workflows/
β βββ ci.yml # CI/CD pipeline
βββ README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with mcp-go by Mark3 Labs
- Inspired by the Model Context Protocol
Your Name - @podanypepa
Project Link: https://github.com/podanypepa/mcpserver