Class: CovLoupe::MCPServer

Inherits:
Object
  • Object
show all
Defined in:
lib/cov_loupe/mcp_server.rb

Constant Summary collapse

TOOLSET =

Tool classes registered with the MCP server. Order determines listing in help output. File-scope tools require a path argument; project-scope tools do not.

[
  Tools::ProjectCoverageTool,
  Tools::FileCoverageDetailedTool,
  Tools::FileCoverageRawTool,
  Tools::FileCoverageSummaryTool,
  Tools::ProjectCoverageTotalsTool,
  Tools::FileUncoveredLinesTool,
  Tools::ProjectValidateTool,
  Tools::HelpTool,
  Tools::VersionTool,
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context: CovLoupe.context) ⇒ MCPServer

Returns a new instance of MCPServer.



16
17
18
# File 'lib/cov_loupe/mcp_server.rb', line 16

def initialize(context: CovLoupe.context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



52
53
54
# File 'lib/cov_loupe/mcp_server.rb', line 52

def context
  @context
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cov_loupe/mcp_server.rb', line 20

def run
  CovLoupe.with_context(context) do
    server = ::MCP::Server.new(
      name:           'cov-loupe',
      version:        CovLoupe::VERSION,
      tools:          toolset,
      instructions:   instructions,
      server_context: context
    )
    ::MCP::Server::Transports::StdioTransport.new(server).open
  end
end

#toolsetObject

Expose the registered tools so embedders can introspect without booting the server.



48
49
50
# File 'lib/cov_loupe/mcp_server.rb', line 48

def toolset
  TOOLSET
end