actionmcp 0.54.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f3d6323b7f8ce694050a031c566f30e33d637116e2869cda61fbbaad0702411
4
- data.tar.gz: ef8bfccea1b3109146b3e490340a44c4a6071e08c6aed3bd72ddecd5fd95638a
3
+ metadata.gz: 24a0298e6a7ed25d658bdb17c2161911a1c8e8ac199a5bd0e2b553a47e1d809f
4
+ data.tar.gz: 2066c3f6af2375dee54736d44f67b022c791c5b85cb7022cc1abd3ae6e9627f8
5
5
  SHA512:
6
- metadata.gz: 2665d85224ce5b07a115936d1f1d159b70c8068a8a221e2f196bebd9564b9e753a73acd15b86241b04d277e70dc6dc5db818fecda505cfab9beb999d8483aecb
7
- data.tar.gz: 56a568c5aca9693534a46d1013a9fdd8cb168a92e10b6c947dc02bb345f0c0a4f5b812edac990ddaa84c0ba589c500d47b7841f22b8542b1f36a120d2c8a1756
6
+ metadata.gz: 896039f7d34cae5e00d8e5c01717b12e4d806c2502f5cd6bf8da0a4d1556f30e90f26a4cddd0e7817d72d70443b94054f1071ad3bf40ab48f64e8be3a96e1927
7
+ data.tar.gz: a5a65421f027c10abcb0015ac8339ef06010c25a25c95eb24b7aba4f52504a813ee4105a10071ac68a66355671e0ee7894ca42a6785d67ccdfdc9f82f53163cd
data/README.md CHANGED
@@ -357,7 +357,7 @@ ActionMCP includes three session store implementations:
357
357
 
358
358
  ### Configuration
359
359
 
360
- You can configure the session store type in your Rails configuration:
360
+ You can configure the session store type in your Rails configuration or `config/mcp.yml`:
361
361
 
362
362
  ```ruby
363
363
  # config/application.rb or environment files
@@ -366,11 +366,34 @@ Rails.application.configure do
366
366
  end
367
367
  ```
368
368
 
369
+ Or in `config/mcp.yml`:
370
+
371
+ ```yaml
372
+ # Global session store type (used by both client and server)
373
+ session_store_type: volatile
374
+
375
+ # Client-specific session store type (falls back to session_store_type if not specified)
376
+ client_session_store_type: volatile
377
+
378
+ # Server-specific session store type (falls back to session_store_type if not specified)
379
+ server_session_store_type: active_record
380
+ ```
381
+
369
382
  The defaults are:
370
383
  - Production: `:active_record`
371
384
  - Development: `:volatile`
372
385
  - Test: `:volatile` (or `:test` when using TestHelper)
373
386
 
387
+ ### Separate Client and Server Session Stores
388
+
389
+ You can configure different session store types for client and server operations:
390
+
391
+ - **`session_store_type`**: Global setting used by both client and server when specific types aren't set
392
+ - **`client_session_store_type`**: Session store used by ActionMCP client connections (falls back to global setting)
393
+ - **`server_session_store_type`**: Session store used by ActionMCP server sessions (falls back to global setting)
394
+
395
+ This allows you to optimize each component separately. For example, you might use volatile storage for client sessions (faster, temporary) while using persistent storage for server sessions (maintains state across restarts).
396
+
374
397
  ### Using Different Session Stores
375
398
 
