52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
use super::{McpToolCall, McpToolDescriptor, McpToolResponse};
|
|
use crate::{Error, Result};
|
|
use async_trait::async_trait;
|
|
|
|
/// Trait for a client that can interact with an MCP server
|
|
#[async_trait]
|
|
pub trait McpClient: Send + Sync {
|
|
/// List the tools available on the server
|
|
async fn list_tools(&self) -> Result<Vec<McpToolDescriptor>>;
|
|
|
|
/// Call a tool on the server
|
|
async fn call_tool(&self, call: McpToolCall) -> Result<McpToolResponse>;
|
|
}
|
|
|
|
/// Placeholder for a client that connects to a remote MCP server.
|
|
pub struct RemoteMcpClient;
|
|
|
|
impl RemoteMcpClient {
|
|
pub fn new() -> Result<Self> {
|
|
// Attempt to spawn the MCP server binary located at ./target/debug/owlen-mcp-server
|
|
// The server runs over STDIO and will be managed by the client instance.
|
|
// For now we just verify that the binary exists; the actual process handling
|
|
// is performed lazily in the async methods.
|
|
let path = "./target/debug/owlen-mcp-server";
|
|
if std::path::Path::new(path).exists() {
|
|
Ok(Self)
|
|
} else {
|
|
Err(Error::NotImplemented(format!(
|
|
"Remote MCP server binary not found at {}",
|
|
path
|
|
)))
|
|
}
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl McpClient for RemoteMcpClient {
|
|
async fn list_tools(&self) -> Result<Vec<McpToolDescriptor>> {
|
|
// TODO: Implement remote call
|
|
Err(Error::NotImplemented(
|
|
"Remote MCP client is not implemented".to_string(),
|
|
))
|
|
}
|
|
|
|
async fn call_tool(&self, _call: McpToolCall) -> Result<McpToolResponse> {
|
|
// TODO: Implement remote call
|
|
Err(Error::NotImplemented(
|
|
"Remote MCP client is not implemented".to_string(),
|
|
))
|
|
}
|
|
}
|