UNPKG

@cyanheads/filesystem-mcp-server

Version:

A Model Context Protocol (MCP) server for platform-agnostic file capabilities, including advanced search and replace, and directory tree traversal

29 lines (28 loc) 1.16 kB
import { z } from 'zod'; import { RequestContext } from '../../../utils/internal/requestContext.js'; export declare const WriteFileInputSchema: z.ZodObject<{ path: z.ZodString; content: z.ZodString; }, "strip", z.ZodTypeAny, { path: string; content: string; }, { path: string; content: string; }>; export type WriteFileInput = z.infer<typeof WriteFileInputSchema>; export interface WriteFileOutput { message: string; writtenPath: string; bytesWritten: number; } /** * Writes content to a specified file, overwriting it if it exists, * and creating necessary directories. * * @param {WriteFileInput} input - The input object containing the file path and content. * @param {RequestContext} context - The request context for logging and error handling. * @returns {Promise<WriteFileOutput>} A promise that resolves with a success message, the path written to, and bytes written. * @throws {McpError} Throws McpError for path resolution errors, I/O errors, or if the path resolves to a directory. */ export declare const writeFileLogic: (input: WriteFileInput, context: RequestContext) => Promise<WriteFileOutput>;