Class: Mewmew::McpIntegration
- Inherits:
-
Object
- Object
- Mewmew::McpIntegration
- Defined in:
- lib/mewmew/mcp_integration.rb
Overview
Integrates Thor CLI with MCP server
Instance Attribute Summary collapse
-
#server_options ⇒ Object
readonly
Returns the value of attribute server_options.
-
#thor_class ⇒ Object
readonly
Returns the value of attribute thor_class.
Instance Method Summary collapse
-
#create_server ⇒ Object
Create an MCP server with Thor tools.
-
#initialize(thor_class, **server_options) ⇒ McpIntegration
constructor
A new instance of McpIntegration.
-
#serve ⇒ Object
Start the MCP stdio server.
Constructor Details
#initialize(thor_class, **server_options) ⇒ McpIntegration
Returns a new instance of McpIntegration.
15 16 17 18 |
# File 'lib/mewmew/mcp_integration.rb', line 15 def initialize(thor_class, **) @thor_class = thor_class = end |
Instance Attribute Details
#server_options ⇒ Object (readonly)
Returns the value of attribute server_options.
13 14 15 |
# File 'lib/mewmew/mcp_integration.rb', line 13 def end |
#thor_class ⇒ Object (readonly)
Returns the value of attribute thor_class.
13 14 15 |
# File 'lib/mewmew/mcp_integration.rb', line 13 def thor_class @thor_class end |
Instance Method Details
#create_server ⇒ Object
Create an MCP server with Thor tools
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mewmew/mcp_integration.rb', line 38 def create_server tools = ThorIntrospector.new(thor_class).to_mcp_tools MCP::Server.new( name: server_name, version: server_version, tools: tools, ** ) end |
#serve ⇒ Object
Start the MCP stdio server
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mewmew/mcp_integration.rb', line 21 def serve server = create_server transport = MCP::Server::Transports::StdioTransport.new(server) # Trap signals for graceful shutdown %w[INT TERM].each do |signal| Signal.trap(signal) do warn "\nShutting down MCP server..." transport.close exit(0) end end transport.open end |