75 lines
2.3 KiB
Rust
75 lines
2.3 KiB
Rust
//! Integration test for the MCP prompt rendering server.
|
|
|
|
use owlen_core::Result;
|
|
use owlen_core::config::McpServerConfig;
|
|
use owlen_core::mcp::client::RemoteMcpClient;
|
|
use owlen_core::mcp::{McpToolCall, McpToolResponse};
|
|
use serde_json::json;
|
|
use std::path::PathBuf;
|
|
|
|
#[tokio::test]
|
|
async fn test_render_prompt_via_external_server() -> Result<()> {
|
|
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
let workspace_root = manifest_dir
|
|
.parent()
|
|
.and_then(|p| p.parent())
|
|
.expect("workspace root");
|
|
|
|
let candidates = [
|
|
workspace_root
|
|
.join("target")
|
|
.join("debug")
|
|
.join("owlen-mcp-prompt-server"),
|
|
workspace_root
|
|
.join("owlen-mcp-prompt-server")
|
|
.join("target")
|
|
.join("debug")
|
|
.join("owlen-mcp-prompt-server"),
|
|
];
|
|
|
|
let binary = if let Some(path) = candidates.iter().find(|path| path.exists()) {
|
|
path.clone()
|
|
} else {
|
|
eprintln!(
|
|
"Skipping prompt server integration test: binary not found. \
|
|
Build it with `cargo build -p owlen-mcp-prompt-server`. Tried {:?}",
|
|
candidates
|
|
);
|
|
return Ok(());
|
|
};
|
|
|
|
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 = match RemoteMcpClient::new_with_config(&config) {
|
|
Ok(client) => client,
|
|
Err(err) => {
|
|
eprintln!(
|
|
"Skipping prompt server integration test: failed to launch {} ({err})",
|
|
config.command
|
|
);
|
|
return Ok(());
|
|
}
|
|
};
|
|
|
|
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(())
|
|
}
|