Skip to content

Commit

Permalink
Merge pull request #60 from mkouba/issue-57
Browse files Browse the repository at this point in the history
Use DEBUG log level at runtime
  • Loading branch information
mkouba authored Jan 15, 2025
2 parents 3febd2e + aafaa37 commit 6a16bd4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void initializing(JsonObject message, Responder responder, McpConnection
String method = message.getString("method");
if (NOTIFICATIONS_INITIALIZED.equals(method)) {
if (connection.setInitialized()) {
LOG.infof("Client successfully initialized [%s]", connection.id());
LOG.debugf("Client successfully initialized [%s]", connection.id());
}
} else if (PING.equals(method)) {
ping(message, responder);
Expand Down Expand Up @@ -153,13 +153,13 @@ private void complete(JsonObject message, Responder responder, McpConnection con
private void ping(JsonObject message, Responder responder) {
// https://spec.modelcontextprotocol.io/specification/basic/utilities/ping/
Object id = message.getValue("id");
LOG.infof("Ping [id: %s]", id);
LOG.debugf("Ping [id: %s]", id);
responder.sendResult(id, new JsonObject());
}

private void close(JsonObject message, Responder responder, McpConnection connection) {
if (connectionManager.remove(connection.id())) {
LOG.infof("Connection %s closed", connection.id());
LOG.debugf("Connection %s closed", connection.id());
} else {
responder.sendError(message.getValue("id"), JsonRPC.INTERNAL_ERROR,
"Unable to obtain the connection to be closed:" + connection.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void promptComplete(Object id, JsonObject ref, JsonObject argument, Responder re
String promptName = ref.getString("name");
String argumentName = argument.getString("name");

LOG.infof("Complete prompt %s for argument %s [id: %s]", promptName, argumentName, id);
LOG.debugf("Complete prompt %s for argument %s [id: %s]", promptName, argumentName, id);

String key = promptName + "_" + argumentName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PromptMessageHandler {

void promptsList(JsonObject message, Responder responder) {
Object id = message.getValue("id");
LOG.infof("List prompts [id: %s]", id);
LOG.debugf("List prompts [id: %s]", id);
JsonArray prompts = new JsonArray();
for (FeatureMetadata<PromptResponse> resource : promptManager.list()) {
prompts.add(resource.asJson());
Expand All @@ -34,7 +34,7 @@ void promptsGet(JsonObject message, Responder responder, McpConnection connectio
Object id = message.getValue("id");
JsonObject params = message.getJsonObject("params");
String promptName = params.getString("name");
LOG.infof("Get prompt %s [id: %s]", promptName, id);
LOG.debugf("Get prompt %s [id: %s]", promptName, id);

ArgumentProviders argProviders = new ArgumentProviders(params.getJsonObject("arguments").getMap(), connection, id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ResourceMessageHandler {

void resourcesList(JsonObject message, Responder responder) {
Object id = message.getValue("id");
LOG.infof("List resources [id: %s]", id);
LOG.debugf("List resources [id: %s]", id);
JsonArray resources = new JsonArray();
for (FeatureMetadata<ResourceResponse> resource : resourceManager.list()) {
resources.add(resource.asJson());
Expand All @@ -40,7 +40,7 @@ void resourcesRead(JsonObject message, Responder responder, McpConnection connec
responder.sendError(id, JsonRPC.INVALID_PARAMS, "Resource URI not defined");
return;
}
LOG.infof("Read resource %s [id: %s]", resourceUri, id);
LOG.debugf("Read resource %s [id: %s]", resourceUri, id);

ArgumentProviders argProviders = new ArgumentProviders(Map.of("uri", resourceUri), connection, id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ResourceTemplateMessageHandler {

void resourceTemplatesList(JsonObject message, Responder responder) {
Object id = message.getValue("id");
LOG.infof("List resource templates [id: %s]", id);
LOG.debugf("List resource templates [id: %s]", id);
JsonArray resources = new JsonArray();
for (FeatureMetadata<ResourceResponse> resource : manager.list()) {
resources.add(resource.asJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ToolMessageHandler {

void toolsList(JsonObject message, Responder responder) {
Object id = message.getValue("id");
LOG.infof("List tools [id: %s]", id);
LOG.debugf("List tools [id: %s]", id);

JsonArray tools = new JsonArray();
for (FeatureMetadata<ToolResponse> toolMetadata : toolManager.list()) {
Expand Down Expand Up @@ -73,7 +73,7 @@ void toolsCall(JsonObject message, Responder responder, McpConnection connection
Object id = message.getValue("id");
JsonObject params = message.getJsonObject("params");
String toolName = params.getString("name");
LOG.infof("Call tool %s [id: %s]", toolName, id);
LOG.debugf("Call tool %s [id: %s]", toolName, id);

ArgumentProviders argProviders = new ArgumentProviders(params.getJsonObject("arguments").getMap(), connection, id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void handle(RoutingContext ctx) {

String id = Base64.getUrlEncoder().encodeToString(UUID.randomUUID().toString().getBytes());

LOG.infof("Client connection initialized [%s]", id);
LOG.debugf("Client connection initialized [%s]", id);

SseMcpConnection connection = new SseMcpConnection(id, response);
connectionManager.add(connection);
Expand Down Expand Up @@ -83,7 +83,7 @@ public void handle(Void event) {
closeHandler.handle(event);
}
if (connectionManager.remove(connectionId)) {
LOG.infof("Connection %s closed", connectionId);
LOG.debugf("Connection %s closed", connectionId);
}
// Connection may have been removed earlier...
}
Expand Down

0 comments on commit 6a16bd4

Please sign in to comment.