Skip to main content
Glama
VersionTool.test.ts1.77 kB
import { getVersionInfo } from '../../utils/versionUtils.js'; import { VersionTool } from './VersionTool'; jest.mock('../../utils/versionUtils.js', () => ({ getVersionInfo: jest.fn(() => ({ name: 'Test MCP Server', version: '1.0.0', sha: 'abc123', tag: 'v1.0.0', branch: 'main' })) })); const mockGetVersionInfo = getVersionInfo as jest.MockedFunction< typeof getVersionInfo >; describe('VersionTool', () => { let tool: VersionTool; beforeEach(() => { tool = new VersionTool(); }); describe('run', () => { it('should return version information', async () => { const result = await tool.run({}); expect(result.isError).toBe(false); expect(result.content).toHaveLength(1); expect(result.content[0].type).toBe('text'); expect(result.content[0].text).toContain('Test MCP Server'); expect(result.content[0].text).toContain('1.0.0'); expect(result.content[0].text).toContain('abc123'); expect(result.content[0].text).toContain('v1.0.0'); expect(result.content[0].text).toContain('main'); }); it('should handle errors gracefully', async () => { mockGetVersionInfo.mockImplementationOnce(() => { throw new Error('Version info not available'); }); const result = await tool.run({}); expect(result.isError).toBe(true); expect(result.content).toHaveLength(1); expect(result.content[0].type).toBe('text'); }); }); describe('properties', () => { it('should have correct name', () => { expect(tool.name).toBe('version_tool'); }); it('should have correct description', () => { expect(tool.description).toBe( 'Get the current version information of the MCP server' ); }); }); });

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/Waldzell-Agentics/mcp-server'

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