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

44 lines (43 loc) 1.8 kB
import { RequestContext } from '../utils/internal/requestContext.js'; /** * Simple in-memory state management for the MCP server session. * This state is cleared when the server restarts. */ declare class ServerState { private defaultFilesystemPath; private fsBaseDirectory; constructor(); /** * Sets the default filesystem path for the current session. * The path is sanitized and validated. * * @param newPath - The absolute path to set as default. * @param context - The request context for logging. * @throws {McpError} If the path is invalid or not absolute. */ setDefaultFilesystemPath(newPath: string, context: RequestContext): void; /** * Gets the currently set default filesystem path. * * @returns The absolute default path or null if not set. */ getDefaultFilesystemPath(): string | null; /** * Clears the default filesystem path. * @param context - The request context for logging. */ clearDefaultFilesystemPath(context: RequestContext): void; /** * Resolves a given path against the default path if the given path is relative. * If the given path is absolute, it's returned directly after sanitization. * If the given path is relative and no default path is set, an error is thrown. * * @param requestedPath - The path provided by the user (can be relative or absolute). * @param context - The request context for logging and error handling. * @returns The resolved, sanitized, absolute path. * @throws {McpError} If a relative path is given without a default path set, or if sanitization fails. */ resolvePath(requestedPath: string, context: RequestContext): string; } export declare const serverState: ServerState; export {};