use anyhow::Result;
use serde_json::json;
use crate::mcp::{self, McpConfig, print_result};
pub async fn run(config: &McpConfig, repo: &str, query: &str) -> Result<()> {
let client_config = mcp::McpConfig {
url: config.url.clone(),
token: config.token.clone(),
timeout_secs: config.timeout_secs,
output_format: config.output_format.clone(),
};
let mut client = mcp::McpClient::new(client_config)?;
client.initialize().await?;
let search_question = format!(
"Search for information about: {query}. \
List all relevant topics, functions, modules, and documentation sections that match this query."
);
let arguments = json!({
"repoName": repo,
"question": search_question
});
let result = client.call_tool("ask_question", arguments).await?;
print_result(&config.output_format, &result);
Ok(())
}