Skip to content

Add default resource limits to VirtualMCPServer vmcp container #2873

Closed

Description

@jhrozek

Summary

The vmcp container in VirtualMCPServer deployments is created without default CPU/memory resource limits.

Problem

Looking at cmd/thv-operator/controllers/virtualmcpserver_deployment.go, the container spec does not include a Resources field:

Containers: []corev1.Container{{
    Image:           getVmcpImage(),
    Name:            "vmcp",
    // ... other fields
    SecurityContext: containerSecurityContext,
    // Missing: Resources field
}},

Impact

Without resource limits:

  • A misbehaving or compromised vmcp container could consume excessive CPU/memory
  • Could cause node resource exhaustion affecting other workloads
  • Potential denial of service scenarios

Proposed Solution

Add default resource limits that users can override via PodTemplateSpec:

Resources: corev1.ResourceRequirements{
    Limits: corev1.ResourceList{
        corev1.ResourceCPU:    resource.MustParse("500m"),
        corev1.ResourceMemory: resource.MustParse("512Mi"),
    },
    Requests: corev1.ResourceList{
        corev1.ResourceCPU:    resource.MustParse("100m"),
        corev1.ResourceMemory: resource.MustParse("128Mi"),
    },
},

Notes

  • This is a pre-existing issue, not introduced by the PodTemplateSpec reconciliation fix
  • Users can already set resources via PodTemplateSpec, but having defaults would be safer
  • Consider also adding similar defaults to MCPServer deployments for consistency

Activity

  1. added
    enhancement
    on Dec 3, 2025
  2. added
    kubernetes
    on Dec 3, 2025
  3. added
    vmcp
    on Dec 3, 2025
  4. 4t8dd commented on Dec 4, 2025

    @4t8dd
    Contributor

    @jhrozek assign this to me.

  5. jhrozek commented on Dec 4, 2025

    @jhrozek
    ContributorAuthor

    @jhrozek assign this to me.

    done!

  6. 4t8dd commented on Dec 6, 2025

    @4t8dd
    Contributor

    @jhrozek When user define part value of resources, like either request or limit. Should we consider this case here? Or just all or nothing?

  7. jhrozek commented on Dec 8, 2025

    @jhrozek
    ContributorAuthor

    @jhrozek When user define part value of resources, like either request or limit. Should we consider this case here? Or just all or nothing?

    In general I would mirror what we do for MCPServer for now

  8. 4t8dd commented on Dec 12, 2025

    @4t8dd
    Contributor

    @jhrozek When user define part value of resources, like either request or limit. Should we consider this case here? Or just all or nothing?

    In general I would mirror what we do for MCPServer for now

    Actually the case for MCPServer is complicated. I need some time to figure this out.
    The vMCPServer is straight but for mcp server, it is managed by toolhive.
    When we have default resource, and with user's customization, then more cases will be present.

  9. 4t8dd commented on Dec 12, 2025

    @4t8dd
    Contributor

    Currently we have two possible resources, one from MCPServerSpec and the other from the podTemplateSpec. But the existing code just gives this to toolhive although in the spec saying it is for mc server.
    spec code: https://github.com/stacklok/toolhive/blob/main/cmd/thv-operator/api/v1alpha1/mcpserver_types.go#L106
    and controller: https://github.com/stacklok/toolhive/blob/main/cmd/thv-operator/controllers/mcpserver_controller.go#L1160

    This is wrong. We need to define the resource for toolhive too. toolhive here is like a manager it should have a resource scope,
    according to its workload, like hundreds of mcp server or just a few. This is different.

    I should make this clearer:

    For MCP server there two containers here:

    1. all the mcp servers
    2. the mcp managers, toolhive.
      The problem is not toolhive got no resources as container in k8s.
  10. 4t8dd commented on Dec 17, 2025

    @4t8dd
    Contributor

    @jhrozek please help review the PR for this issue.

  11. assigned and unassigned on Feb 6, 2026
  12. added 2 commits that reference this issue on Feb 6, 2026
    11ec5d6
    9206aa4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementkubernetesoperatorvmcp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions