Class: TypeGuessr::MCP::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/type_guessr/mcp/server.rb

Overview

MCP server that exposes type-guessr’s inference engine as tools. Indexes the target project on startup and serves type queries via stdio transport.

Usage:

server = TypeGuessr::MCP::Server.new(project_path: "/path/to/project")
server.start

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path:) ⇒ Server

Returns a new instance of Server.

Parameters:

  • project_path (String)

    Path to the Ruby project to analyze



33
34
35
36
# File 'lib/type_guessr/mcp/server.rb', line 33

def initialize(project_path:)
  @project_path = File.expand_path(project_path)
  @runtime = nil
end

Instance Attribute Details

#runtimeStandaloneRuntime (readonly)

Returns The runtime used for inference (available after #start).

Returns:



30
31
32
# File 'lib/type_guessr/mcp/server.rb', line 30

def runtime
  @runtime
end

Instance Method Details

#startObject

Build index and start the MCP server (blocks on stdio transport)



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/type_guessr/mcp/server.rb', line 39

def start
  warn "[type-guessr] Initializing for project: #{@project_path}"

  index = build_ruby_index
  @runtime = build_runtime(index)
  index_project_files
  start_file_watcher

  server = ::MCP::Server.new(
    name: "type-guessr",
    version: TypeGuessr::VERSION,
    tools: build_tools
  )

  warn "[type-guessr] Server ready"
  transport = ::MCP::Server::Transports::StdioTransport.new(server)
  transport.open
end