@@ -65,7 +65,12 @@ const ConfigSchema = z
6565 . string ( )
6666 . optional ( )
6767 . describe ( "Path to custom CA certificate for Elasticsearch" ) ,
68-
68+
69+ sslSkipVerify : z
70+ . boolean ( )
71+ . optional ( )
72+ . describe ( "Skip SSL certificate verification" ) ,
73+
6974 pathPrefix : z
7075 . string ( )
7176 . optional ( )
@@ -104,7 +109,7 @@ export async function createElasticsearchMcpServer(
104109 config : ElasticsearchConfig
105110) {
106111 const validatedConfig = ConfigSchema . parse ( config ) ;
107- const { url, apiKey, username, password, caCert, pathPrefix } = validatedConfig ;
112+ const { url, apiKey, username, password, caCert, sslSkipVerify , pathPrefix } = validatedConfig ;
108113
109114 const clientOptions : ClientOptions = {
110115 node : url ,
@@ -127,10 +132,11 @@ export async function createElasticsearchMcpServer(
127132 }
128133
129134 // Set up SSL/TLS certificate if provided
135+ clientOptions . tls = { } ;
130136 if ( caCert ) {
131137 try {
132138 const ca = fs . readFileSync ( caCert ) ;
133- clientOptions . tls = { ca } ;
139+ clientOptions . tls . ca = ca ;
134140 } catch ( error ) {
135141 console . error (
136142 `Failed to read certificate file: ${
@@ -140,6 +146,11 @@ export async function createElasticsearchMcpServer(
140146 }
141147 }
142148
149+ // Skip verification if requested
150+ if ( sslSkipVerify ) {
151+ clientOptions . tls . rejectUnauthorized = false ;
152+ }
153+
143154 const esClient = new Client ( clientOptions ) ;
144155
145156 const server = new McpServer ( {
@@ -456,6 +467,7 @@ const config: ElasticsearchConfig = {
456467 username : process . env . ES_USERNAME || "" ,
457468 password : process . env . ES_PASSWORD || "" ,
458469 caCert : process . env . ES_CA_CERT || "" ,
470+ sslSkipVerify : process . env . ES_SSL_SKIP_VERIFY === "1" || process . env . ES_SSL_SKIP_VERIFY === "true" ,
459471 pathPrefix : process . env . ES_PATH_PREFIX || "" ,
460472} ;
461473
0 commit comments