/*
* Copyright (C) 2025 Christian Schmitt, Tim Frey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.iunera.druidmcpserver.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.modelcontextprotocol.client.transport.ServerParameters;
import io.modelcontextprotocol.client.transport.StdioClientTransport;
import io.modelcontextprotocol.json.jackson.JacksonMcpJsonMapper;
import java.io.File;
/**
* With stdio transport, the Druid MCP server is automatically started by the client.
* But you have to build the server jar first:
*
* <pre>
* ./mvnw clean install -DskipTests
* </pre>
*/
public class DruidClientStdio {
public static void main(String[] args) {
System.out.println(new File(".").getAbsolutePath());
var stdioParams = ServerParameters.builder("java")
.args("-Dspring.ai.mcp.server.stdio=true", "-Dspring.main.web-application-type=none",
"-Dlogging.pattern.console=", "-jar",
"target/druid-mcp-server-1.2.1.jar")
.build();
var transport = new StdioClientTransport(stdioParams, new JacksonMcpJsonMapper(new ObjectMapper()));
new DruidSampleClient(transport).run();
}
}