Class: Mathpix::MCP::Server
- Inherits:
-
Object
- Object
- Mathpix::MCP::Server
- Defined in:
- lib/mathpix/mcp/server.rb
Overview
MCP Server for Mathpix OCR.
Uses the official Ruby MCP SDK. Provides 9 tools as thin delegates to Mathpix::Client over the stdio transport.
Instance Attribute Summary collapse
-
#mathpix_client ⇒ Object
readonly
Returns the value of attribute mathpix_client.
-
#mcp_server ⇒ Object
readonly
Returns the value of attribute mcp_server.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.run ⇒ Object
Class method: run server directly.
Instance Method Summary collapse
-
#capabilities ⇒ Hash
Server capabilities.
-
#create_stdio_transport ⇒ ::MCP::Server::Transports::StdioTransport
Create STDIO transport (standard MCP transport).
-
#initialize(name: 'mathpix', version: Mathpix::VERSION, mathpix_client: nil) ⇒ Server
constructor
Initialize MCP server.
-
#run ⇒ Object
Run MCP server with STDIO transport (blocking).
Constructor Details
#initialize(name: 'mathpix', version: Mathpix::VERSION, mathpix_client: nil) ⇒ Server
Initialize MCP server
53 54 55 56 57 58 |
# File 'lib/mathpix/mcp/server.rb', line 53 def initialize(name: 'mathpix', version: Mathpix::VERSION, mathpix_client: nil) @name = name @version = version @mathpix_client = mathpix_client || Mathpix.client @mcp_server = create_mcp_server end |
Instance Attribute Details
#mathpix_client ⇒ Object (readonly)
Returns the value of attribute mathpix_client.
46 47 48 |
# File 'lib/mathpix/mcp/server.rb', line 46 def mathpix_client @mathpix_client end |
#mcp_server ⇒ Object (readonly)
Returns the value of attribute mcp_server.
46 47 48 |
# File 'lib/mathpix/mcp/server.rb', line 46 def mcp_server @mcp_server end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/mathpix/mcp/server.rb', line 46 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
46 47 48 |
# File 'lib/mathpix/mcp/server.rb', line 46 def version @version end |
Class Method Details
.run ⇒ Object
Class method: run server directly
88 89 90 |
# File 'lib/mathpix/mcp/server.rb', line 88 def self.run(**) new(**).run end |
Instance Method Details
#capabilities ⇒ Hash
Server capabilities
78 79 80 81 82 |
# File 'lib/mathpix/mcp/server.rb', line 78 def capabilities { tools: tool_classes.map(&:name) } end |
#create_stdio_transport ⇒ ::MCP::Server::Transports::StdioTransport
Create STDIO transport (standard MCP transport)
63 64 65 |
# File 'lib/mathpix/mcp/server.rb', line 63 def create_stdio_transport ::MCP::Server::Transports::StdioTransport.new(@mcp_server) end |
#run ⇒ Object
Run MCP server with STDIO transport (blocking)
Standard way to run MCP server via stdio
70 71 72 73 |
# File 'lib/mathpix/mcp/server.rb', line 70 def run transport = create_stdio_transport transport.open end |