Class: ScoutApmMcp::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm_mcp/server.rb,
lib/scout_apm_mcp/server/base_tool.rb,
lib/scout_apm_mcp/server/null_logger.rb,
lib/scout_apm_mcp/server/tools/standard_tools.rb,
lib/scout_apm_mcp/server/tools/fetch_scout_url_tool.rb,
lib/scout_apm_mcp/server/tools/parse_scout_url_tool.rb,
lib/scout_apm_mcp/server/tools/fetch_openapi_schema_tool.rb

Overview

MCP Server for ScoutAPM integration

This server provides MCP tools for interacting with ScoutAPM API Usage: bundle exec scout_apm_mcp

Defined Under Namespace

Classes: BaseTool, FetchOpenAPISchemaTool, FetchScoutURLTool, FetchTraceTool, GetAllInsightsTool, GetAnomalyEventTool, GetAppTool, GetEndpointMetricsTool, GetErrorGroupErrorsTool, GetErrorGroupTool, GetInsightByTypeTool, GetInsightsHistoryByTypeTool, GetInsightsHistoryTool, GetJobMetricsTool, GetMetricTool, ListAnomalyEventsTool, ListAppsTool, ListEndpointTracesTool, ListEndpointsTool, ListErrorGroupsTool, ListJobMetricsTool, ListJobTracesTool, ListJobsTool, ListMetricsTool, NullLogger, ParseScoutURLTool

Constant Summary collapse

TOOL_CLASSES =
[
  ListAppsTool,
  GetAppTool,
  ListMetricsTool,
  GetMetricTool,
  ListEndpointsTool,
  GetEndpointMetricsTool,
  ListEndpointTracesTool,
  ListJobsTool,
  ListJobMetricsTool,
  GetJobMetricsTool,
  ListJobTracesTool,
  FetchTraceTool,
  ListErrorGroupsTool,
  GetErrorGroupTool,
  GetErrorGroupErrorsTool,
  ListAnomalyEventsTool,
  GetAnomalyEventTool,
  GetAllInsightsTool,
  GetInsightByTypeTool,
  GetInsightsHistoryTool,
  GetInsightsHistoryByTypeTool,
  ParseScoutURLTool,
  FetchScoutURLTool,
  FetchOpenAPISchemaTool
].freeze

Class Method Summary collapse

Class Method Details

.api_clientObject



48
49
50
# File 'lib/scout_apm_mcp/server.rb', line 48

def self.api_client
  @api_client ||= Client.new(api_key: Helpers.get_api_key)
end

.register_tools(server) ⇒ Object



79
80
81
# File 'lib/scout_apm_mcp/server.rb', line 79

def self.register_tools(server)
  TOOL_CLASSES.each { |tool_class| server.register_tool(tool_class) }
end

.startObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/scout_apm_mcp/server.rb', line 20

def self.start
  # Load 1Password credentials early if OP_ENV_ENTRY_PATH is set
  op_env_entry_path = ENV["OP_ENV_ENTRY_PATH"]
  if op_env_entry_path && !op_env_entry_path.empty?
    begin
      require "opdotenv"
      Opdotenv::Loader.load(op_env_entry_path)
    rescue LoadError
      # opdotenv not available, will fall back to op CLI in get_api_key
    rescue
      # Silently fail - will try other methods in get_api_key
    end
  end

  # Create server with null logger to prevent any output
  server = FastMcp::Server.new(
    name: "scout-apm",
    version: ScoutApmMcp::VERSION,
    logger: NullLogger.new
  )

  # Register all tools
  register_tools(server)

  # Start the server (blocks and speaks MCP over STDIN/STDOUT)
  server.start
end