first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 21:52:23 +03:00
commit 880f412e2c
2662 changed files with 866266 additions and 0 deletions

View File

@@ -0,0 +1,158 @@
# Go Test Server
A test MCP server written in Go that provides string manipulation, JSON validation, UUID generation, hashing, and encoding/decoding tools.
## Tools
### 1. string_transform
Performs string transformations.
**Parameters:**
- `input` (string, required): The input string to transform
- `operation` (string, required): Operation to perform - "uppercase", "lowercase", "reverse", "title"
**Example:**
```json
{
"input": "hello world",
"operation": "uppercase"
}
```
**Response:**
```json
{
"input": "hello world",
"operation": "uppercase",
"result": "HELLO WORLD"
}
```
### 2. json_validate
Validates if a string is valid JSON.
**Parameters:**
- `json_string` (string, required): The JSON string to validate
**Example:**
```json
{
"json_string": "{\"name\": \"test\"}"
}
```
**Response:**
```json
{
"valid": true,
"parsed": {"name": "test"}
}
```
### 3. uuid_generate
Generates a random UUID v4.
**Parameters:** None
**Response:**
```json
{
"uuid": "550e8400-e29b-41d4-a716-446655440000"
}
```
### 4. hash
Computes hash of input string.
**Parameters:**
- `input` (string, required): The input string to hash
- `algorithm` (string, required): Hash algorithm - "md5", "sha256", "sha512"
**Example:**
```json
{
"input": "hello",
"algorithm": "sha256"
}
```
**Response:**
```json
{
"input": "hello",
"algorithm": "sha256",
"hash": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}
```
### 5. encode
Encodes input string.
**Parameters:**
- `input` (string, required): The input string to encode
- `encoding` (string, required): Encoding type - "base64", "hex", "url"
**Example:**
```json
{
"input": "hello world",
"encoding": "base64"
}
```
**Response:**
```json
{
"input": "hello world",
"encoding": "base64",
"encoded": "aGVsbG8gd29ybGQ="
}
```
### 6. decode
Decodes encoded string.
**Parameters:**
- `input` (string, required): The encoded input string to decode
- `encoding` (string, required): Encoding type - "base64", "hex", "url"
**Example:**
```json
{
"input": "aGVsbG8gd29ybGQ=",
"encoding": "base64"
}
```
**Response:**
```json
{
"input": "aGVsbG8gd29ybGQ=",
"encoding": "base64",
"decoded": "hello world"
}
```
## Build and Run
```bash
# Build
go build -o bin/go-test-server
# Run
./bin/go-test-server
```
## Usage in Tests
```go
config := schemas.MCPClientConfig{
ID: "go-test-server",
Name: "GoTestServer",
ConnectionType: schemas.MCPConnectionTypeSTDIO,
StdioConfig: &schemas.MCPStdioConfig{
Command: "/path/to/bin/go-test-server",
Args: []string{},
},
}
```

View File

