Skip to main content
Glama

Rust MCP Filesystem

write.rs1.16 kB
use crate::{error::ServiceResult, fs_service::FileSystemService}; use std::path::Path; impl FileSystemService { pub async fn write_file(&self, file_path: &Path, content: &String) -> ServiceResult<()> { let allowed_directories = self.allowed_directories().await; let valid_path = self.validate_path(file_path, allowed_directories)?; tokio::fs::write(valid_path, content).await?; Ok(()) } pub async fn create_directory(&self, file_path: &Path) -> ServiceResult<()> { let allowed_directories = self.allowed_directories().await; let valid_path = self.validate_path(file_path, allowed_directories)?; tokio::fs::create_dir_all(valid_path).await?; Ok(()) } pub async fn move_file(&self, src_path: &Path, dest_path: &Path) -> ServiceResult<()> { let allowed_directories = self.allowed_directories().await; let valid_src_path = self.validate_path(src_path, allowed_directories.clone())?; let valid_dest_path = self.validate_path(dest_path, allowed_directories)?; tokio::fs::rename(valid_src_path, valid_dest_path).await?; Ok(()) } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rust-mcp-stack/rust-mcp-filesystem'

If you have feedback or need assistance with the MCP directory API, please join our Discord server