|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "log" |
| 6 | + |
| 7 | + "github.com/davecgh/go-spew/spew" |
| 8 | + mcp_golang "github.com/metoro-io/mcp-golang" |
| 9 | + "github.com/metoro-io/mcp-golang/transport/http" |
| 10 | +) |
| 11 | + |
| 12 | +func main() { |
| 13 | + // Create an HTTP transport that connects to the server |
| 14 | + transport := http.NewHTTPClientTransport("/mcp") |
| 15 | + transport.WithBaseURL("http://localhost:8080/api/v1") |
| 16 | + // Public metoro token - not a leak |
| 17 | + transport.WithHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXN0b21lcklkIjoiOThlZDU1M2QtYzY4ZC00MDRhLWFhZjItNDM2ODllNWJiMGUzIiwiZW1haWwiOiJ0ZXN0QGNocmlzYmF0dGFyYmVlLmNvbSIsImV4cCI6MTgyMTI0NzIzN30.QeFzKsP1yO16pVol0mkAdt7qhJf6nTqBoqXqdWawBdE") |
| 18 | + |
| 19 | + // Create a new client with the transport |
| 20 | + client := mcp_golang.NewClient(transport) |
| 21 | + |
| 22 | + // Initialize the client |
| 23 | + if resp, err := client.Initialize(context.Background()); err != nil { |
| 24 | + log.Fatalf("Failed to initialize client: %v", err) |
| 25 | + } else { |
| 26 | + log.Printf("Initialized client: %v", spew.Sdump(resp)) |
| 27 | + } |
| 28 | + |
| 29 | + // List available tools |
| 30 | + tools, err := client.ListTools(context.Background(), nil) |
| 31 | + if err != nil { |
| 32 | + log.Fatalf("Failed to list tools: %v", err) |
| 33 | + } |
| 34 | + |
| 35 | + log.Println("Available Tools:") |
| 36 | + for _, tool := range tools.Tools { |
| 37 | + desc := "" |
| 38 | + if tool.Description != nil { |
| 39 | + desc = *tool.Description |
| 40 | + } |
| 41 | + log.Printf("Tool: %s. Description: %s", tool.Name, desc) |
| 42 | + } |
| 43 | + |
| 44 | + response, err := client.CallTool(context.Background(), "get_log_attributes", map[string]interface{}{}) |
| 45 | + if err != nil { |
| 46 | + log.Fatalf("Failed to call get_log_attributes tool: %v", err) |
| 47 | + } |
| 48 | + |
| 49 | + log.Printf("Response: %v", spew.Sdump(response)) |
| 50 | +} |
0 commit comments