Add server diagnostics to initialize response
serverInfo now includes: - hostname and ipAddress for server identification - javaVersion and javaVendor for environment info - serverStartTime (epoch ms) for uptime calculation - moquiVersion, runtimePath for deployment verification - currentUser/currentUserId for auth confirmation Follows MCP standard - info returned via initialize response
Showing
2 changed files
with
35 additions
and
3 deletions
| ... | @@ -132,10 +132,42 @@ | ... | @@ -132,10 +132,42 @@ |
| 132 | logging: [:] | 132 | logging: [:] |
| 133 | ] | 133 | ] |
| 134 | 134 | ||
| 135 | // Build server info | 135 | // Build server info with useful metadata |
| 136 | def moquiVersion = ec.factory.moquiVersion ?: "Unknown" | ||
| 137 | def runtimePath = ec.factory.runtimePath ?: "Unknown" | ||
| 138 | |||
| 139 | // Get hostname and IP | ||
| 140 | def hostname = "Unknown" | ||
| 141 | def ipAddress = "Unknown" | ||
| 142 | try { | ||
| 143 | def localhost = java.net.InetAddress.getLocalHost() | ||
| 144 | hostname = localhost.getHostName() | ||
| 145 | ipAddress = localhost.getHostAddress() | ||
| 146 | } catch (Exception e) { /* ignore */ } | ||
| 147 | |||
| 148 | // Get Java/JVM info | ||
| 149 | def javaVersion = System.getProperty("java.version") ?: "Unknown" | ||
| 150 | def javaVendor = System.getProperty("java.vendor") ?: "Unknown" | ||
| 151 | |||
| 152 | // Get server start time from Runtime MXBean | ||
| 153 | def serverStartTime = null | ||
| 154 | try { | ||
| 155 | def runtimeMXBean = java.lang.management.ManagementFactory.getRuntimeMXBean() | ||
| 156 | serverStartTime = runtimeMXBean.getStartTime() | ||
| 157 | } catch (Exception e) { /* ignore */ } | ||
| 158 | |||
| 136 | def serverInfo = [ | 159 | def serverInfo = [ |
| 137 | name: "Moqui MCP Server", | 160 | name: "Moqui MCP Server", |
| 138 | version: "2.0.1" | 161 | version: "2.0.2", |
| 162 | moquiVersion: moquiVersion, | ||
| 163 | hostname: hostname, | ||
| 164 | ipAddress: ipAddress, | ||
| 165 | javaVersion: javaVersion, | ||
| 166 | javaVendor: javaVendor, | ||
| 167 | serverStartTime: serverStartTime, | ||
| 168 | runtimePath: runtimePath, | ||
| 169 | currentUser: ec.user?.username, | ||
| 170 | currentUserId: ec.user?.userId | ||
| 139 | ] | 171 | ] |
| 140 | 172 | ||
| 141 | result = [ | 173 | result = [ | ... | ... |
| ... | @@ -201,7 +201,7 @@ class EnhancedMcpServlet extends HttpServlet { | ... | @@ -201,7 +201,7 @@ class EnhancedMcpServlet extends HttpServlet { |
| 201 | logger.debug("About to call handleJsonRpc with visit: ${visit?.visitId}") | 201 | logger.debug("About to call handleJsonRpc with visit: ${visit?.visitId}") |
| 202 | handleJsonRpc(request, response, ec, webappName, requestBody, visit) | 202 | handleJsonRpc(request, response, ec, webappName, requestBody, visit) |
| 203 | } else if ("GET".equals(method) && (requestURI.equals("/mcp") || requestURI.endsWith("/mcp"))) { | 203 | } else if ("GET".equals(method) && (requestURI.equals("/mcp") || requestURI.endsWith("/mcp"))) { |
| 204 | // Handle GET requests to /mcp - maybe for server info or SSE fallback | 204 | // Handle GET requests to /mcp - SSE connection for streaming |
| 205 | handleSseConnection(request, response, ec, webappName) | 205 | handleSseConnection(request, response, ec, webappName) |
| 206 | } else { | 206 | } else { |
| 207 | // Fallback to JSON-RPC handling | 207 | // Fallback to JSON-RPC handling | ... | ... |
-
Please register or sign in to post a comment