Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ libc = "0.2"
[target.'cfg(target_os = "linux")'.dependencies]
fuser = { version = "0.15", default-features = false, features = ["abi-7-29"] }
uuid = { version = "1", features = ["v4"] }
# NFS server for userspace filesystem (used by `agentfs run` and `agentfs nfs`)
# NFS server for userspace filesystem (used by `agentfs run` and `agentfs serve nfs`)
nfsserve = "0.10"
async-trait = "0.1"
# Sandbox dependencies - (requires libunwind-dev on ARM)
Expand Down
29 changes: 28 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use agentfs::{
cmd::{self, completions::handle_completions},
get_runtime,
parser::{Args, Command, FsCommand, SyncCommand},
parser::{Args, Command, FsCommand, ServeCommand, SyncCommand},
};
use clap::{CommandFactory, Parser};
use clap_complete::CompleteEnv;
Expand Down Expand Up @@ -198,13 +198,17 @@ fn main() {
bind,
port,
} => {
eprintln!("Warning: `agentfs nfs` is deprecated, use `agentfs serve nfs` instead");
let rt = get_runtime();
if let Err(e) = rt.block_on(cmd::nfs::handle_nfs_command(id_or_path, bind, port)) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
Command::McpServer { id_or_path, tools } => {
eprintln!(
"Warning: `agentfs mcp-server` is deprecated, use `agentfs serve mcp` instead"
);
let rt = get_runtime();
if let Err(e) = rt.block_on(cmd::mcp_server::handle_mcp_server_command(
id_or_path, tools,
Expand All @@ -213,6 +217,29 @@ fn main() {
std::process::exit(1);
}
}
Command::Serve { command } => match command {
#[cfg(unix)]
ServeCommand::Nfs {
id_or_path,
bind,
port,
} => {
let rt = get_runtime();
if let Err(e) = rt.block_on(cmd::nfs::handle_nfs_command(id_or_path, bind, port)) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
ServeCommand::Mcp { id_or_path, tools } => {
let rt = get_runtime();
if let Err(e) = rt.block_on(cmd::mcp_server::handle_mcp_server_command(
id_or_path, tools,
)) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
},
}
}

Expand Down
40 changes: 40 additions & 0 deletions cli/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub enum Command {
format: String,
},
/// Start an NFS server to export an AgentFS filesystem over the network
/// (deprecated: use `agentfs serve nfs` instead)
#[cfg(unix)]
Nfs {
/// Agent ID or database path
Expand All @@ -181,6 +182,7 @@ pub enum Command {
},

/// Start an MCP server exposing filesystem and KV-store tools
/// (deprecated: use `agentfs serve mcp` instead)
McpServer {
/// Agent ID or database path
#[arg(value_name = "ID_OR_PATH", add = ArgValueCompleter::new(id_or_path_completer))]
Expand All @@ -192,6 +194,12 @@ pub enum Command {
#[arg(long, value_delimiter = ',')]
tools: Option<Vec<String>>,
},

/// Serve an AgentFS filesystem via different protocols
Serve {
#[command(subcommand)]
command: ServeCommand,
},
}

#[derive(Subcommand, Debug)]
Expand Down Expand Up @@ -229,6 +237,38 @@ pub enum SyncCommand {
Checkpoint,
}

#[derive(Subcommand, Debug)]
pub enum ServeCommand {
/// Start an NFS server to export an AgentFS filesystem over the network
#[cfg(unix)]
Nfs {
/// Agent ID or database path
#[arg(value_name = "ID_OR_PATH", add = ArgValueCompleter::new(id_or_path_completer))]
id_or_path: String,

/// IP address to bind to
#[arg(long, default_value = "127.0.0.1")]
bind: String,

/// Port to listen on
#[arg(long, default_value = "11111")]
port: u32,
},

/// Start an MCP server exposing filesystem and KV-store tools
Mcp {
/// Agent ID or database path
#[arg(value_name = "ID_OR_PATH", add = ArgValueCompleter::new(id_or_path_completer))]
id_or_path: String,

/// Tools to expose (comma-separated). If not provided, all tools are exposed.
/// Available tools: read_file, write_file, readdir, mkdir, rmdir, rm, unlink,
/// copy_file, rename, stat, access, kv_get, kv_set, kv_delete, kv_list
#[arg(long, value_delimiter = ',')]
tools: Option<Vec<String>>,
},
}

#[derive(Subcommand, Debug, Clone, Copy)]
pub enum CompletionsCommand {
/// Install shell completions to your shell rc file
Expand Down
4 changes: 2 additions & 2 deletions examples/firecracker/firecracker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ trap cleanup EXIT

# Clean up from previous failed run
sudo ip link del "${TAP_DEV}" 2>/dev/null || true
pkill -f "agentfs nfs.*${NFS_PORT}" 2>/dev/null || true
pkill -f "agentfs serve nfs.*${NFS_PORT}" 2>/dev/null || true
sleep 0.5

# Set up TAP device
Expand All @@ -66,7 +66,7 @@ sudo ip link set "${TAP_DEV}" up

# Start agentfs NFS server (suppress output)
cd "${SCRIPT_DIR}"
${AGENTFS} nfs --bind "${TAP_IP}" --port "${NFS_PORT}" "${AGENT_ID}" >/dev/null 2>&1 &
${AGENTFS} serve nfs --bind "${TAP_IP}" --port "${NFS_PORT}" "${AGENT_ID}" >/dev/null 2>&1 &
AGENTFS_PID=$!
sleep 1

Expand Down