Skip to content

Conversation

@naikmubashir
Copy link

Fixes #103

Description

This PR resolves issue #103 by making the DigitalOcean API token optional at server startup. The MCP server can now start successfully without a token and provides helpful error messages when API calls are made without proper authentication.

Changes Made

Core Server Changes

  • Modified cmd/mcp-digitalocean/main.go: Removed mandatory token validation during server initialization
  • Added warning message: Server displays clear warning when starting without token
  • Maintained backward compatibility: Existing token configurations work exactly as before

Documentation Updates

  • Updated README.md: Added "API Token Configuration" section explaining optional token behavior

Testing

Manual Testing

  • Server starts successfully without token (shows warning, doesn't exit)
  • Server starts normally with valid token
  • API calls without token provide helpful error messages
  • API calls with valid token work as expected
  • Backward compatibility maintained

Test Commands

# Server starts without token (shows warning)
npx @digitalocean/mcp --services apps
# Server works normally with token
DIGITALOCEAN_API_TOKEN=your_token npx @digitalocean/mcp --services apps
# Go binary works without token
go run ./cmd/mcp-digitalocean --services accounts

Signed-off-by: Naik Mubashir naikmubashir095@gmail.com

Signed-off-by: Naik Mubashir <naikmubashir095@gmail.com>
Signed-off-by: Naik Mubashir <naikmubashir095@gmail.com>
Comment on lines +63 to +69
if token == "" {
logger.Warn("DigitalOcean API token not provided. Server will start but API calls will fail until token is available. Use --digitalocean-api-token flag or set DIGITALOCEAN_API_TOKEN environment variable")
// Create a client with empty token - this will allow server to start but API calls will fail
client, err = newGodoClientWithTokenAndEndpoint(context.Background(), "", endpoint)
} else {
client, err = newGodoClientWithTokenAndEndpoint(context.Background(), token, endpoint)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if token == "" {
logger.Warn("DigitalOcean API token not provided. Server will start but API calls will fail until token is available. Use --digitalocean-api-token flag or set DIGITALOCEAN_API_TOKEN environment variable")
// Create a client with empty token - this will allow server to start but API calls will fail
client, err = newGodoClientWithTokenAndEndpoint(context.Background(), "", endpoint)
} else {
client, err = newGodoClientWithTokenAndEndpoint(context.Background(), token, endpoint)
}
if token == "" {
logger.Warn("DigitalOcean API token not provided. Server will start but API calls will fail until token is available. Use --digitalocean-api-token flag or set DIGITALOCEAN_API_TOKEN environment variable")
}
client, err := newGodoClientWithTokenAndEndpoint(context.Background(), token, endpoint)

This should have the same outcome with lesser nesting.

@thearyanahmed
Copy link
Contributor

As per the conflict, we want to handle both scenarios, http and stdio transports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the server load without the DO Token

2 participants