1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! cnctd-service-ssh - SSH command execution library
//!
//! This library provides secure SSH command execution capabilities.
//! It can be used directly as a library or run as an MCP server.
//!
//! # Library Usage
//!
//! ```rust,no_run
//! use cnctd_service_ssh::{SshService, SshRegisterArgs, SshExecArgs};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let service = SshService::new();
//!
//! // Register a target
//! service.register(SshRegisterArgs {
//! id: "my-server".to_string(),
//! host: "example.com".to_string(),
//! user: "ubuntu".to_string(),
//! port: 22,
//! key_passphrase: None,
//! known_hosts_path: "~/.ssh/known_hosts".to_string(),
//! client_id: Some("my-app".to_string()),
//! }).await?;
//!
//! // Execute a command
//! let result = service.exec(SshExecArgs {
//! id: "my-server".to_string(),
//! command: "hostname".to_string(),
//! timeout_secs: 30,
//! context: Some("checking hostname".to_string()),
//! }).await?;
//!
//! println!("Output: {}", result.stdout);
//! Ok(())
//! }
//! ```
//!
//! # Tool Definitions
//!
//! To get tool schemas for LLM integration (avoiding hardcoded schemas):
//!
//! ```rust
//! use cnctd_service_ssh::get_tool_definitions;
//!
//! let tools = get_tool_definitions();
//! for tool in tools {
//! println!("{}: {}", tool.name, tool.description);
//! }
//! ```
//!
//! # MCP Server
//!
//! Run as a standalone MCP server:
//! ```bash
//! cnctd-service-ssh
//! ```
// Re-export main types for convenience
pub use ;
pub use ServiceError;