Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.
This repository was archived by the owner on May 18, 2026. It is now read-only.

test: MCP server initialization function lacks unit test coverage #108

@jongio

Description

@jongio

Summary

The runMCPServer() function in cli/src/cmd/exec/commands/mcp.go (lines 49-126) initializes the MCP server, registers all tool handlers, configures rate limiting, and starts the stdio transport. This function has zero direct test coverage.

Impact

  • Server initialization logic (tool registration order, rate limit config, capability flags) is untested
  • Regressions in server setup would only surface during manual or integration testing
  • The function contains ~75 lines of non-trivial setup logic including error handling branches

Details

What is tested:

  • Individual tool handlers (handleExecScript, handleExecInline, handleListShells, handleGetEnvironment) are well-tested in mcp_test.go
  • buildShellArgs and marshalExecResult have thorough table-driven tests

What is NOT tested:

  • Server builder configuration (lines 68-90): capability flags, server name/version
  • Tool registration (lines 92-119): correct tool names, descriptions, input schemas
  • Rate limiting setup (lines 85-87): rate limit values and behavior
  • Error path when ServeStdio fails (line 121-123)
  • The wiring between registered tool names and their handler functions

Recommendation

  1. Extract the server builder configuration into a testable helper that returns the configured server (without calling ServeStdio)
  2. Add unit tests that verify:
    • All expected tools are registered with correct names
    • Tool input schemas match expected structure
    • Server capabilities are correctly configured
  3. Consider adding a lightweight integration test using an in-memory MCP transport (if the azdext SDK supports it) to verify end-to-end tool dispatch

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedCreated by automationtest-healthTest suite health findings

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions