Skip to main content
Glama
smithery-server.test.ts4.38 kB
/** * Tests for Smithery Server */ import createStatelessServer, { configSchema } from '../src/smithery-server'; describe('Smithery Server', () => { describe('configSchema', () => { it('should validate default configuration', () => { const config = configSchema.parse({}); expect(config.rpcUrl).toBe('https://hyperion-testnet.metisdevops.link'); expect(config.chainId).toBe(133717); expect(config.networkName).toBe('Hyperion Testnet'); expect(config.currencySymbol).toBe('tMETIS'); expect(config.explorerUrl).toBe('https://hyperion-testnet-explorer.metisdevops.link'); expect(config.debug).toBe(false); }); it('should validate custom configuration', () => { const customConfig = { rpcUrl: 'https://custom-rpc.example.com', chainId: 12345, networkName: 'Custom Network', currencySymbol: 'CUSTOM', explorerUrl: 'https://custom-explorer.example.com', debug: true, }; const config = configSchema.parse(customConfig); expect(config.rpcUrl).toBe('https://custom-rpc.example.com'); expect(config.chainId).toBe(12345); expect(config.networkName).toBe('Custom Network'); expect(config.currencySymbol).toBe('CUSTOM'); expect(config.explorerUrl).toBe('https://custom-explorer.example.com'); expect(config.debug).toBe(true); }); it('should use defaults for missing optional fields', () => { const partialConfig = { rpcUrl: 'https://custom-rpc.example.com', chainId: 12345, }; const config = configSchema.parse(partialConfig); expect(config.rpcUrl).toBe('https://custom-rpc.example.com'); expect(config.chainId).toBe(12345); expect(config.networkName).toBe('Hyperion Testnet'); // default expect(config.currencySymbol).toBe('tMETIS'); // default expect(config.debug).toBe(false); // default }); }); describe('createStatelessServer', () => { it('should create a server with default configuration', () => { const config = configSchema.parse({}); const server = createStatelessServer({ config }); expect(server).toBeDefined(); expect(typeof server).toBe('object'); }); it('should create a server with custom configuration', () => { const customConfig = configSchema.parse({ rpcUrl: 'https://custom-rpc.example.com', chainId: 12345, networkName: 'Custom Network', debug: true, }); const server = createStatelessServer({ config: customConfig }); expect(server).toBeDefined(); expect(typeof server).toBe('object'); }); it('should handle configuration validation errors', () => { expect(() => { // Invalid configuration - chainId should be number configSchema.parse({ chainId: 'invalid', }); }).toThrow(); }); }); describe('server functionality', () => { let server: any; beforeEach(() => { const config = configSchema.parse({ debug: true, // Enable debug mode for tests }); server = createStatelessServer({ config }); }); it('should have the correct server name and version', () => { // Note: This test assumes the server object has name and version properties // The actual structure depends on the MCP SDK implementation expect(server).toBeDefined(); }); it('should be ready for MCP protocol communication', () => { // Basic test to ensure server object is properly structured expect(server).toBeDefined(); expect(typeof server).toBe('object'); }); }); describe('environment integration', () => { it('should work with test environment variables', () => { // Test that the server can be created with environment-based config const config = configSchema.parse({ rpcUrl: process.env.HYPERION_RPC_URL || 'https://hyperion-testnet.metisdevops.link', chainId: process.env.HYPERION_CHAIN_ID ? parseInt(process.env.HYPERION_CHAIN_ID, 10) : 133717, }); const server = createStatelessServer({ config }); expect(server).toBeDefined(); expect(config.rpcUrl).toBe('https://hyperion-testnet.metisdevops.link'); expect(config.chainId).toBe(133717); }); }); });

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/cuongpo/hyperion-mcp-server'

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