//! Integration test for the MCP prompt rendering server. use owlen_core::config::McpServerConfig; use owlen_core::mcp::client::RemoteMcpClient; use owlen_core::mcp::{McpToolCall, McpToolResponse}; use owlen_core::Result; use serde_json::json; use std::path::PathBuf; #[tokio::test] async fn test_render_prompt_via_external_server() -> Result<()> { // Locate the compiled prompt server binary. let mut binary = PathBuf::from(env!("CARGO_MANIFEST_DIR")); binary.pop(); // remove `tests` binary.pop(); // remove `owlen-core` binary.push("owlen-mcp-prompt-server"); binary.push("target"); binary.push("debug"); binary.push("owlen-mcp-prompt-server"); assert!( binary.exists(), "Prompt server binary not found: {:?}", binary ); let config = McpServerConfig { name: "prompt_server".into(), command: binary.to_string_lossy().into_owned(), args: Vec::new(), transport: "stdio".into(), env: std::collections::HashMap::new(), }; let client = RemoteMcpClient::new_with_config(&config)?; let call = McpToolCall { name: "render_prompt".into(), arguments: json!({ "template_name": "example", "variables": {"name": "Alice", "role": "Tester"} }), }; let resp: McpToolResponse = client.call_tool(call).await?; assert!(resp.success, "Tool reported failure: {:?}", resp); let output = resp.output.as_str().unwrap_or(""); assert!(output.contains("Alice"), "Output missing name: {}", output); assert!(output.contains("Tester"), "Output missing role: {}", output); Ok(()) }