@@ -0,0 +1,19 @@
module github.com/maximhq/bifrost/examples/mcps/go-test-server
go 1.26.2
require (
github.com/google/uuid v1.6.0
github.com/mark3labs/mcp-go v0.43.2
)
require (
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@@ -0,0 +1,39 @@
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mark3labs/mcp-go v0.43.2 h1:21PUSlWWiSbUPQwXIJ5WKlETixpFpq+WBpbMGDSVy/I=
github.com/mark3labs/mcp-go v0.43.2/go.mod h1:YnJfOL382MIWDx1kMY+2zsRHU/q78dBg9aFb8W6Thdw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -0,0 +1,381 @@
package main
import (
"context"
"crypto/md5"
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"net/url"
"os"
"strings"
"github.com/google/uuid"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)
func main() {
// Create MCP server
s := server.NewMCPServer(
"go-test-server",
"1.0.0",
server.WithToolCapabilities(true),
)
// Register all tools
registerStringTransformTool(s)
registerJSONValidateTool(s)
registerUUIDGenerateTool(s)
registerHashTool(s)
registerEncodeTool(s)
registerDecodeTool(s)
// Start STDIO server
if err := server.ServeStdio(s); err != nil {
fmt.Fprintf(os.Stderr, "Server error: %v\n", err)
os.Exit(1)
}
}
// ============================================================================
// TOOL 1: string_transform
// ============================================================================
func registerStringTransformTool(s *server.MCPServer) {
tool := mcp.NewTool("string_transform",
mcp.WithDescription("Performs string transformations: uppercase, lowercase, reverse, title"),
mcp.WithString("input",
mcp.Required(),
mcp.Description("The input string to transform"),
),
mcp.WithString("operation",
mcp.Required(),
mcp.Description("The operation to perform"),
mcp.Enum("uppercase", "lowercase", "reverse", "title"),
),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var args struct {
Input string `json:"input"`
Operation string `json:"operation"`
}
// Get arguments using the proper method
argsInterface := request.GetArguments()
// Marshal and unmarshal to convert to our struct
argsBytes, err := json.Marshal(argsInterface)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil
}
if err := json.Unmarshal(argsBytes, &args); err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Invalid arguments: %v", err)), nil
}
var result string
switch args.Operation {
case "uppercase":
result = strings.ToUpper(args.Input)
case "lowercase":
result = strings.ToLower(args.Input)
case "reverse":
runes := []rune(args.Input)
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
result = string(runes)
case "title":
result = strings.Title(strings.ToLower(args.Input))
default:
return mcp.NewToolResultError(fmt.Sprintf("Unknown operation: %s", args.Operation)), nil
}
response := map[string]string{
"input": args.Input,
"operation": args.Operation,
"result": result,
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}
// ============================================================================
// TOOL 2: json_validate
// ============================================================================
func registerJSONValidateTool(s *server.MCPServer) {
tool := mcp.NewTool("json_validate",
mcp.WithDescription("Validates if a string is valid JSON"),
mcp.WithString("json_string",
mcp.Required(),
mcp.Description("The JSON string to validate"),
),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var args struct {
JSONString string `json:"json_string"`
}
// Get arguments using the proper method
argsInterface := request.GetArguments()
// Marshal and unmarshal to convert to our struct
argsBytes, err := json.Marshal(argsInterface)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil
}
if err := json.Unmarshal(argsBytes, &args); err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Invalid arguments: %v", err)), nil
}
var jsonData interface{}
err = json.Unmarshal([]byte(args.JSONString), &jsonData)
response := map[string]interface{}{
"valid": err == nil,
}
if err != nil {
response["error"] = err.Error()
} else {
response["parsed"] = jsonData
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}
// ============================================================================
// TOOL 3: uuid_generate
// ============================================================================
func registerUUIDGenerateTool(s *server.MCPServer) {
tool := mcp.NewTool("uuid_generate",
mcp.WithDescription("Generates a random UUID v4"),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
id := uuid.New()
response := map[string]string{
"uuid": id.String(),
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}
// ============================================================================
// TOOL 4: hash
// ============================================================================
func registerHashTool(s *server.MCPServer) {
tool := mcp.NewTool("hash",
mcp.WithDescription("Computes hash of input string using specified algorithm"),
mcp.WithString("input",
mcp.Required(),
mcp.Description("The input string to hash"),
),
mcp.WithString("algorithm",
mcp.Required(),
mcp.Description("The hash algorithm to use"),
mcp.Enum("md5", "sha256", "sha512"),
),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var args struct {
Input string `json:"input"`
Algorithm string `json:"algorithm"`
}
// Get arguments using the proper method
argsInterface := request.GetArguments()
// Marshal and unmarshal to convert to our struct
argsBytes, err := json.Marshal(argsInterface)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil
}
if err := json.Unmarshal(argsBytes, &args); err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Invalid arguments: %v", err)), nil
}
var hashResult string
switch args.Algorithm {
case "md5":
hash := md5.Sum([]byte(args.Input))
hashResult = hex.EncodeToString(hash[:])
case "sha256":
hash := sha256.Sum256([]byte(args.Input))
hashResult = hex.EncodeToString(hash[:])
case "sha512":
hash := sha512.Sum512([]byte(args.Input))
hashResult = hex.EncodeToString(hash[:])
default:
return mcp.NewToolResultError(fmt.Sprintf("Unknown algorithm: %s", args.Algorithm)), nil
}
response := map[string]string{
"input": args.Input,
"algorithm": args.Algorithm,
"hash": hashResult,
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}
// ============================================================================
// TOOL 5: encode
// ============================================================================
func registerEncodeTool(s *server.MCPServer) {
tool := mcp.NewTool("encode",
mcp.WithDescription("Encodes input string using specified encoding"),
mcp.WithString("input",
mcp.Required(),
mcp.Description("The input string to encode"),
),
mcp.WithString("encoding",
mcp.Required(),
mcp.Description("The encoding to use"),
mcp.Enum("base64", "hex", "url"),
),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var args struct {
Input string `json:"input"`
Encoding string `json:"encoding"`
}
// Get arguments using the proper method
argsInterface := request.GetArguments()
// Marshal and unmarshal to convert to our struct
argsBytes, err := json.Marshal(argsInterface)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil
}
if err := json.Unmarshal(argsBytes, &args); err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Invalid arguments: %v", err)), nil
}
var encoded string
switch args.Encoding {
case "base64":
encoded = base64.StdEncoding.EncodeToString([]byte(args.Input))
case "hex":
encoded = hex.EncodeToString([]byte(args.Input))
case "url":
encoded = url.QueryEscape(args.Input)
default:
return mcp.NewToolResultError(fmt.Sprintf("Unknown encoding: %s", args.Encoding)), nil
}
response := map[string]string{
"input": args.Input,
"encoding": args.Encoding,
"encoded": encoded,
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}
// ============================================================================
// TOOL 6: decode
// ============================================================================
func registerDecodeTool(s *server.MCPServer) {
tool := mcp.NewTool("decode",
mcp.WithDescription("Decodes input string using specified encoding"),
mcp.WithString("input",
mcp.Required(),
mcp.Description("The encoded input string to decode"),
),
mcp.WithString("encoding",
mcp.Required(),
mcp.Description("The encoding to use for decoding"),
mcp.Enum("base64", "hex", "url"),
),
)
s.AddTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var args struct {
Input string `json:"input"`
Encoding string `json:"encoding"`
}
// Get arguments using the proper method
argsInterface := request.GetArguments()
// Marshal and unmarshal to convert to our struct
argsBytes, err := json.Marshal(argsInterface)
if err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Failed to marshal arguments: %v", err)), nil
}
if err := json.Unmarshal(argsBytes, &args); err != nil {
return mcp.NewToolResultError(fmt.Sprintf("Invalid arguments: %v", err)), nil
}
var decoded string
var decodeErr error
switch args.Encoding {
case "base64":
decodedBytes, err := base64.StdEncoding.DecodeString(args.Input)
if err != nil {
decodeErr = err
} else {
decoded = string(decodedBytes)
}
case "hex":
decodedBytes, err := hex.DecodeString(args.Input)
if err != nil {
decodeErr = err
} else {
decoded = string(decodedBytes)
}
case "url":
var err error
decoded, err = url.QueryUnescape(args.Input)
if err != nil {
decodeErr = err
}
default:
return mcp.NewToolResultError(fmt.Sprintf("Unknown encoding: %s", args.Encoding)), nil
}
if decodeErr != nil {
return mcp.NewToolResultError(fmt.Sprintf("Decode error: %v", decodeErr)), nil
}
response := map[string]string{
"input": args.Input,
"encoding": args.Encoding,
"decoded": decoded,
}
jsonResult, _ := json.Marshal(response)
return mcp.NewToolResultText(string(jsonResult)), nil
})
}