-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
61 lines (51 loc) · 1.31 KB
/
main.go
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
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"os"
mcpgolang "github.com/metoro-io/mcp-golang"
"github.com/metoro-io/mcp-golang/transport/stdio"
"github.com/metoro-io/metoro-mcp-server/resources"
"github.com/metoro-io/metoro-mcp-server/tools"
"github.com/metoro-io/metoro-mcp-server/utils"
)
func main() {
// Check if the appropriate environment variables are set
if err := checkEnvVars(); err != nil {
panic(err)
}
done := make(chan struct{})
mcpServer := mcpgolang.NewServer(stdio.NewStdioServerTransport())
// Add tools
for _, tool := range tools.MetoroToolsList {
err := mcpServer.RegisterTool(tool.Name, tool.Description, tool.Handler)
if err != nil {
panic(err)
}
}
// Add resources
for _, resource := range resources.MetoroResourcesList {
err := mcpServer.RegisterResource(
resource.Path,
resource.Name,
resource.Description,
resource.ContentType,
resource.Handler)
if err != nil {
panic(err)
}
}
err := mcpServer.Serve()
if err != nil {
panic(err)
}
<-done
}
func checkEnvVars() error {
if os.Getenv(utils.METORO_API_URL_ENV_VAR) == "" {
return fmt.Errorf("%s environment variable not set", utils.METORO_API_URL_ENV_VAR)
}
if os.Getenv(utils.METORO_AUTH_TOKEN_ENV_VAR) == "" {
return fmt.Errorf("%s environment variable not set", utils.METORO_AUTH_TOKEN_ENV_VAR)
}
return nil
}