MCPcopy Create free account
hub / github.com/dexwritescode/rust-mcp / generate_tests

Method generate_tests

src/server/handler.rs:454–486  ·  view source on GitHub ↗
(
        &self,
        Parameters(GenerateTestsParams {
            target_function,
            file_path,
            test_cases,
        }): Parameters<GenerateTestsParams>,
    )

Source from the content-addressed store, hash-verified

452
453 #[tool(description = "Generate unit tests for a function")]
454 async fn generate_tests(
455 &self,
456 Parameters(GenerateTestsParams {
457 target_function,
458 file_path,
459 test_cases,
460 }): Parameters<GenerateTestsParams>,
461 ) -> Result<CallToolResult, McpError> {
462 let args = serde_json::json!({
463 "target_function": target_function,
464 "file_path": file_path,
465 "test_cases": test_cases
466 });
467
468 let mut analyzer = self.analyzer.lock().await;
469 match execute_tool("generate_tests", args, &mut analyzer).await {
470 Ok(result) => {
471 if let Some(content) = result.content.first() {
472 if let Some(text) = content.get("text") {
473 return Ok(CallToolResult::success(vec![Content::text(
474 text.as_str().unwrap_or("No result"),
475 )]));
476 }
477 }
478 Ok(CallToolResult::success(vec![Content::text(
479 "Tests generated successfully",
480 )]))
481 }
482 Err(e) => Ok(CallToolResult::success(vec![Content::text(format!(
483 "Error: {e}"
484 ))])),
485 }
486 }
487
488 #[tool(description = "Inline a function call at specified position")]
489 async fn inline_function(

Callers

nothing calls this directly

Calls 1

execute_toolFunction · 0.85

Tested by

no test coverage detected