78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/rails_pg_extras/mcp_app.rb', line 78
def self.build
app = lambda do |_env|
[200, { "Content-Type" => "text/html" },
["<html><body><h1>Hello from Rack!</h1><p>This is a simple Rack app with MCP middleware.</p></body></html>"]]
end
mcp_app = FastMcp.rack_middleware(
app,
name: "rails-pg-extras", version: ::VERSION,
path_prefix: "/pg-extras-mcp",
logger: Logger.new($stdout),
) do |server|
server.register_tools(DiagnoseTool)
server.register_tools(MissingFkConstraintsTool)
server.register_tools(MissingFkIndexesTool)
server.register_tools(*QUERY_TOOL_CLASSES)
server.register_resource(ReadmeResource)
Rack::Builder.new { run mcp_app }
end
end
|