Skip to main content
Glama
ahmetshbz1

Filesystem MCP Server

by ahmetshbz1
hash.test.ts1.1 kB
import { describe, it, expect, vi, beforeEach } from 'vitest'; import fs from 'fs/promises'; import { handlers } from '../src/handlers/utility.js'; import { setAllowedDirectories } from '../src/lib.js'; // Mock fs vi.mock('fs/promises'); vi.mock('../logger.js', () => ({ logger: { info: vi.fn() }, })); const mockFs = fs as any; describe('file_hash', () => { beforeEach(() => { setAllowedDirectories(['/tmp']); vi.clearAllMocks(); mockFs.realpath.mockImplementation((p: string) => Promise.resolve(p)); }); it('should calculate SHA256 hash by default', async () => { mockFs.readFile.mockResolvedValue('test content'); const result = await handlers.utility({ operation: 'hash', path: '/tmp/file.txt' }); expect(result.content[0].text).toMatch(/^sha256: [a-f0-9]{64}$/); }); it('should calculate MD5 hash', async () => { mockFs.readFile.mockResolvedValue('test content'); const result = await handlers.utility({ operation: 'hash', path: '/tmp/file.txt', algorithm: 'md5' }); expect(result.content[0].text).toMatch(/^md5: [a-f0-9]{32}$/); }); });

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