Skip to content

Commit 206fd22

Browse files
committed
chore: bump mc-mcp version from 0.1.6 to 0.1.7 in Cargo.toml and Cargo.lock, update logging to use the log crate for better error and info handling in the codebase.
1 parent 44a553e commit 206fd22

File tree

6 files changed

+57
-57
lines changed

6 files changed

+57
-57
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mc-mcp"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55
authors = ["ea <ecdysis-xyz@proton.me>", "kai <kai.hiroi@pm.me>"]
66
description = "A Model Context Protocol (MCP) server for metacontract smart contract development."

src/bin/build_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() -> anyhow::Result<()> {
2121
// 引数: 入力ディレクトリ, 出力ファイル
2222
let args: Vec<String> = env::args().collect();
2323
if args.len() != 3 {
24-
eprintln!("Usage: build_index <input_docs_dir> <output_jsonl>");
24+
log::error!("Usage: build_index <input_docs_dir> <output_jsonl>");
2525
std::process::exit(1);
2626
}
2727
let input_dir = PathBuf::from(&args[1]);
@@ -53,6 +53,6 @@ fn main() -> anyhow::Result<()> {
5353
total_chunks += 1;
5454
}
5555
}
56-
println!("Wrote {} chunks to {:?}", total_chunks, output_path);
56+
log::info!("Wrote {} chunks to {:?}", total_chunks, output_path);
5757
Ok(())
5858
}

src/infrastructure/file_system.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn load_documents(docs_path: Option<PathBuf>) -> Result<SimpleDocumentIndex,
4040
let default_path = PathBuf::from("metacontract/mc/site/docs");
4141
let target_path = docs_path.unwrap_or(default_path);
4242

43-
println!("Loading documents from: {:?}", target_path);
43+
log::info!("Loading documents from: {:?}", target_path);
4444

4545
if !target_path.is_dir() {
4646
return Err(format!(
@@ -65,13 +65,13 @@ pub fn load_documents(docs_path: Option<PathBuf>) -> Result<SimpleDocumentIndex,
6565
index.insert(path_str, (text, "mc-docs".to_string())); // sourceは現状固定
6666
}
6767
Err(e) => {
68-
eprintln!("Failed to read file {}: {}", path_str, e);
68+
log::error!("Failed to read file {}: {}", path_str, e);
6969
}
7070
}
7171
}
7272

7373
if index.is_empty() {
74-
println!(
74+
log::warn!(
7575
"Warning: No markdown files found or loaded from {:?}",
7676
target_path
7777
);
@@ -162,7 +162,7 @@ pub fn load_documents_from_multiple_sources(
162162
index.insert(path_str, (text, source.clone()));
163163
}
164164
Err(e) => {
165-
eprintln!("Failed to read file {}: {}", path_str, e);
165+
log::error!("Failed to read file {}: {}", path_str, e);
166166
}
167167
}
168168
}
@@ -235,14 +235,14 @@ pub fn load_documents_from_source(dir_path: &PathBuf) -> Result<HashMap<String,
235235
/// 指定URLからprebuilt_index.jsonl(.gz)をダウンロード(既存ならスキップ)
236236
pub fn download_if_not_exists(url: &str, dest: &str) -> anyhow::Result<()> {
237237
if PathBuf::from(dest).exists() {
238-
println!("Index file already exists: {}", dest);
238+
log::info!("Index file already exists: {}", dest);
239239
return Ok(());
240240
}
241-
println!("Downloading index from {} ...", url);
241+
log::info!("Downloading index from {} ...", url);
242242
let mut resp = reqwest::blocking::get(url)?;
243243
let mut out = File::create(dest)?;
244244
copy(&mut resp, &mut out)?;
245-
println!("Downloaded index to {}", dest);
245+
log::info!("Downloaded index to {}", dest);
246246
Ok(())
247247
}
248248

