-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
87 lines (73 loc) · 2.62 KB
/
Copy pathmain.go
File metadata and controls
87 lines (73 loc) · 2.62 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"flag"
"log"
"os"
"github.com/mark3labs/mcp-go/server"
"mcp-pb/tools"
)
var version = "undefined"
func main() {
mode := flag.String("mode", "http", "server mode: http or stdio")
parseableURL := flag.String("parseable-url", "", "base URL for Parseable instance (or set PARSEABLE_URL env var)")
parseableUserFlag := flag.String("parseable-username", "", "Parseable basic auth username (or set PARSEABLE_USER env var)")
parseablePassFlag := flag.String("parseable-password", "", "Parseable basic auth password (or set PARSEABLE_PASS env var)")
listenAddr := flag.String("listen", ":9034", "address to listen on")
versionFlag := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *versionFlag {
println("mcp-parseable-server " + version)
os.Exit(0)
}
// Prefer environment variables if set, otherwise use flags or defaults
tools.ParseableBaseURL = os.Getenv("PARSEABLE_URL")
if tools.ParseableBaseURL == "" {
if *parseableURL != "" {
tools.ParseableBaseURL = *parseableURL
} else {
tools.ParseableBaseURL = "http://localhost:8000"
}
}
tools.ParseableUser = os.Getenv("PARSEABLE_USERNAME")
if tools.ParseableUser == "" {
if *parseableUserFlag != "" {
tools.ParseableUser = *parseableUserFlag
} else {
tools.ParseableUser = "admin"
}
}
tools.ParseablePass = os.Getenv("PARSEABLE_PASSWORD")
if tools.ParseablePass == "" {
if *parseablePassFlag != "" {
tools.ParseablePass = *parseablePassFlag
} else {
tools.ParseablePass = "admin"
}
}
listenAddrEnv := os.Getenv("LISTEN_ADDR")
if listenAddrEnv != "" {
*listenAddr = listenAddrEnv
}
mcpServer := server.NewMCPServer("parseable-mcp", version,
server.WithRecovery(),
server.WithLogging(),
server.WithInstructions(`
You are Virtual Assistant, a tool for interacting with Parseable API and documentation in different tasks related to monitoring and observability.
You have many tools to get data from Parseable, but try to specify the query as accurately as possible.
Try not to second guess information - if you don't know something or lack information, it's better to ask.
`),
)
tools.RegisterParseableTools(mcpServer)
if *mode == "stdio" {
log.Printf("MCP server running in stdio mode (Parseable at %s)", tools.ParseableBaseURL)
if err := server.ServeStdio(mcpServer); err != nil {
log.Fatalf("MCP stdio server failed: %v", err)
}
return
}
httpServer := server.NewStreamableHTTPServer(mcpServer)
log.Printf("MCP server running on %s, Parseable at %s", *listenAddr, tools.ParseableBaseURL)
if err := httpServer.Start(*listenAddr); err != nil {
log.Fatalf("MCP server failed: %v", err)
}
}