Skip to main content
Glama

Physics MCP Server

by BlinkZer0
distributed.test.js13.9 kB
const { createMockWorkerClient, fixtures, testUtils } = require('../../../tests/shared/test-harness'); const { handleDistributedCollaborationTool } = require('../dist'); // Mock the worker client jest.mock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => createMockWorkerClient({ 'distributed_job_submit': { success: true, job_id: 'job_12345', status: 'queued', estimated_runtime: '5 minutes' }, 'distributed_session_share': { success: true, share_url: 'https://phys-mcp.org/session/abc123', access_code: 'PHYS2024' }, 'distributed_lab_notebook': { success: true, notebook_path: 'artifacts/lab_notebook.md', entries: 5 } }) })); describe('Distributed Collaboration Tool - Comprehensive Test Suite', () => { beforeEach(() => { testUtils.mockFileSystem(); }); describe('Job Submission and Management', () => { test('Submit computational job to cluster', async () => { const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_submit', job_type: 'computation', script: 'python monte_carlo_simulation.py', resources: { cpu: 4, memory: '8GB', time: '2h' }, priority: 'normal' }); testUtils.validateToolResponse(result); expect(result.job_id).toBeDefined(); expect(result.status).toBe('queued'); }); test('Submit GPU-accelerated ML training job', async () => { const mockClient = createMockWorkerClient({ 'distributed_job_submit': { success: true, job_id: 'gpu_job_67890', status: 'running', allocated_resources: { gpu: 'V100', cpu: 8, memory: '32GB' }, queue_position: 1 } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_submit', job_type: 'ml_training', script: 'train_neural_network.py', resources: { gpu: 1, cpu: 8, memory: '32GB', time: '12h' }, priority: 'high' }); expect(result.success).toBe(true); expect(result.allocated_resources.gpu).toBeDefined(); }); test('Check job status and progress', async () => { const mockClient = createMockWorkerClient({ 'distributed_job_status': { success: true, job_id: 'job_12345', status: 'running', progress: 0.65, runtime: '3h 25m', output_preview: 'Iteration 650/1000 completed...' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_status', job_id: 'job_12345' }); expect(result.success).toBe(true); expect(result.progress).toBeGreaterThan(0.5); }); test('Cancel running job', async () => { const mockClient = createMockWorkerClient({ 'distributed_job_cancel': { success: true, job_id: 'job_12345', status: 'cancelled', partial_results: 'artifacts/partial_output.json' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_cancel', job_id: 'job_12345' }); expect(result.success).toBe(true); expect(result.status).toBe('cancelled'); }); }); describe('Session Sharing and Collaboration', () => { test('Share current session with collaborators', async () => { const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_share', permissions: ['read', 'execute'], expiry: '24h', collaborators: ['alice@university.edu', 'bob@research.org'] }); testUtils.validateToolResponse(result); expect(result.share_url).toContain('https://'); expect(result.access_code).toBeDefined(); }); test('Join shared session', async () => { const mockClient = createMockWorkerClient({ 'distributed_session_join': { success: true, session_id: 'session_abc123', owner: 'alice@university.edu', permissions: ['read', 'execute'], active_users: 3 } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_join', access_code: 'PHYS2024' }); expect(result.success).toBe(true); expect(result.session_id).toBeDefined(); }); test('Synchronize session state', async () => { const mockClient = createMockWorkerClient({ 'distributed_session_sync': { success: true, synchronized_objects: ['variables', 'plots', 'calculations'], last_sync: '2024-01-15T10:30:00Z', conflicts_resolved: 0 } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_sync', session_id: 'session_abc123' }); expect(result.success).toBe(true); expect(result.synchronized_objects.length).toBeGreaterThan(0); }); }); describe('Lab Notebook and Documentation', () => { test('Generate collaborative lab notebook', async () => { const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'lab_notebook', session_id: 'session_abc123', include: ['calculations', 'plots', 'discussions', 'conclusions'], format: 'markdown' }); testUtils.validateToolResponse(result); expect(result.notebook_path).toContain('artifacts/'); expect(result.entries).toBeGreaterThan(0); }); test('Add entry to shared notebook', async () => { const mockClient = createMockWorkerClient({ 'distributed_notebook_add': { success: true, entry_id: 'entry_789', timestamp: '2024-01-15T10:45:00Z', author: 'bob@research.org', entry_type: 'calculation' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'notebook_add', session_id: 'session_abc123', entry_type: 'calculation', content: 'Computed eigenvalues for H = p²/2m + V(x)', attachments: ['eigenvalues_plot.png'] }); expect(result.success).toBe(true); expect(result.entry_id).toBeDefined(); }); test('Export notebook to various formats', async () => { const mockClient = createMockWorkerClient({ 'distributed_notebook_export': { success: true, exported_files: [ 'lab_notebook.pdf', 'lab_notebook.html', 'lab_notebook.tex' ], total_pages: 15 } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'notebook_export', session_id: 'session_abc123', formats: ['pdf', 'html', 'latex'] }); expect(result.success).toBe(true); expect(result.exported_files.length).toBe(3); }); }); describe('Artifact Versioning and Management', () => { test('Version control for computational artifacts', async () => { const mockClient = createMockWorkerClient({ 'distributed_artifact_version': { success: true, version_id: 'v1.2.3', artifact_hash: 'sha256:abc123...', changes: ['Updated simulation parameters', 'Fixed boundary conditions'], size: '2.5MB' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'artifact_versioning', action: 'commit', artifacts: ['simulation_results.h5', 'analysis_plots.png'], message: 'Updated simulation with new parameters' }); expect(result.success).toBe(true); expect(result.version_id).toBeDefined(); }); test('Retrieve specific artifact version', async () => { const mockClient = createMockWorkerClient({ 'distributed_artifact_retrieve': { success: true, artifacts: ['simulation_results_v1.2.3.h5'], metadata: { created: '2024-01-15T09:00:00Z', author: 'alice@university.edu', description: 'Monte Carlo simulation with 10^6 samples' } } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'artifact_versioning', action: 'retrieve', version_id: 'v1.2.3' }); expect(result.success).toBe(true); expect(result.artifacts.length).toBeGreaterThan(0); }); test('Compare artifact versions', async () => { const mockClient = createMockWorkerClient({ 'distributed_artifact_diff': { success: true, differences: [ { field: 'temperature', old_value: 300, new_value: 350 }, { field: 'pressure', old_value: 1.0, new_value: 1.5 } ], similarity_score: 0.85 } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'artifact_versioning', action: 'diff', version_a: 'v1.2.2', version_b: 'v1.2.3' }); expect(result.success).toBe(true); expect(result.differences.length).toBeGreaterThan(0); }); }); describe('Error Handling and Security', () => { test('Invalid job submission should return error', async () => { const mockClient = createMockWorkerClient({ 'distributed_job_submit': { success: false, error: 'Insufficient resources available' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_submit', job_type: 'computation', resources: { cpu: 1000, memory: '1TB' } // Unrealistic resources }); expect(result.success).toBe(false); expect(result.error).toBeDefined(); }); test('Unauthorized session access should return error', async () => { const mockClient = createMockWorkerClient({ 'distributed_session_join': { success: false, error: 'Invalid access code' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_join', access_code: 'INVALID123' }); expect(result.success).toBe(false); expect(result.error).toContain('Invalid access code'); }); test('Missing authentication should return error', async () => { const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_share' // Missing auth_token }); expect(result.success).toBe(false); }); }); describe('Performance and Scalability', () => { test('Large-scale job submission', async () => { const mockClient = createMockWorkerClient({ 'distributed_job_batch': { success: true, submitted_jobs: 100, batch_id: 'batch_456', estimated_completion: '2024-01-16T10:00:00Z' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'job_batch', jobs: Array.from({length: 100}, (_, i) => ({ script: `simulation_${i}.py`, resources: { cpu: 2, memory: '4GB' } })) }); expect(result.success).toBe(true); expect(result.submitted_jobs).toBe(100); }); test('High-frequency session synchronization', async () => { const mockClient = createMockWorkerClient({ 'distributed_session_sync': { success: true, sync_frequency: '1s', bandwidth_used: '150KB/s', latency: '25ms' } }); jest.doMock('../../tools-cas/dist/worker-client.js', () => ({ getWorkerClient: () => mockClient })); const result = await handleDistributedCollaborationTool('distributed_collaboration', { method: 'session_sync', session_id: 'session_abc123', real_time: true }); expect(result.success).toBe(true); expect(result.latency).toBeDefined(); }); }); });

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/BlinkZer0/Phys-MCP'

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