@@ -311,7 +311,7 @@ mod tests {
311311
fn test_load_documents_default_path_not_exists() {
312312
// Need to ensure the default path doesn't exist for this test
313313
if PathBuf::from("metacontract/mc/site/docs").exists() {
314-
println!(
314+
log::info!(
315315
"Skipping test_load_documents_default_path_not_exists because default path exists."
316316
);
317317
return;

src/main.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const MC_TEMPLATE_REPO: &str = "metacontract/template";
4949
async fn main() -> Result<()> {
5050
// check if qdrant is running
5151
if let Err(e) = ensure_qdrant_via_docker() {
52-
eprintln!("{e}");
52+
log::error!("{e}");
5353
std::process::exit(1);
5454
}
5555
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace"))
@@ -711,7 +711,7 @@ mod tests {
711711
impl ReferenceService for MockReferenceService {
712712
// index_sources implementation
713713
async fn index_sources(&self, sources: &[DocumentSource]) -> Result<()> {
714-
println!(
714+
log::info!(
715715
"MockReferenceService: index_sources called with {} sources",
716716
sources.len()
717717
);
@@ -727,7 +727,7 @@ mod tests {
727727
query: mc_mcp::domain::reference::SearchQuery,
728728
_score_threshold: Option<f32>,
729729
) -> Result<Vec<SearchResult>> {
730-
println!(
730+
log::info!(
731731
"MockReferenceService: search_documents called with query: {:?}",
732732
query
733733
);
@@ -1158,34 +1158,34 @@ fi
11581158

11591159

11601160
// --- Debug: Check if mock script file actually exists ---
1161-
println!("Checking existence of: {}", forge_script_on_mock_bin.display());
1161+
log::info!("Checking existence of: {}", forge_script_on_mock_bin.display());
11621162
if forge_script_on_mock_bin.exists() {
1163-
println!("Mock script file FOUND.");
1163+
log::info!("Mock script file FOUND.");
11641164

11651165
// --- Add execute permission ---
11661166
#[cfg(unix)]
11671167
{
11681168
use std::os::unix::fs::PermissionsExt;
1169-
println!("Setting execute permission on mock script...");
1169+
log::info!("Setting execute permission on mock script...");
11701170
let metadata = std::fs::metadata(&forge_script_on_mock_bin).expect("Failed to get metadata for mock script");
11711171
let mut perms = metadata.permissions();
11721172
if perms.mode() & 0o111 == 0 { // Check if execute bit is NOT set
11731173
perms.set_mode(perms.mode() | 0o111); // Add execute permission for user, group, others
11741174
std::fs::set_permissions(&forge_script_on_mock_bin, perms).expect("Failed to set permissions on mock script");
1175-
println!("Execute permission set.");
1175+
log::info!("Execute permission set.");
11761176
} else {
1177-
println!("Execute permission already set.");
1177+
log::info!("Execute permission already set.");
11781178
}
11791179
}
11801180
// --- End Add execute permission ---
11811181

11821182
} else {
1183-
println!("Mock script file NOT FOUND!");
1183+
log::error!("Mock script file NOT FOUND!");
11841184
// もし見つからなかったら、ls の結果も見てみる
11851185
let ls_output = std::process::Command::new("ls").arg("-al").arg(mock_bin_path.display().to_string()).output();
11861186
match ls_output {
1187-
Ok(out) => println!("ls -al {}:\n{}", mock_bin_path.display(), String::from_utf8_lossy(&out.stdout)),
1188-
Err(e) => println!("Failed to run ls: {}", e),
1187+
Ok(out) => log::error!("ls -al {}:\n{}", mock_bin_path.display(), String::from_utf8_lossy(&out.stdout)),
1188+
Err(e) => log::error!("Failed to run ls: {}", e),
11891189
}
11901190
}
11911191
// --- End Debug ---
@@ -1197,23 +1197,23 @@ fi
11971197
std::env::set_var("PATH", format!("{}:{}", mock_bin_abs_path_str, original_path));
11981198

11991199
// --- Debugging: Check which forge is used and run mock script directly ---
1200-
println!("--- Debug Info: test_mc_deploy_broadcast_success ---");
1200+
log::info!("--- Debug Info: test_mc_deploy_broadcast_success ---");
12011201
let which_output = std::process::Command::new("which").arg("forge").output().expect("Failed to run which forge");
1202-
println!("which forge stdout: {}", String::from_utf8_lossy(&which_output.stdout));
1203-
println!("which forge stderr: {}", String::from_utf8_lossy(&which_output.stderr));
1204-
println!("which forge status: {:?}", which_output.status.code());
1202+
log::info!("which forge stdout: {}", String::from_utf8_lossy(&which_output.stdout));
1203+
log::info!("which forge stderr: {}", String::from_utf8_lossy(&which_output.stderr));
1204+
log::info!("which forge status: {:?}", which_output.status.code());
12051205

1206-
println!("Executing mock script directly: {} script {} --broadcast", forge_script_path_mock_abs.display(), expected_script_path);
1206+
log::info!("Executing mock script directly: {} script {} --broadcast", forge_script_path_mock_abs.display(), expected_script_path);
12071207
let mock_run_output = std::process::Command::new(forge_script_path_mock_abs)
12081208
.arg("script")
12091209
.arg(expected_script_path)
12101210
.arg("--broadcast")
12111211
.output()
12121212
.expect("Failed to run mock forge script directly");
1213-
println!("Mock script stdout: {}", String::from_utf8_lossy(&mock_run_output.stdout));
1214-
println!("Mock script stderr: {}", String::from_utf8_lossy(&mock_run_output.stderr));
1215-
println!("Mock script status: {:?}", mock_run_output.status.code());
1216-
println!("--- End Debug Info ---");
1213+
log::info!("Mock script stdout: {}", String::from_utf8_lossy(&mock_run_output.stdout));
1214+
log::info!("Mock script stderr: {}", String::from_utf8_lossy(&mock_run_output.stderr));
1215+
log::info!("Mock script status: {:?}", mock_run_output.status.code());
1216+
log::info!("--- End Debug Info ---");
12171217
// --- End Debugging ---
12181218

12191219
let args = McDeployArgs {
@@ -1531,34 +1531,34 @@ fi
15311531

15321532

15331533
// --- Debug: Check if mock script file actually exists ---
1534-
println!("Checking existence of: {}", forge_script_on_mock_bin.display());
1534+
log::info!("Checking existence of: {}", forge_script_on_mock_bin.display());
15351535
if forge_script_on_mock_bin.exists() {
1536-
println!("Mock script file FOUND.");
1536+
log::info!("Mock script file FOUND.");
15371537

15381538
// --- Add execute permission ---
15391539
#[cfg(unix)]
15401540
{
15411541
use std::os::unix::fs::PermissionsExt;
1542-
println!("Setting execute permission on mock script...");
1542+
log::info!("Setting execute permission on mock script...");
15431543
let metadata = std::fs::metadata(&forge_script_on_mock_bin).expect("Failed to get metadata for mock script");
15441544
let mut perms = metadata.permissions();
15451545
if perms.mode() & 0o111 == 0 { // Check if execute bit is NOT set
15461546
perms.set_mode(perms.mode() | 0o111); // Add execute permission for user, group, others
15471547
std::fs::set_permissions(&forge_script_on_mock_bin, perms).expect("Failed to set permissions on mock script");
1548-
println!("Execute permission set.");
1548+
log::info!("Execute permission set.");
15491549
} else {
1550-
println!("Execute permission already set.");
1550+
log::info!("Execute permission already set.");
15511551
}
15521552
}
15531553
// --- End Add execute permission ---
15541554

15551555
} else {
1556-
println!("Mock script file NOT FOUND!");
1556+
log::error!("Mock script file NOT FOUND!");
15571557
// もし見つからなかったら、ls の結果も見てみる
15581558
let ls_output = std::process::Command::new("ls").arg("-al").arg(mock_bin_path.display().to_string()).output();
15591559
match ls_output {
1560-
Ok(out) => println!("ls -al {}:\n{}", mock_bin_path.display(), String::from_utf8_lossy(&out.stdout)),
1561-
Err(e) => println!("Failed to run ls: {}", e),
1560+
Ok(out) => log::error!("ls -al {}:\n{}", mock_bin_path.display(), String::from_utf8_lossy(&out.stdout)),
1561+
Err(e) => log::error!("Failed to run ls: {}", e),
15621562
}
15631563
}
15641564
// --- End Debug ---
@@ -1570,23 +1570,23 @@ fi
15701570
std::env::set_var("PATH", format!("{}:{}", mock_bin_abs_path_str, original_path));
15711571

15721572
// --- Debugging: Check which forge is used and run mock script directly ---
1573-
println!("--- Debug Info: test_mc_upgrade_broadcast_success ---");
1573+
log::info!("--- Debug Info: test_mc_upgrade_broadcast_success ---");
15741574
let which_output = std::process::Command::new("which").arg("forge").output().expect("Failed to run which forge");
1575-
println!("which forge stdout: {}", String::from_utf8_lossy(&which_output.stdout));
1576-
println!("which forge stderr: {}", String::from_utf8_lossy(&which_output.stderr));
1577-
println!("which forge status: {:?}", which_output.status.code());
1575+
log::info!("which forge stdout: {}", String::from_utf8_lossy(&which_output.stdout));
1576+
log::info!("which forge stderr: {}", String::from_utf8_lossy(&which_output.stderr));
1577+
log::info!("which forge status: {:?}", which_output.status.code());
15781578

1579-
println!("Executing mock script directly: {} script {} --broadcast", forge_script_path_mock_abs.display(), expected_script_path);
1579+
log::info!("Executing mock script directly: {} script {} --broadcast", forge_script_path_mock_abs.display(), expected_script_path);
15801580
let mock_run_output = std::process::Command::new(forge_script_path_mock_abs)
15811581
.arg("script")
15821582
.arg(expected_script_path)
15831583
.arg("--broadcast")
15841584
.output()
15851585
.expect("Failed to run mock forge script directly");
1586-
println!("Mock script stdout: {}", String::from_utf8_lossy(&mock_run_output.stdout));
1587-
println!("Mock script stderr: {}", String::from_utf8_lossy(&mock_run_output.stderr));
1588-
println!("Mock script status: {:?}", mock_run_output.status.code());
1589-
println!("--- End Debug Info ---");
1586+
log::info!("Mock script stdout: {}", String::from_utf8_lossy(&mock_run_output.stdout));
1587+
log::info!("Mock script stderr: {}", String::from_utf8_lossy(&mock_run_output.stderr));
1588+
log::info!("Mock script status: {:?}", mock_run_output.status.code());
1589+
log::info!("--- End Debug Info ---");
15901590
// --- End Debugging ---
15911591

15921592
let args = McUpgradeArgs { broadcast: Some(true) };
@@ -1754,10 +1754,10 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
17541754
.map_err(|e| format!("Failed to execute docker ps: {e}"))?;
17551755
let ps_stdout = String::from_utf8_lossy(&ps.stdout);
17561756
if ps_stdout.contains("qdrant") {
1757-
eprintln!("✅ Qdrant is already running in Docker.");
1757+
log::info!("✅ Qdrant is already running in Docker.");
17581758
} else {
17591759
// 3. Start Qdrant container
1760-
eprintln!("Qdrant container not found. Starting Qdrant in Docker...");
1760+
log::info!("Qdrant container not found. Starting Qdrant in Docker...");
17611761
let run = std::process::Command::new("docker")
17621762
.args([
17631763
"run",
@@ -1778,7 +1778,7 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
17781778
String::from_utf8_lossy(&run.stderr)
17791779
));
17801780
}
1781-
eprintln!("Qdrant container started.");
1781+
log::info!("Qdrant container started.");
17821782
}
17831783

17841784
// 4. Health check (HTTP endpoint retry)
@@ -1789,12 +1789,12 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
17891789
.call()
17901790
{
17911791
Ok(resp) if resp.status() == 200 => {
1792-
eprintln!("✅ Qdrant is running and connected!");
1792+
log::info!("✅ Qdrant is running and connected!");
17931793
return Ok(());
17941794
}
17951795
_ => {
1796-
eprintln!("Waiting for Qdrant to start... (Retry {i}/5)");
1797-
sleep(Duration::from_secs(2));
1796+
log::info!("Waiting for Qdrant to start... (Retry {i}/5)");
1797+
std::thread::sleep(std::time::Duration::from_secs(2));
17981798
}
17991799
}
18001800
}

tests/vector_db_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn setup_qdrant() -> Result<(VectorDb, ContainerAsync<GenericImage>)> {
5252
if !error_string.contains("already exists") && !error_string.contains("already created") {
5353
return Err(e.into());
5454
}
55-
println!(
55+
log::warn!(
5656
"Collection {} already exists, likely due to race condition. Continuing.",
5757
collection_name
5858
);
@@ -100,7 +100,7 @@ async fn test_vector_db_upsert_and_search() -> Result<()> {
100100
tokio::time::sleep(Duration::from_millis(500)).await;
101101
let query_vector = vec![0.15, 0.25, 0.6];
102102
let results = vector_db.search(query_vector.clone(), 5, Some(0.5)).await?;
103-
println!("Search Results: {:?}", results);
103+
log::info!("Search Results: {:?}", results);
104104
assert!(!results.is_empty(), "Search should return results");
105105
assert_eq!(results.len(), 2, "Expected 2 results above threshold 0.5");
106106
let top_result = &results[0];

0 commit comments

Comments
 (0)