editar_archivo
Edit the content of an existing file by overwriting it with new text using the DedcodeMCP File Manager.
Instructions
Edita el contenido de un archivo existente (sobrescribe el contenido)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nombre | Yes | Nombre del archivo a editar | |
| nuevo_contenido | Yes | Nuevo contenido del archivo |
Implementation Reference
- main.ts:227-254 (handler)Handler for the 'editar_archivo' tool: parses arguments using EditarArchivoSchema, constructs file path on desktop, validates path access, checks file existence, overwrites file with new content, and returns success message.case "editar_archivo": { const { nombre, nuevo_contenido } = EditarArchivoSchema.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.access(ruta); await fs.writeFile(ruta, nuevo_contenido, "utf-8"); return { content: [ { type: "text", text: `Archivo editado correctamente: ${nombre}`, }, ], }; }
- main.ts:52-55 (schema)Zod schema defining input parameters for editar_archivo: nombre (file name) and nuevo_contenido (new content).const EditarArchivoSchema = z.object({ nombre: z.string().describe("Nombre del archivo a editar"), nuevo_contenido: z.string().describe("Nuevo contenido del archivo"), });
- main.ts:102-119 (registration)Tool registration in ListToolsRequestHandler: defines name, description, and inputSchema matching the EditarArchivoSchema.{ name: "editar_archivo", description: "Edita el contenido de un archivo existente (sobrescribe el contenido)", inputSchema: { type: "object", properties: { nombre: { type: "string", description: "Nombre del archivo a editar", }, nuevo_contenido: { type: "string", description: "Nuevo contenido del archivo", }, }, required: ["nombre", "nuevo_contenido"], }, },