crear_archivo
Create new files with specified names and content through the DedcodeMCP File Manager server to manage desktop files.
Instructions
Crea un archivo nuevo en el sistema
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nombre | Yes | Nombre del archivo con extensión | |
| contenido | Yes | El contenido del archivo |
Implementation Reference
- main.ts:170-197 (handler)Handler for crear_archivo tool: parses args using schema, validates path restricted to desktop, creates directory if needed, writes file content, returns success or error message.
case "crear_archivo": { const { nombre, contenido } = CrearArchivoSchema.parse(args); const ruta = path.join(DESKTOP_DIR, nombre); if (!validarRuta(ruta)) { return { content: [ { type: "text", text: "Error: Solo se permite acceso al escritorio", }, ], isError: true, }; } await fs.mkdir(path.dirname(ruta), { recursive: true }); await fs.writeFile(ruta, contenido, "utf-8"); return { content: [ { type: "text", text: `Archivo creado exitosamente: ${nombre}`, }, ], }; } - main.ts:43-46 (schema)Zod schema for input validation of crear_archivo tool: requires nombre (filename with extension) and contenido (file content).
const CrearArchivoSchema = z.object({ nombre: z.string().describe("Nombre del archivo con extensión"), contenido: z.string().describe("El contenido del archivo"), }); - main.ts:70-87 (registration)Registration of crear_archivo tool in the listTools response, including name, description, and input schema matching the Zod schema.
{ name: "crear_archivo", description: "Crea un archivo nuevo en el sistema", inputSchema: { type: "object", properties: { nombre: { type: "string", description: "Nombre del archivo con extensión", }, contenido: { type: "string", description: "El contenido del archivo", }, }, required: ["nombre", "contenido"], }, },