@@ -25,7 +25,7 @@ use elasticsearch::auth::Credentials;
2525use elasticsearch:: cert:: CertificateValidation ;
2626use elasticsearch:: http:: Url ;
2727use elasticsearch:: http:: response:: Response ;
28- use http:: header;
28+ use http:: { header, HeaderName , HeaderValue } ;
2929use http:: request:: Parts ;
3030use indexmap:: IndexMap ;
3131use rmcp:: RoleServer ;
@@ -37,6 +37,7 @@ use serde_aux::field_attributes::deserialize_bool_from_anything;
3737use std:: borrow:: Cow ;
3838use std:: collections:: HashMap ;
3939use std:: sync:: Arc ;
40+ use http:: header:: USER_AGENT ;
4041
4142#[ derive( Debug , Serialize , Deserialize ) ]
4243pub struct ElasticsearchMcpConfig {
@@ -191,6 +192,7 @@ impl ElasticsearchMcp {
191192 }
192193
193194 pub fn new_with_config ( config : ElasticsearchMcpConfig ) -> anyhow:: Result < base_tools:: EsBaseTools > {
195+ eprintln ! ( "ES config: {:#?}" , config) ;
194196 let creds = if let Some ( api_key) = config. api_key . clone ( ) {
195197 Some ( Credentials :: EncodedApiKey ( api_key) )
196198 } else if let Some ( login) = config. login . clone ( ) {
@@ -210,6 +212,7 @@ impl ElasticsearchMcp {
210212 if config. ssl_skip_verify {
211213 transport = transport. cert_validation ( CertificateValidation :: None )
212214 }
215+ transport = transport. header ( USER_AGENT , HeaderValue :: from_str ( & format ! ( "elastic-mcp/{}" , env!( "CARGO_PKG_VERSION" ) ) ) ?) ;
213216 let transport = transport. build ( ) ?;
214217 let es_client = Elasticsearch :: new ( transport) ;
215218
0 commit comments