Skip to content

Conversation

@intojhanurag
Copy link
Contributor

@intojhanurag intojhanurag commented Sep 17, 2025

This PR fixes #76 a bug where MCPServer resources that use cmd: npx (or uvx) stay in Unhealthy state unless spec.deployment.image is explicitly set.
Now, the controller correctly injects a default image (node:24-alpine3.21) during translation, and the status is updated to Healthy.

Screenshot 2025-09-17 114242

@intojhanurag intojhanurag force-pushed the fix/mcpserver-default-image-health branch from 565157d to 4394a4c Compare September 17, 2025 06:37
@intojhanurag
Copy link
Contributor Author

intojhanurag commented Sep 18, 2025

Hey @jmhbh @rinormaloku , this is ready for review

Copy link
Collaborator

@jmhbh jmhbh left a comment

Choose a reason for hiding this comment

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

Hey @intojhanurag sorry for the super late review. This slipped through the cracks for me.

log.FromContext(ctx).Info("MCPServer deployment not found", "name", server.Name)
setReadyCondition(server, false, kagentdevv1alpha1.MCPServerReasonPodsNotReady, "Deployment not found")
} else {
log.FromContext(ctx).Error(err, "Error getting MCPServer deployment", "name", server.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This log feels unnecessary given that we already write the error to the status

deploymentName := server.Name
if err := r.Get(ctx, client.ObjectKey{Name: deploymentName, Namespace: server.Namespace}, deployment); err != nil {
if client.IgnoreNotFound(err) == nil {
log.FromContext(ctx).Info("MCPServer deployment not found", "name", server.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This log feels unnecessary given that we already write the error to the status

// Check if deployment is available
// A deployment is considered ready when it has the desired number of available replicas
if deployment.Status.AvailableReplicas > 0 && deployment.Status.AvailableReplicas == deployment.Status.Replicas {
log.FromContext(ctx).Info("MCPServer status transitioned to Healthy",
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

} else {
message := fmt.Sprintf("Deployment not ready: %d/%d replicas available",
deployment.Status.AvailableReplicas, deployment.Status.Replicas)
log.FromContext(ctx).Info("MCPServer deployment not ready",
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

server *v1alpha1.MCPServer,
) (*appsv1.Deployment, error) {
image := server.Spec.Deployment.Image
originalImage := image
Copy link
Collaborator

Choose a reason for hiding this comment

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

just curious what the original intention with this change is? If this was a leftover change I think we can remove this and the conditional for this variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The originalImage variable is used to detect if an image was explicitly provided by the user or if a default was injected for uvx/npx. This allows the logs to show when a default image is being used, which is useful for debugging. Btw I removed this part.


// Set Accepted condition based on validation
if err := r.validateMCPServer(server); err != nil {
log.FromContext(ctx).Info("MCPServer validation failed", "name", server.Name, "error", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all the logs added here are not necessary as they are all reflected in the MCPServer status so I would remove them.


// Set Programmed condition based on reconcile result
if reconcileErr != nil {
log.FromContext(ctx).Error(reconcileErr, "MCPServer reconcile failed", "name", server.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

"Configuration validation failed",
)
} else {
log.FromContext(ctx).Info("MCPServer validation passed", "name", server.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

"Resources failed to be created",
)
} else {
log.FromContext(ctx).Info("MCPServer reconcile succeeded", "name", server.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

@intojhanurag intojhanurag force-pushed the fix/mcpserver-default-image-health branch from 7b76718 to 9e0a08a Compare November 13, 2025 16:37
…en pods ready; add logs

Signed-off-by: Anurag Ojha <aojharaj2004@gmail.com>
@intojhanurag intojhanurag force-pushed the fix/mcpserver-default-image-health branch from 9e0a08a to dfa3a59 Compare November 13, 2025 16:46
@intojhanurag
Copy link
Contributor Author

Hey @jmhbh , I applied the all suggestions . Feel free to take a look if you have a moment.

@jmhbh
Copy link
Collaborator

jmhbh commented Nov 17, 2025

@intojhanurag Thanks! looks good please remove the kind binary and then I'll merge this.

Signed-off-by: Anurag Ojha <aojharaj2004@gmail.com>
@intojhanurag intojhanurag force-pushed the fix/mcpserver-default-image-health branch from f33032c to fba8f91 Compare November 17, 2025 13:10
@intojhanurag
Copy link
Contributor Author

Hey @jmhbh , Feel free to take a look . I removed the binary file.

@jmhbh
Copy link
Collaborator

jmhbh commented Nov 17, 2025

thanks for your contribution @intojhanurag !

@jmhbh jmhbh merged commit 0296869 into kagent-dev:main Nov 17, 2025
6 checks passed
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.

MCPServer stays Unhealthy with uvx/npx unless image is explicitly set

2 participants