Skip to content

Implement unit tests for MCP server #150

@bhf

Description

@bhf

As identified in #147, the MCP server (src/mcp-server.ts) currently lacks automated unit tests to verify tool definitions and request handlers.

Goal

Implement unit tests for the MCP server to ensure:

  • Tool registration is correct.
  • Resource listing/retrieval handlers correctly interface with the K8s library.
  • Error handling (e.g., K8s API failures) returns appropriate MCP error responses.

Scope

  • Use Vitest and the MCP SDK's testing utilities or mock StdioServerTransport to trigger and validate tool calls.
  • Mock src/lib/k8s.ts functions to decouple from actual Kubernetes API logic.

Acceptance Criteria

  • Create src/__tests__/mcp-server.test.ts.
  • Test the list_tools handler.
  • Test call handlers for at least 3 core tools (e.g., list_pods, get_pod_logs).
  • Validate error handling when the underlying K8s library throws.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions