Skip to content

Commit 6ebccfa

Browse files
Add 'mcp' to mcp graphql UA (#400)
1 parent 8f3ee1d commit 6ebccfa

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/cmd/mcp.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package cmd
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67

78
"github.com/mark3labs/mcp-go/mcp"
89
"github.com/mark3labs/mcp-go/server"
10+
"github.com/opslevel/cli/common"
911
"github.com/rs/zerolog/log"
1012
"github.com/spf13/cobra"
1113
)
@@ -32,12 +34,13 @@ var mcpCmd = &cobra.Command{
3234
"1.0.0",
3335
)
3436

37+
client := common.NewGraphClient(fmt.Sprintf("mcp-%s", version))
38+
3539
// Register Teams
3640
s.AddTool(
3741
mcp.NewTool("teams",
3842
mcp.WithDescription("Get all the team names, identifiers and metadata for the opslevel account. Teams are owners of other objects in opslevel. Only use this if you need to search all teams.")),
3943
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
40-
client := getClientGQL()
4144
resp, err := client.ListTeams(nil)
4245
if err != nil {
4346
return nil, err
@@ -53,7 +56,6 @@ var mcpCmd = &cobra.Command{
5356
s.AddTool(
5457
mcp.NewTool("users", mcp.WithDescription("Get all the user names, e-mail addresses and metadata for the opslevel account. Users are the people in opslevel. Only use this if you need to search all users.")),
5558
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
56-
client := getClientGQL()
5759
resp, err := client.ListUsers(nil)
5860
if err != nil {
5961
return nil, err
@@ -69,7 +71,6 @@ var mcpCmd = &cobra.Command{
6971
s.AddTool(
7072
mcp.NewTool("actions", mcp.WithDescription("Get all the information about actions the user can run in the opslevel account")),
7173
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
72-
client := getClientGQL()
7374
resp, err := client.ListTriggerDefinitions(nil)
7475
if err != nil {
7576
return nil, err
@@ -85,7 +86,6 @@ var mcpCmd = &cobra.Command{
8586
s.AddTool(
8687
mcp.NewTool("filters", mcp.WithDescription("Get all the rubric filter names and which predicates they have for the opslevel account")),
8788
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
88-
client := getClientGQL()
8989
resp, err := client.ListFilters(nil)
9090
if err != nil {
9191
return nil, err
@@ -101,7 +101,6 @@ var mcpCmd = &cobra.Command{
101101
s.AddTool(
102102
mcp.NewTool("components", mcp.WithDescription("Get all the components in the opslevel account. Components are objects in opslevel that represent things like apis, libraries, services, frontends, backends, etc.")),
103103
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
104-
client := getClientGQL()
105104
resp, err := client.ListServices(nil)
106105
if err != nil {
107106
return nil, err
@@ -126,7 +125,6 @@ var mcpCmd = &cobra.Command{
126125
s.AddTool(
127126
mcp.NewTool("infrastructure", mcp.WithDescription("Get all the infrastructure in the opslevel account. Infrastructure are objects in opslevel that represent cloud provider resources like vpc, databases, caches, networks, vms, etc.")),
128127
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
129-
client := getClientGQL()
130128
resp, err := client.ListInfrastructure(nil)
131129
if err != nil {
132130
return nil, err
@@ -142,7 +140,6 @@ var mcpCmd = &cobra.Command{
142140
s.AddTool(
143141
mcp.NewTool("domains", mcp.WithDescription("Get all the domains in the opslevel account. Domains are objects in opslevel that represent a top-level abstraction used to organize and categorize software systems.")),
144142
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
145-
client := getClientGQL()
146143
resp, err := client.ListDomains(nil)
147144
if err != nil {
148145
return nil, err
@@ -158,7 +155,6 @@ var mcpCmd = &cobra.Command{
158155
s.AddTool(
159156
mcp.NewTool("systems", mcp.WithDescription("Get all the systems in the opslevel account. Systems are objects in opslevel that represent a grouping of services or components that act together to serve a business function or process.")),
160157
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
161-
client := getClientGQL()
162158
resp, err := client.ListSystems(nil)
163159
if err != nil {
164160
return nil, err

0 commit comments

Comments
 (0)