Class: PostHog::MCP::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/posthog/mcp/options.rb

Overview

Note:

Experimental: option names may change in a future minor release.

Configuration for instrument.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil, report_missing: false, missing_capability_tool_name: nil, enable_conversation_id: false, enable_exception_autocapture: true, context: true, capture_model: false, identify: nil, intent_fallback: nil, before_send: nil, event_properties: nil) ⇒ Options

Returns a new instance of Options.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/posthog/mcp/options.rb', line 72

def initialize(logger: nil, report_missing: false, missing_capability_tool_name: nil,
               enable_conversation_id: false, enable_exception_autocapture: true, context: true,
               capture_model: false, identify: nil, intent_fallback: nil, before_send: nil,
               event_properties: nil)
  @logger = logger
  @report_missing = report_missing == true
  @missing_capability_tool_name = missing_capability_tool_name
  @enable_conversation_id = enable_conversation_id == true
  @enable_exception_autocapture = enable_exception_autocapture != false
  @context = normalize_context(context)
  @capture_model = normalize_model(capture_model)
  @identify = identify
  @intent_fallback = intent_fallback
  @before_send = before_send
  @event_properties = event_properties
end

Instance Attribute Details

#before_send ⇒ #call? (readonly)

Returns (payload) -> payload | nil; runs once per emitted payload, nil drops it.

Returns:

  • (#call, nil) —

    (payload) -> payload | nil; runs once per emitted payload, nil drops it.



68
69
70
# File 'lib/posthog/mcp/options.rb', line 68

def before_send
  @before_send
end

#capture_model ⇒ Boolean, ModelOptions (readonly)

Returns Capture $mcp_llm_model. Default false.

Returns:

  • (Boolean, ModelOptions) —

    Capture $mcp_llm_model. Default false.



62
63
64
# File 'lib/posthog/mcp/options.rb', line 62

def capture_model
  @capture_model
end

#context ⇒ Boolean, ContextOptions (readonly)

Returns Inject the required context argument. Default true.

Returns:

  • (Boolean, ContextOptions) —

    Inject the required context argument. Default true.



60
61
62
# File 'lib/posthog/mcp/options.rb', line 60

def context
  @context
end

#enable_conversation_id ⇒ Boolean (readonly)

Returns Inject conversation_id and anchor $session_id on it. Default false.

Returns:

  • (Boolean) —

    Inject conversation_id and anchor $session_id on it. Default false.



56
57
58
# File 'lib/posthog/mcp/options.rb', line 56

def enable_conversation_id
  @enable_conversation_id
end

#enable_exception_autocapture ⇒ Boolean (readonly)

Returns Emit a sibling $exception event for failed calls. Default true.

Returns:

  • (Boolean) —

    Emit a sibling $exception event for failed calls. Default true.



58
59
60
# File 'lib/posthog/mcp/options.rb', line 58

def enable_exception_autocapture
  @enable_exception_autocapture
end

#event_properties ⇒ #call? (readonly)

Returns (request, extra) -> Hash | nil, spread flat onto every auto-captured event.

Returns:

  • (#call, nil) —

    (request, extra) -> Hash | nil, spread flat onto every auto-captured event.



70
71
72
# File 'lib/posthog/mcp/options.rb', line 70

def event_properties
  @event_properties
end

#identify ⇒ #call, ... (readonly)

Returns (request, extra) -> UserIdentity | Hash | nil, or a static identity.

Returns:

  • (#call, UserIdentity, Hash, nil) —

    (request, extra) -> UserIdentity | Hash | nil, or a static identity.



64
65
66
# File 'lib/posthog/mcp/options.rb', line 64

def identify
  @identify
end

#intent_fallback ⇒ #call? (readonly)

Returns (request, extra) -> String | nil, consulted when no context arg was passed.

Returns:

  • (#call, nil) —

    (request, extra) -> String | nil, consulted when no context arg was passed.



66
67
68
# File 'lib/posthog/mcp/options.rb', line 66

def intent_fallback
  @intent_fallback
end

#logger ⇒ #call? (readonly)

Returns STDIO-safe log sink receiving single String messages. Default: no-op.

Returns:

  • (#call, nil) —

    STDIO-safe log sink receiving single String messages. Default: no-op.



50
51
52
# File 'lib/posthog/mcp/options.rb', line 50

def logger
  @logger
end

#missing_capability_tool_name ⇒ String (readonly)

Returns Name of the virtual tool. Default get_more_tools.

Returns:

  • (String) —

    Name of the virtual tool. Default get_more_tools.



54
55
56
# File 'lib/posthog/mcp/options.rb', line 54

def missing_capability_tool_name
  @missing_capability_tool_name
end

#report_missing ⇒ Boolean (readonly)

Returns Register the get_more_tools virtual tool. Default false.

Returns:

  • (Boolean) —

    Register the get_more_tools virtual tool. Default false.



52
53
54
# File 'lib/posthog/mcp/options.rb', line 52

def report_missing
  @report_missing
end

Instance Method Details

#capture_model_enabled? ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/posthog/mcp/options.rb', line 100

def capture_model_enabled?
  @capture_model != false
end

#context_description ⇒ String?

Returns:

  • (String, nil)


95
96
97
# File 'lib/posthog/mcp/options.rb', line 95

def context_description
  @context.is_a?(ContextOptions) ? @context.description : nil
end

#context_enabled? ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/posthog/mcp/options.rb', line 90

def context_enabled?
  @context != false
end

#model_description ⇒ String?

Returns:

  • (String, nil)


105
106
107
# File 'lib/posthog/mcp/options.rb', line 105

def model_description
  @capture_model.is_a?(ModelOptions) ? @capture_model.description : nil
end