Skip to main content
Glama

Superglue MCP

Official
by superglue-ai
ftp.test.ts3.32 kB
import { ApiConfig, HttpMethod, RequestOptions } from '@superglue/client'; import { describe, expect, it, vi } from 'vitest'; // Mock the modules before importing executeFTP vi.mock('basic-ftp'); vi.mock('ssh2-sftp-client'); // Now import after mocks are set up import { executeFTP } from './ftp.js'; describe('executeFTP', () => { const mockEndpoint: ApiConfig = { id: 'test-ftp', urlHost: 'ftp://testuser:testpass@ftp.example.com', urlPath: '/testpath', body: '{"operation": "list"}', method: HttpMethod.GET, instruction: 'Test FTP endpoint' }; const mockPayload = {}; const mockCredentials = {}; const mockOptions: RequestOptions = {}; describe('Integration tests', () => { it('should validate FTP configuration', () => { // Just validate that the function exists and can be called expect(executeFTP).toBeDefined(); expect(typeof executeFTP).toBe('function'); }); }); describe('Error handling', () => { it('should throw error for invalid JSON in body', async () => { const endpoint = { ...mockEndpoint, body: 'invalid json' }; await expect(executeFTP({operation: endpoint.body, credentials: mockCredentials, options: mockOptions})) .rejects.toThrow('Invalid JSON in body'); }); it('should throw error for missing operation', async () => { const endpoint = { ...mockEndpoint, body: '{}' }; await expect(executeFTP({operation: endpoint.body, credentials: mockCredentials, options: mockOptions})) .rejects.toThrow("Missing 'operation' field in request body"); }); it('should throw error for unsupported operation', async () => { const endpoint = { ...mockEndpoint, body: '{"operation": "unsupported"}' }; await expect(executeFTP({operation: endpoint.body, credentials: mockCredentials, options: mockOptions})) .rejects.toThrow('Unsupported operation: \'unsupported\''); }); }); describe('Operation validation', () => { it('should validate supported operations', () => { const supportedOps = ['list', 'get', 'put', 'delete', 'rename', 'mkdir', 'rmdir', 'exists', 'stat']; supportedOps.forEach(op => { const endpoint = { ...mockEndpoint, body: JSON.stringify({ operation: op }) }; // This will fail at connection, but won't fail at operation validation expect(async () => { try { await executeFTP({operation: endpoint.body, credentials: mockCredentials, options: mockOptions}); } catch (e: any) { // Should not be an unsupported operation error expect(e.message).not.toContain('Unsupported operation'); } }).toBeDefined(); }); }); it('should reject invalid operations', async () => { const invalidOps = ['upload', 'download', 'copy', 'move']; for (const op of invalidOps) { const endpoint = { ...mockEndpoint, body: JSON.stringify({ operation: op }) }; await expect(executeFTP({operation: endpoint.body, credentials: mockCredentials, options: mockOptions})) .rejects.toThrow(`Unsupported operation: '${op}'`); } }); }); });

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/superglue-ai/superglue'

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