Skip to content

Commit

Permalink
Merge pull request #79 from mkouba/issue-77-console-log-revert
Browse files Browse the repository at this point in the history
stdio: redirect console logging to stderr
  • Loading branch information
mkouba authored Jan 21, 2025
2 parents b1eb2f4 + 06ec40a commit 74bafba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For instance, with Maven, add the following dependency to your POM file:
</dependency>
----

IMPORTANT: If you use the `stdio` transport then your app should not write anything to the standard output. Logging in the console is automatically disabled. And the standard output stream is set to "null" when the app is started by default.
IMPORTANT: If you use the `stdio` transport then your app should not write anything to the standard output. Quarkus console logging is automatically redirected to the standard error. And the standard output stream is set to "null" when the app is started by default.

If you want to use the https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse[HTTP/SSE] transport you'll need to add the `io.quarkiverse.mcp:quarkus-mcp-server-sse` extension to your build file first.
For instance, with Maven, add the following dependency to your POM file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.smallrye.config.SmallRyeConfigBuilderCustomizer;

/**
* Always disable console logging.
* Redirect console logging to {@code System#err} instead of {@code System#out}.
* <p>
* Originally, we tried to use the {@code RunTimeConfigurationDefaultBuildItem}. However, this build item has no effect unless a
* Quarkus version with <a href="https://github.com/quarkusio/quarkus/pull/45431">a fix</a> is used.
Expand All @@ -18,8 +18,10 @@ public class StdioConfigBuilderCustomizer implements SmallRyeConfigBuilderCustom
public void configBuilder(SmallRyeConfigBuilder builder) {
builder.withSources(
new PropertiesConfigSource(
Map.of("quarkus.log.console.enable", "false"),
"mcp-stdio-config-source", 500));
Map.of("quarkus.log.console.stderr", "true"),
"mcp-stdio-config-source",
// Keep the low ordinal so that users can override the config property
50));
}

}

0 comments on commit 74bafba

Please sign in to comment.