Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20250630-125123.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: Allow the MCP Server to start with no OPSLEVEL_API_TOKEN so it can be inspected and tested. Tools will not work without a valid OpsLevel API token.
time: 2025-06-30T12:51:23.374588-07:00
11 changes: 8 additions & 3 deletions src/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ import (

func NewGraphClient(version string, options ...opslevel.Option) *opslevel.Client {
timeout := time.Second * time.Duration(viper.GetInt("api-timeout"))
api_token := viper.GetString("api-token")
options = append(
options,
opslevel.SetAPIToken(viper.GetString("api-token")),
opslevel.SetAPIToken(api_token),
opslevel.SetURL(viper.GetString("api-url")),
opslevel.SetTimeout(timeout),
opslevel.SetUserAgentExtra(fmt.Sprintf("mcp-%s", version)),
)
client := opslevel.NewGQLClient(options...)

clientErr := client.Validate()
Comment thread
derek-etherton-opslevel marked this conversation as resolved.
cobra.CheckErr(clientErr)
// If API token is provided, ensure it's valid in OpsLevel to notify the user.
// If no token is provided, just allow the server to start for inspection.
if api_token != "" {
clientErr := client.Validate()
cobra.CheckErr(clientErr)
}

return client
}
3 changes: 2 additions & 1 deletion src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ var rootCmd = &cobra.Command{

RunE: func(cmd *cobra.Command, args []string) error {
token := viper.GetString("api-token")
// Allow server to start even if token is missing
if token == "" {
return fmt.Errorf("no API token was found, use --api-token=XXX or the OPSLEVEL_API_TOKEN environment variable is required")
log.Warn().Msg("No API token was found. Tool requests will fail with 401 Unauthorized. Set an API token using --api-token=XXX or the OPSLEVEL_API_TOKEN environment variable.")
}

s := server.NewMCPServer(
Expand Down
Loading