Class: ClaudeMemory::MCP::Server
- Inherits:
-
Object
- Object
- ClaudeMemory::MCP::Server
- Defined in:
- lib/claude_memory/mcp/server.rb
Overview
MCP JSON-RPC server over stdio. Reads newline-delimited JSON requests from input, dispatches to Tools, and writes JSON responses to output.
Constant Summary collapse
- PROTOCOL_VERSION =
"2024-11-05"
Instance Method Summary collapse
-
#initialize(store_or_manager, input: $stdin, output: $stdout) ⇒ Server
constructor
A new instance of Server.
-
#run ⇒ void
Start the read loop, blocking until input is exhausted or stop is called.
-
#stop ⇒ void
Signal the read loop to exit after the current message.
Constructor Details
#initialize(store_or_manager, input: $stdin, output: $stdout) ⇒ Server
Returns a new instance of Server.
21 22 23 24 25 26 27 28 |
# File 'lib/claude_memory/mcp/server.rb', line 21 def initialize(store_or_manager, input: $stdin, output: $stdout) @store_or_manager = store_or_manager @tools = Tools.new(store_or_manager) @telemetry = Telemetry.new(store_or_manager) @input = input @output = output @running = false end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Start the read loop, blocking until input is exhausted or stop is called.
32 33 34 35 36 37 38 39 40 |
# File 'lib/claude_memory/mcp/server.rb', line 32 def run @running = true while @running line = @input.gets break unless line (line.strip) end end |
#stop ⇒ void
This method returns an undefined value.
Signal the read loop to exit after the current message.
44 45 46 |
# File 'lib/claude_memory/mcp/server.rb', line 44 def stop @running = false end |