Skip to content

Commit c89f8b4

Browse files
committed
Add User-Agent header
1 parent b2912b2 commit c89f8b4

File tree

1 file changed

+4
-1
lines changed
  • src/servers/elasticsearch

1 file changed

+4
-1
lines changed

src/servers/elasticsearch/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use elasticsearch::auth::Credentials;
2525
use elasticsearch::cert::CertificateValidation;
2626
use elasticsearch::http::Url;
2727
use elasticsearch::http::response::Response;
28-
use http::header;
28+
use http::{header, HeaderName, HeaderValue};
2929
use http::request::Parts;
3030
use indexmap::IndexMap;
3131
use rmcp::RoleServer;
@@ -37,6 +37,7 @@ use serde_aux::field_attributes::deserialize_bool_from_anything;
3737
use std::borrow::Cow;
3838
use std::collections::HashMap;
3939
use std::sync::Arc;
40+
use http::header::USER_AGENT;
4041

4142
#[derive(Debug, Serialize, Deserialize)]
4243
pub 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

Comments
 (0)