Class: Textus::MCP::Server
- Inherits:
-
Object
- Object
- Textus::MCP::Server
- Defined in:
- lib/textus/mcp/server.rb
Overview
Stdio JSON-RPC 2.0 server speaking MCP draft 2024-11-05. One line per message (NDJSON). Holds a single Session for the lifetime of stdin.
Constant Summary collapse
- PROTOCOL_VERSION =
"2024-11-05"- SERVER_INFO =
{ "name" => "textus", "version" => Textus::VERSION }.freeze
Instance Method Summary collapse
-
#initialize(store:, stdin: $stdin, stdout: $stdout, role: Textus::Role::DEFAULT) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(store:, stdin: $stdin, stdout: $stdout, role: Textus::Role::DEFAULT) ⇒ Server
Returns a new instance of Server.
12 13 14 15 16 17 18 |
# File 'lib/textus/mcp/server.rb', line 12 def initialize(store:, stdin: $stdin, stdout: $stdout, role: Textus::Role::DEFAULT) @store = store @stdin = stdin @stdout = stdout @role = role @session = nil end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/textus/mcp/server.rb', line 20 def run @stdin.each_line do |line| line = line.strip next if line.empty? handle_line(line) end end |