This is an automated email from the ASF dual-hosted git repository.

piotr pushed a commit to branch mcp
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/mcp by this push:
     new d36fdc3d default config file
d36fdc3d is described below

commit d36fdc3dabd2021a5da452fcb91b3797e8593477
Author: spetz <[email protected]>
AuthorDate: Fri Jul 18 21:48:20 2025 +0200

    default config file
---
 Cargo.lock                                         | 115 +++++++++++++++++----
 core/ai/mcp/Cargo.toml                             |   2 +-
 core/ai/mcp/config.toml                            |  11 +-
 core/ai/mcp/src/configs.rs                         |  56 ++++++++--
 core/ai/mcp/src/main.rs                            |  28 +++--
 core/integration/Cargo.toml                        |   8 ++
 core/integration/src/lib.rs                        |   2 +
 .../integration/src/{lib.rs => test_mcp_server.rs} |  12 ---
 core/integration/{src/lib.rs => tests/mcp/mod.rs}  |  19 ++--
 core/integration/tests/mod.rs                      |   1 +
 10 files changed, 183 insertions(+), 71 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 42c71f1f..c498c2b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1097,7 +1097,7 @@ version = "3.6.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "40d1dad34aa19bf02295382f08d9bc40651585bd497266831d40ee6296fb49ca"
 dependencies = [
- "darling",
+ "darling 0.20.11",
  "ident_case",
  "prettyplease",
  "proc-macro2",
@@ -1921,8 +1921,18 @@ version = "0.20.11"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
 dependencies = [
- "darling_core",
- "darling_macro",
+ "darling_core 0.20.11",
+ "darling_macro 0.20.11",
+]
+
+[[package]]
+name = "darling"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "a79c4acb1fd5fa3d9304be4c76e031c54d2e92d172a393e24b19a14fe8532fe9"
+dependencies = [
+ "darling_core 0.21.0",
+ "darling_macro 0.21.0",
 ]
 
 [[package]]
@@ -1939,13 +1949,38 @@ dependencies = [
  "syn 2.0.104",
 ]
 
+[[package]]
+name = "darling_core"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "74875de90daf30eb59609910b84d4d368103aaec4c924824c6799b28f77d6a1d"
+dependencies = [
+ "fnv",
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn 2.0.104",
+]
+
 [[package]]
 name = "darling_macro"
 version = "0.20.11"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
 dependencies = [
- "darling_core",
+ "darling_core 0.20.11",
+ "quote",
+ "syn 2.0.104",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "e79f8e61677d5df9167cd85265f8e5f64b215cdea3fb55eebc3e622e44c7a146"
+dependencies = [
+ "darling_core 0.21.0",
  "quote",
  "syn 2.0.104",
 ]
@@ -2053,7 +2088,7 @@ version = "0.20.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
 dependencies = [
- "darling",
+ "darling 0.20.11",
  "proc-macro2",
  "quote",
  "syn 2.0.104",
@@ -4233,6 +4268,7 @@ dependencies = [
  "log",
  "predicates",
  "rcgen",
+ "rmcp",
  "serial_test",
  "server",
  "tempfile",
@@ -5214,6 +5250,26 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "oauth2"
+version = "5.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d"
+dependencies = [
+ "base64 0.21.7",
+ "chrono",
+ "getrandom 0.2.16",
+ "http 1.3.1",
+ "rand 0.8.5",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "serde_path_to_error",
+ "sha2",
+ "thiserror 1.0.69",
+ "url",
+]
+
 [[package]]
 name = "objc2-core-foundation"
 version = "0.3.1"
@@ -5921,6 +5977,20 @@ dependencies = [
  "yansi",
 ]
 
+[[package]]
+name = "process-wrap"
+version = "8.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "a3ef4f2f0422f23a82ec9f628ea2acd12871c81a9362b02c43c1aa86acfc3ba1"
+dependencies = [
+ "futures",
+ "indexmap 2.9.0",
+ "nix",
+ "tokio",
+ "tracing",
+ "windows 0.61.3",
+]
+
 [[package]]
 name = "prokio"
 version = "0.1.0"
@@ -6513,9 +6583,9 @@ dependencies = [
 
 [[package]]
 name = "rmcp"
-version = "0.2.1"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "37f2048a81a7ff7e8ef6bc5abced70c3d9114c8f03d85d7aaaafd9fd04f12e9e"
+checksum = "b008b927a85d514699ff304be84c5084598596e6cad4a6f5bc67207715fafe5f"
 dependencies = [
  "axum 0.8.4",
  "base64 0.22.1",
@@ -6525,11 +6595,14 @@ dependencies = [
  "http 1.3.1",
  "http-body",
  "http-body-util",
+ "oauth2",
  "paste",
  "pin-project-lite",
+ "process-wrap",
  "rand 0.9.1",
+ "reqwest",
  "rmcp-macros",
- "schemars 0.8.22",
+ "schemars 1.0.4",
  "serde",
  "serde_json",
  "sse-stream",
@@ -6539,16 +6612,17 @@ dependencies = [
  "tokio-util",
  "tower-service",
  "tracing",
+ "url",
  "uuid",
 ]
 
 [[package]]
 name = "rmcp-macros"
-version = "0.2.1"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "72398e694b9f6dbb5de960cf158c8699e6a1854cb5bbaac7de0646b2005763c4"
+checksum = "7465280d5f73f2c5c99017a04af407b2262455a149f255ad22f2b0b29087695c"
 dependencies = [
- "darling",
+ "darling 0.21.0",
  "proc-macro2",
  "quote",
  "serde_json",
@@ -6862,34 +6936,35 @@ dependencies = [
 
 [[package]]
 name = "schemars"
-version = "0.8.22"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615"
+checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f"
 dependencies = [
- "chrono",
  "dyn-clone",
- "schemars_derive",
+ "ref-cast",
  "serde",
  "serde_json",
 ]
 
 [[package]]
 name = "schemars"
-version = "0.9.0"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f"
+checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
 dependencies = [
+ "chrono",
  "dyn-clone",
  "ref-cast",
+ "schemars_derive",
  "serde",
  "serde_json",
 ]
 
 [[package]]
 name = "schemars_derive"
-version = "0.8.22"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d"
+checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -7095,7 +7170,7 @@ version = "3.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "81679d9ed988d5e9a5e6531dc3f2c28efbd639cbd1dfb628df08edea6004da77"
 dependencies = [
- "darling",
+ "darling 0.20.11",
  "proc-macro2",
  "quote",
  "syn 2.0.104",
diff --git a/core/ai/mcp/Cargo.toml b/core/ai/mcp/Cargo.toml
index d81bf7f0..c50ed9c8 100644
--- a/core/ai/mcp/Cargo.toml
+++ b/core/ai/mcp/Cargo.toml
@@ -9,7 +9,7 @@ config = { workspace = true }
 dotenvy = { workspace = true }
 figlet-rs = { workspace = true }
 iggy = { workspace = true }
-rmcp = { version = "0.2.1", features = [
+rmcp = { version = "0.3.0", features = [
     "server",
     "transport-io",
     "transport-sse-server",
diff --git a/core/ai/mcp/config.toml b/core/ai/mcp/config.toml
index fcadb8fe..a29f30ef 100644
--- a/core/ai/mcp/config.toml
+++ b/core/ai/mcp/config.toml
@@ -17,22 +17,21 @@
 
 transport = "stdio"
 
-[http_api] # Optional HTTP API configuration
+[http] # Optional HTTP API configuration
 address = "127.0.0.1:8082"
 path = "/mcp"
-# api_key = "secret" # Optional API key for authentication to be passed as 
`api-key` header
 
-[http_api.tls] # Optional TLS configuration for HTTP API
+[http.tls] # Optional TLS configuration for HTTP API
 enabled = false
-cert_file = "core/certs/iggy_cert.pem"
-key_file = "core/certs/iggy_key.pem"
+cert = "core/certs/iggy_cert.pem"
+key = "core/certs/iggy_key.pem"
 
 [iggy]
 address = "localhost:8090"
 username = "iggy"
 password = "iggy"
 # token = "secret" # Personal Access Token (PAT) can be used instead of 
username and password
-# consumer_name = "iggy-mcp" # Optional consumer name
+# consumer = "iggy-mcp" # Optional consumer name
 
 [permissions]
 create = true
diff --git a/core/ai/mcp/src/configs.rs b/core/ai/mcp/src/configs.rs
index 3dc1eb98..6243239f 100644
--- a/core/ai/mcp/src/configs.rs
+++ b/core/ai/mcp/src/configs.rs
@@ -16,12 +16,13 @@
  * under the License.
  */
 
+use iggy::prelude::{DEFAULT_ROOT_PASSWORD, DEFAULT_ROOT_USERNAME};
 use serde::{Deserialize, Serialize};
 use strum::Display;
 
 #[derive(Debug, Clone, Deserialize, Serialize)]
 pub struct McpServerConfig {
-    pub http_api: Option<HttpApiConfig>,
+    pub http: Option<HttpApiConfig>,
     pub iggy: IggyConfig,
     pub permissions: PermissionsConfig,
     pub transport: McpTransport,
@@ -33,14 +34,13 @@ pub struct IggyConfig {
     pub username: Option<String>,
     pub password: Option<String>,
     pub token: Option<String>,
-    pub consumer_name: Option<String>,
+    pub consumer: Option<String>,
 }
 
 #[derive(Debug, Clone, Deserialize, Serialize)]
 pub struct HttpApiConfig {
     pub address: String,
     pub path: String,
-    pub api_key: Option<String>,
     pub tls: Option<HttpTlsConfig>,
 }
 
@@ -52,11 +52,11 @@ pub struct PermissionsConfig {
     pub delete: bool,
 }
 
-#[derive(Debug, Deserialize, Serialize, Clone)]
+#[derive(Debug, Default, Deserialize, Serialize, Clone)]
 pub struct HttpTlsConfig {
     pub enabled: bool,
-    pub cert_file: String,
-    pub key_file: String,
+    pub cert: String,
+    pub key: String,
 }
 
 #[derive(Clone, Copy, Debug, Default, Display, PartialEq, Eq, Serialize, 
Deserialize)]
@@ -69,3 +69,47 @@ pub enum McpTransport {
     #[strum(to_string = "stdio")]
     Stdio,
 }
+
+impl Default for McpServerConfig {
+    fn default() -> Self {
+        Self {
+            http: Some(HttpApiConfig::default()),
+            iggy: IggyConfig::default(),
+            permissions: PermissionsConfig::default(),
+            transport: McpTransport::Http,
+        }
+    }
+}
+
+impl Default for IggyConfig {
+    fn default() -> Self {
+        Self {
+            address: "localhost:8090".to_owned(),
+            username: Some(DEFAULT_ROOT_USERNAME.to_owned()),
+            password: Some(DEFAULT_ROOT_PASSWORD.to_owned()),
+            token: None,
+            consumer: None,
+        }
+    }
+}
+
+impl Default for HttpApiConfig {
+    fn default() -> Self {
+        Self {
+            address: "localhost:8082".to_owned(),
+            path: "/mcp".to_owned(),
+            tls: None,
+        }
+    }
+}
+
+impl Default for PermissionsConfig {
+    fn default() -> Self {
+        Self {
+            create: true,
+            read: true,
+            update: true,
+            delete: true,
+        }
+    }
+}
diff --git a/core/ai/mcp/src/main.rs b/core/ai/mcp/src/main.rs
index b0badc7d..95d4f83b 100644
--- a/core/ai/mcp/src/main.rs
+++ b/core/ai/mcp/src/main.rs
@@ -58,14 +58,11 @@ async fn main() -> Result<(), McpRuntimeError> {
     }
 
     let config_path = env::var("IGGY_MCP_CONFIG_PATH").unwrap_or_else(|_| 
"config".to_string());
-
-    eprintln!("Loading configuration from: {config_path}");
-
-    let builder = Config::builder()
-        .add_source(File::with_name(&config_path))
-        .add_source(Environment::with_prefix("IGGY_MCP").separator("_"));
-
-    let config: McpServerConfig = builder
+    eprintln!("Configuration file path: {config_path}");
+    let config: McpServerConfig = Config::builder()
+        
.add_source(Config::try_from(&McpServerConfig::default()).expect("Failed to 
init config"))
+        .add_source(File::with_name(&config_path).required(false))
+        .add_source(Environment::with_prefix("IGGY_MCP").separator("_"))
         .build()
         .expect("Failed to build runtime config")
         .try_deserialize()
@@ -87,12 +84,13 @@ async fn main() -> Result<(), McpRuntimeError> {
 
     info!("Starting Iggy MCP Server, transport: {transport}...");
 
-    let consumer_id =
-        
Identifier::from_str_value(config.iggy.consumer_name.as_deref().unwrap_or("iggy-mcp"))
-            .map_err(|error| {
-                error!("Failed to create Iggy consumer ID: {:?}", error);
-                McpRuntimeError::FailedToCreateConsumerId
-            })?;
+    let consumer_id = Identifier::from_str_value(
+        config.iggy.consumer.as_deref().unwrap_or("iggy-mcp"),
+    )
+    .map_err(|error| {
+        error!("Failed to create Iggy consumer ID: {:?}", error);
+        McpRuntimeError::FailedToCreateConsumerId
+    })?;
     let iggy_consumer = Arc::new(iggy::prelude::Consumer::new(consumer_id));
     let iggy_client = Arc::new(stream::init(config.iggy).await?);
     let permissions = Permissions {
@@ -118,7 +116,7 @@ async fn main() -> Result<(), McpRuntimeError> {
             error!("waiting error: {:?}", error);
         }
     } else {
-        let Some(http_config) = config.http_api else {
+        let Some(http_config) = config.http else {
             error!("HTTP API configuration not found");
             return Err(McpRuntimeError::MissingConfig);
         };
diff --git a/core/integration/Cargo.toml b/core/integration/Cargo.toml
index b17d3d0b..5d8f0d79 100644
--- a/core/integration/Cargo.toml
+++ b/core/integration/Cargo.toml
@@ -46,6 +46,14 @@ libc = "0.2.174"
 log = { workspace = true }
 predicates = { workspace = true }
 rcgen = "0.13.2"
+rmcp = { version = "0.3.0", features = [
+    "client",
+    "reqwest",
+    "transport-streamable-http-client",
+    "transport-child-process",
+    "tower",
+    "auth",
+] }
 serial_test = { workspace = true }
 server = { workspace = true }
 tempfile = { workspace = true }
diff --git a/core/integration/src/lib.rs b/core/integration/src/lib.rs
index 1f65508b..88c51ac1 100644
--- a/core/integration/src/lib.rs
+++ b/core/integration/src/lib.rs
@@ -25,5 +25,7 @@ pub mod quic_client;
 #[allow(deprecated)]
 pub mod tcp_client;
 #[allow(deprecated)]
+pub mod test_mcp_server;
+#[allow(deprecated)]
 pub mod test_server;
 pub mod test_tls_utils;
diff --git a/core/integration/src/lib.rs 
b/core/integration/src/test_mcp_server.rs
similarity index 78%
copy from core/integration/src/lib.rs
copy to core/integration/src/test_mcp_server.rs
index 1f65508b..31bd66e6 100644
--- a/core/integration/src/lib.rs
+++ b/core/integration/src/test_mcp_server.rs
@@ -15,15 +15,3 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-pub mod bench_utils;
-pub mod file;
-#[allow(deprecated)]
-pub mod http_client;
-#[allow(deprecated)]
-pub mod quic_client;
-#[allow(deprecated)]
-pub mod tcp_client;
-#[allow(deprecated)]
-pub mod test_server;
-pub mod test_tls_utils;
diff --git a/core/integration/src/lib.rs b/core/integration/tests/mcp/mod.rs
similarity index 78%
copy from core/integration/src/lib.rs
copy to core/integration/tests/mcp/mod.rs
index 1f65508b..2e79fae5 100644
--- a/core/integration/src/lib.rs
+++ b/core/integration/tests/mcp/mod.rs
@@ -16,14 +16,11 @@
  * under the License.
  */
 
-pub mod bench_utils;
-pub mod file;
-#[allow(deprecated)]
-pub mod http_client;
-#[allow(deprecated)]
-pub mod quic_client;
-#[allow(deprecated)]
-pub mod tcp_client;
-#[allow(deprecated)]
-pub mod test_server;
-pub mod test_tls_utils;
+use integration::test_server::TestServer;
+
+#[tokio::test]
+async fn test_mcp() {
+    let mut test_server = TestServer::default();
+    test_server.start();
+    let _server_addr = test_server.get_raw_tcp_addr().unwrap();
+}
diff --git a/core/integration/tests/mod.rs b/core/integration/tests/mod.rs
index df7e3a1a..7dbf56bd 100644
--- a/core/integration/tests/mod.rs
+++ b/core/integration/tests/mod.rs
@@ -29,6 +29,7 @@ mod archiver;
 mod cli;
 mod config_provider;
 mod data_integrity;
+mod mcp;
 mod sdk;
 mod server;
 mod state;

Reply via email to