connect DEV to live MCP configuration and verify tool conformance

This commit is contained in:
2026-09-29 10:36:50 +01:00
parent 20bbbd26bd
commit 9592c9b274
16 changed files with 417 additions and 18 deletions
@@ -26,6 +26,15 @@ public final class LocalMcpServer implements AutoCloseable {
private ExecutorService executor;
private ScheduledExecutorService deadlines;
private volatile Connection connection;
private final java.util.List<Runnable> connectionListeners = new CopyOnWriteArrayList<>();
public p.studio.api.operation.OperationSubscription onConnectionChanged(Runnable listener) {
connectionListeners.add(listener); notifyConnectionListener(listener);
return () -> connectionListeners.remove(listener);
}
private static void notifyConnectionListener(Runnable listener) {
try { listener.run(); } catch (RuntimeException ignored) { /* Observation cannot change lifecycle. */ }
}
public LocalMcpServer(ObjectMapper mapper, McpToolRegistry tools) {
this.mapper = mapper.copy().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION)
@@ -47,6 +56,7 @@ public final class LocalMcpServer implements AutoCloseable {
next.setExecutor(workers);
next.start();
executor = workers; server = next;
connectionListeners.forEach(LocalMcpServer::notifyConnectionListener);
} catch (RuntimeException failure) {
next.stop(0); workers.shutdownNow(); timers.shutdownNow(); connection = null;
throw failure;
@@ -62,6 +72,7 @@ public final class LocalMcpServer implements AutoCloseable {
if (server == null) return;
connection = null; server.stop(0); server = null;
sessions.clear(); executor.shutdownNow(); deadlines.shutdownNow();
connectionListeners.forEach(LocalMcpServer::notifyConnectionListener);
}
/** Only explicit connection/configuration consumers may obtain the bearer token; never log it. */
@@ -144,7 +155,7 @@ public final class LocalMcpServer implements AutoCloseable {
var result = mapper.createObjectNode().put("protocolVersion", PROTOCOL_VERSION);
result.putObject("capabilities").putObject("tools").put("listChanged", false);
result.putObject("serverInfo").put("name", "prometeu-studio-mcp").put("version", "1.0");
result.put("instructions", "Read project context and indexed references. Human grant in DEV precedes acquisition. Edit saved project files with your native tools, never SDK/external libraries. Validate with LSP/build and explicitly release. Studio revocation does not stop your external file writes. Reconnect with new configuration after Studio restart.");
result.put("instructions", McpConnectionGuide.INSTRUCTIONS);
send(exchange, 200, response(id, result)); return;
}
if (initialized == null) { empty(exchange, 400); return; }