Skip to content

refactor: Remove hardcoded tool/resource/prompt counts from MCP startup log #53

@electather

Description

@electather

Problem / motivation

In cmd/mcp/serve.go, the MCP server startup log messages hardcode the number of tools, resources, and prompts:

mcpLog.Info("starting MCP server",
    "transport", "stdio",
    "tools", 46, "resources", 9, "prompts", 6,  // hardcoded
)

These values silently become stale whenever tools, resources, or prompts are added or removed. This has likely already drifted from the actual count.

Proposed solution

Either:

  1. Remove the counts entirely from the log message (simplest).
  2. Count dynamically if the mcp-go library exposes a way to query registered tools/resources/prompts from the MCPServer instance.
  3. Define constants next to the registration functions that are updated alongside tool additions (less ideal but better than inline magic numbers).

The counts appear in two places in serve.go (once for stdio, once for http transport).

Alternatives considered

Leave as-is — but this guarantees the log output will be wrong after the next tool addition, which undermines trust in the log messages.

Additional context

The hardcoded values appear on two separate log lines in runServe() — both need to be updated together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions