-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (46 loc) · 1.18 KB
/
main.go
File metadata and controls
52 lines (46 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/serverscom/serverscom-mcp/internal/tools"
"github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
Name: "serverscom-mcp",
Usage: "MCP server for Servers.com infrastructure management",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "token",
Aliases: []string{"t"},
Usage: "Servers.com API token",
Sources: cli.EnvVars("SC_TOKEN"),
Required: true,
},
&cli.StringFlag{
Name: "endpoint",
Aliases: []string{"e"},
Usage: "Servers.com API endpoint",
Sources: cli.EnvVars("SC_ENDPOINT"),
Value: "https://api.servers.com/v1",
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
server := mcp.NewServer(&mcp.Implementation{
Name: "serverscom-mcp",
Version: Version,
}, nil)
tools.Register(server, cmd.String("token"), cmd.String("endpoint"), Version)
if err := server.Run(ctx, &mcp.StdioTransport{}); err != nil {
return fmt.Errorf("server error: %w", err)
}
return nil
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}