376
399
  ```ruby
@@ -4,17 +4,17 @@
4
4
  #
5
5
  # Table name: action_mcp_session_messages
6
6
  #
7
- # id :bigint not null, primary key
8
- # direction :string default("client"), not null
9
- # is_ping :boolean default(FALSE), not null
10
- # message_json :json
11
- # message_type :string not null
12
- # request_acknowledged :boolean default(FALSE), not null
13
- # request_cancelled :boolean default(FALSE), not null
14
- # created_at :datetime not null
15
- # updated_at :datetime not null
16
- # jsonrpc_id :string
17
- # session_id :string not null
7
+ # id :bigint not null, primary key
8
+ # direction(The message recipient) :string default("client"), not null
9
+ # is_ping(Whether the message is a ping) :boolean default(FALSE), not null
10
+ # message_json :json
11
+ # message_type(The type of the message) :string not null
12
+ # request_acknowledged :boolean default(FALSE), not null
13
+ # request_cancelled :boolean default(FALSE), not null
14
+ # created_at :datetime not null
15
+ # updated_at :datetime not null
16
+ # jsonrpc_id :string
17
+ # session_id :string not null
18
18
  #
19
19
  # Indexes
20
20
  #
@@ -22,7 +22,7 @@
22
22
  #
23
23
  # Foreign Keys
24
24
  #
25
- # fk_rails_... (session_id => action_mcp_sessions.id) ON DELETE => cascade ON UPDATE => cascade
25
+ # fk_action_mcp_session_messages_session_id (session_id => action_mcp_sessions.id) ON DELETE => cascade ON UPDATE => cascade
26
26
  #
27
27
  module ActionMCP
28
28
  class Session
@@ -4,28 +4,28 @@
4
4
  #
5
5
  # Table name: action_mcp_sessions
6
6
  #
7
- # id :string not null, primary key
8
- # authentication_method :string default("none")
9
- # client_capabilities :json
10
- # client_info :json
11
- # ended_at :datetime
12
- # initialized :boolean default(FALSE), not null
13
- # messages_count :integer default(0), not null
14
- # oauth_access_token :string
15
- # oauth_refresh_token :string
16
- # oauth_token_expires_at :datetime
17
- # oauth_user_context :json
18
- # prompt_registry :json
19
- # protocol_version :string
20
- # resource_registry :json
21
- # role :string default("server"), not null
22
- # server_capabilities :json
23
- # server_info :json
24
- # sse_event_counter :integer default(0), not null
25
- # status :string default("pre_initialize"), not null
26
- # tool_registry :json
27
- # created_at :datetime not null
28
- # updated_at :datetime not null
7
+ # id :string not null, primary key
8
+ # authentication_method :string default("none")
9
+ # client_capabilities(The capabilities of the client) :json
10
+ # client_info(The information about the client) :json
11
+ # ended_at(The time the session ended) :datetime
12
+ # initialized :boolean default(FALSE), not null
13
+ # messages_count :integer default(0), not null
14
+ # oauth_access_token :string
15
+ # oauth_refresh_token :string
16
+ # oauth_token_expires_at :datetime
17
+ # oauth_user_context :json
18
+ # prompt_registry :json
19
+ # protocol_version :string
20
+ # resource_registry :json
21
+ # role(The role of the session) :string default("server"), not null
22
+ # server_capabilities(The capabilities of the server) :json
23
+ # server_info(The information about the server) :json
24
+ # sse_event_counter :integer default(0), not null
25
+ # status :string default("pre_initialize"), not null
26
+ # tool_registry :json
27
+ # created_at :datetime not null
28
+ # updated_at :datetime not null
29
29
  #
30
30
  # Indexes
31
31
  #
@@ -20,16 +20,7 @@ module ActionMCP
20
20
  end
21
21
 
22
22
  def self.default_type
23
- # Ensure Rails is defined or provide a fallback if this code can run
24
- # outside a Rails environment.
25
- # Will refactor this soon
26
- if defined?(Rails) && Rails.env.test?
27
- :volatile # Use volatile for tests unless explicitly using :test
28
- elsif defined?(Rails) && Rails.env.production?
29
- :active_record
30
- else
31
- :volatile # Default for development or non-Rails environments
32
- end
23
+ ActionMCP.configuration.client_session_store_type
33
24
  end
34
25
  end
35
26
  end
@@ -41,6 +41,8 @@ module ActionMCP
41
41
  :gateway_class,
42
42
  # --- Session Store Options ---
43
43
  :session_store_type,
44
+ :client_session_store_type,
45
+ :server_session_store_type,
44
46
  # --- Pub/Sub and Thread Pool Options ---
45
47
  :adapter,
46
48
  :min_threads,
@@ -75,6 +77,8 @@ module ActionMCP
75
77
 
76
78
  # Session Store
77
79
  @session_store_type = Rails.env.production? ? :active_record : :volatile
80
+ @client_session_store_type = nil # defaults to session_store_type
81
+ @server_session_store_type = nil # defaults to session_store_type
78
82
  end
79
83
 
80
84
  def name
@@ -185,6 +189,16 @@ module ActionMCP
185
189
  capabilities
186
190
  end
187
191
 
192
+ # Get effective client session store type (falls back to global session_store_type)
193
+ def client_session_store_type
194
+ @client_session_store_type || @session_store_type
195
+ end
196
+
197
+ # Get effective server session store type (falls back to global session_store_type)
198
+ def server_session_store_type
199
+ @server_session_store_type || @session_store_type
200
+ end
201
+
188
202
  def apply_profile_options
189
203
  profile = @profiles[active_profile]
190
204
  return unless profile && profile[:options]
@@ -254,6 +268,15 @@ module ActionMCP
254
268
  if app_config["connects_to"]
255
269
  @connects_to = app_config["connects_to"]
256
270
  end
271
+
272
+ # Extract client and server session store types
273
+ if app_config["client_session_store_type"]
274
+ @client_session_store_type = app_config["client_session_store_type"].to_sym
275
+ end
276
+
277
+ if app_config["server_session_store_type"]
278
+ @server_session_store_type = app_config["server_session_store_type"].to_sym
279
+ end
257
280
  end
258
281
 
259
282
  def should_include_all?(type)
@@ -19,13 +19,7 @@ module ActionMCP
19
19
  end
20
20
 
21
21
  def self.default_type
22
- if Rails.env.test?
23
- :volatile # Use volatile for tests unless explicitly using :test
24
- elsif Rails.env.production?
25
- :active_record
26
- else
27
- :volatile
28
- end
22
+ ActionMCP.configuration.server_session_store_type
29
23
  end
30
24
  end
31
25
  end
@@ -31,7 +31,7 @@ module ActionMCP
31
31
  # Access the session store
32
32
  def session_store
33
33
  @session_store ||= SessionStoreFactory.create(
34
- ActionMCP.configuration.session_store_type
34
+ ActionMCP.configuration.server_session_store_type
35
35
  )
36
36
  end
37
37
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "gem_version"
4
4
  module ActionMCP
5
- VERSION = "0.54.0"
5
+ VERSION = "0.55.0"
6
6
 
7
7
  class << self
8
8
  alias version gem_version
@@ -6,6 +6,16 @@ shared:
6
6
  # Authentication configuration - array of methods to try in order
7
7
  authentication: ["none"] # No authentication required by default
8
8
 
9
+ # Session store configuration
10
+ # Global session store type used by both client and server (default: volatile in dev/test, active_record in production)
11
+ # session_store_type: volatile
12
+
13
+ # Client-specific session store type (falls back to session_store_type if not specified)
14
+ # client_session_store_type: volatile
15
+
16
+ # Server-specific session store type (falls back to session_store_type if not specified)
17
+ # server_session_store_type: active_record
18
+
9
19
  # OAuth configuration (if using OAuth authentication)
10
20
  # oauth:
11
21
  # provider: "demo_oauth_provider"
@@ -13,7 +23,7 @@ shared:
13
23
  # enable_dynamic_registration: true
14
24
  # enable_token_revocation: true
15
25
  # pkce_required: true
16
- # issuer_url: <%= ENV.fetch("OAUTH_ISSUER_URL") { "https://yourapp.com" } %>
26
+ # issuer_url: https://yourapp.com
17
27
 
18
28
  # MCP capability profiles
19
29
  profiles:
@@ -36,13 +46,20 @@ shared:
36
46
  options:
37
47
  list_changed: false
38
48
  logging_enabled: false
39
- logging_level: :warn
49
+ logging_level: warn
40
50
  resources_subscribe: false
41
51
 
42
52
  # Development environment
43
53
  development:
44
54
  # Use simple pub/sub adapter for development
45
55
  adapter: simple
56
+
57
+ # Session store examples for development
58
+ # Use volatile client sessions for faster development
59
+ # client_session_store_type: volatile
60
+ # Use persistent server sessions to maintain state across restarts
61
+ # server_session_store_type: active_record
62
+
46
63
  # Thread pool configuration (optional)
47
64
  # min_threads: 5 # Minimum number of threads in the pool
48
65
  # max_threads: 10 # Maximum number of threads in the pool
@@ -55,6 +72,9 @@ test:
55
72
 
56
73
  # Test adapter for testing
57
74
  adapter: test
75
+
76
+ # Use volatile sessions for testing (fast cleanup)
77
+ # session_store_type: volatile
58
78
 
59
79
  # Production environment
60
80
  production:
@@ -68,7 +88,7 @@ production:
68
88
  enable_dynamic_registration: true
69
89
  enable_token_revocation: true
70
90
  pkce_required: true
71
- issuer_url: <%= ENV.fetch("OAUTH_ISSUER_URL") { "https://yourapp.com" } %>
91
+ issuer_url: https://yourapp.com
72
92
 
73
93
  # Additional production profiles for external clients
74
94
  profiles:
@@ -77,6 +97,13 @@ production:
77
97
  prompts: []
78
98
  resources: []
79
99
 
100
+ # Production session store configuration
101
+ # Use persistent storage for production reliability
102
+ # session_store_type: active_record
103
+ # Or configure separately:
104
+ # client_session_store_type: active_record # Client connections persist across restarts
105
+ # server_session_store_type: active_record # Server state persists across deployments
106
+
80
107
  # Choose one of the following adapters:
81
108
 
82
109
  # 1. Database-backed adapter (recommended)
@@ -91,8 +118,8 @@ production:
91
118
 
92
119
  # 2. Redis-backed adapter (alternative)
93
120
  # adapter: redis
94
- # url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
95
- # channel_prefix: <%= Rails.application.class.module_parent_name.underscore %>_production
121
+ # url: redis://localhost:6379/1
122
+ # channel_prefix: my_mcp_app_production
96
123
  # min_threads: 10 # Minimum number of threads in the pool
97
124
  # max_threads: 20 # Maximum number of threads in the pool
98
125
  # max_queue: 500 # Maximum number of tasks that can be queued
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.54.0
4
+ version: 0.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih