Skip to main content
Glama
ahmetshbz1

Filesystem MCP Server

by ahmetshbz1
path-utils.ts1.72 kB
import path from 'path'; import os from 'os'; export function convertToWindowsPath(p: string): string { if (p.startsWith('/mnt/')) return p; if (p.match(/^\/[a-zA-Z]\//) && process.platform === 'win32') { const driveLetter = p.charAt(1).toUpperCase(); const pathPart = p.slice(2).replace(/\//g, '\\'); return `${driveLetter}:${pathPart}`; } if (p.match(/^[a-zA-Z]:/)) return p.replace(/\//g, '\\'); return p; } export function normalizePath(p: string): string { p = p.trim().replace(/^['"]|['"]$/g, ''); const isUnixPath = p.startsWith('/') && ( p.match(/^\/mnt\/[a-z]\//i) || (process.platform !== 'win32') || (process.platform === 'win32' && !p.match(/^\/[a-zA-Z]\//)) ); if (isUnixPath) { const normalized = p.replace(/\/+/g, '/').replace(/\/+$/, ''); return normalized === '' ? '/' : normalized; } p = convertToWindowsPath(p); if (p.startsWith('\\\\')) { let uncPath = p.replace(/^\\{2,}/, '\\\\'); const restOfPath = uncPath.substring(2).replace(/\\\\/g, '\\'); p = '\\\\' + restOfPath; } else { p = p.replace(/\\\\/g, '\\'); } let normalized = path.normalize(p); if (p.startsWith('\\') && !normalized.startsWith('\\')) normalized = '\\' + normalized; if (normalized.match(/^[a-zA-Z]:/)) { let result = normalized.replace(/\//g, '\\'); if (/^[a-z]:/.test(result)) result = result.charAt(0).toUpperCase() + result.slice(1); return result; } if (process.platform === 'win32') return normalized.replace(/\//g, '\\'); return normalized; } export function expandHome(filepath: string): string { if (filepath.startsWith('~/') || filepath === '~') return path.join(os.homedir(), filepath.slice(1)); return filepath; }

Latest Blog Posts

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/ahmetshbz1/filesystem-mcp'

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