Class: Pinmark::Mcp::RackApp
- Inherits:
-
Object
- Object
- Pinmark::Mcp::RackApp
- Defined in:
- lib/pinmark/mcp/rack_app.rb
Overview
Rack-mountable adapter that exposes the pinmark server over the official ‘mcp` gem’s Streamable HTTP transport. Designed to be mounted inside a Rails router (or any Rack stack), so the standalone Puma process the gem ships is unnecessary.
This class deliberately avoids any Rails-app-specific references (controllers, Current attributes, etc.) so the entire Pinmark::Mcp namespace can later be extracted as a Rails engine / standalone gem.
Instance Method Summary collapse
-
#initialize(queue: Queue.new) ⇒ RackApp
constructor
Run the transport in stateless mode: every request stands on its own, no per-session state is held in memory.
Constructor Details
#initialize(queue: Queue.new) ⇒ RackApp
Run the transport in stateless mode: every request stands on its own, no per-session state is held in memory. This makes the mount resilient to Rails’ dev-mode code reloading (which can rebuild the mounted Rack instance) and keeps the in-process server cheap to operate. The annotation tools are simple request/response —they do not need streaming notifications.
23 24 25 26 27 28 29 30 31 |
# File 'lib/pinmark/mcp/rack_app.rb', line 23 def initialize(queue: Queue.new) @queue = queue @server = Server.build(queue: @queue) @transport = ::MCP::Server::Transports::StreamableHTTPTransport.new( @server, stateless: true, enable_json_response: true ) end |