Skip to main content
Glama
tools.test.ts5.56 kB
// Tools registration and validation tests import { describe, it, expect } from '@jest/globals'; describe('MCP Tools', () => { it('should have WordPress tools defined', async () => { const { createWordPressTools } = await import('../src/tools/wordpress-tools'); expect(createWordPressTools).toBeDefined(); expect(typeof createWordPressTools).toBe('function'); }); it('should have Elementor tools defined', async () => { const { createElementorTools } = await import('../src/tools/elementor-tools'); expect(createElementorTools).toBeDefined(); expect(typeof createElementorTools).toBe('function'); }); it('should create tool structure with required fields', async () => { // Mock services const mockWpService = { posts: { listPosts: async () => ({ posts: [], total: 0 }) }, pages: { listPages: async () => ({ pages: [], total: 0 }), listAllContent: async () => ({}) }, media: { getMedia: async () => ({ media: [], total: 0 }), uploadMedia: async () => ({}) }, users: { listUsers: async () => ({ users: [], total: 0 }), createUser: async () => ({}) }, taxonomy: { listCategories: async () => ({ categories: [], total: 0 }), createCategory: async () => ({}), listTags: async () => ({ tags: [], total: 0 }), createTag: async () => ({}) } } as any; const { createWordPressTools } = await import('../src/tools/wordpress-tools'); const tools = createWordPressTools(mockWpService); expect(tools.length).toBeGreaterThan(0); tools.forEach(tool => { expect(tool).toHaveProperty('name'); expect(tool).toHaveProperty('description'); expect(tool).toHaveProperty('inputSchema'); expect(tool).toHaveProperty('handler'); expect(typeof tool.handler).toBe('function'); }); }); it('should have unique tool names', async () => { const mockWpService = { posts: { listPosts: async () => ({ posts: [], total: 0 }) }, pages: { listPages: async () => ({ pages: [], total: 0 }), listAllContent: async () => ({}) }, media: { getMedia: async () => ({ media: [], total: 0 }), uploadMedia: async () => ({}) }, users: { listUsers: async () => ({ users: [], total: 0 }), createUser: async () => ({}) }, taxonomy: { listCategories: async () => ({ categories: [], total: 0 }), createCategory: async () => ({}), listTags: async () => ({ tags: [], total: 0 }), createTag: async () => ({}) } } as any; const mockElementorService = { data: { getElementorData: async () => ({ elements: [] }), updateElementorData: async () => {}, getElementorDataChunked: async () => ({}), backupElementorData: async () => ({}), clearElementorCache: async () => {} }, builder: { createSection: () => ({ id: 'test', elType: 'section', elements: [] }), createHeadingWidget: () => ({ id: 'test', elType: 'widget', widgetType: 'heading' }), createTextWidget: () => ({ id: 'test', elType: 'widget', widgetType: 'text-editor' }), createButtonWidget: () => ({ id: 'test', elType: 'widget', widgetType: 'button' }), createImageWidget: () => ({ id: 'test', elType: 'widget', widgetType: 'image' }), createContainer: () => ({ id: 'test', elType: 'container', elements: [] }) }, manipulation: { findElementById: () => ({ element: null, parent: null, index: -1 }), updateElement: () => true, deleteElement: () => true, moveElement: () => true, reorderElements: () => true, copyElementSettings: () => true, cloneElement: () => ({ id: 'test', elType: 'section', elements: [] }), getPageStructure: () => [], findElementsByType: () => [], findWidgetsByType: () => [] }, templates: { getTemplates: async () => ({ templates: [], total: 0 }), createTemplate: async () => ({}), applyTemplateToPage: async () => {} } } as any; const { createWordPressTools } = await import('../src/tools/wordpress-tools'); const { createElementorTools } = await import('../src/tools/elementor-tools'); const wpTools = createWordPressTools(mockWpService); const elementorTools = createElementorTools(mockElementorService); const allTools = [...wpTools, ...elementorTools]; const toolNames = allTools.map(t => t.name); const uniqueNames = new Set(toolNames); expect(uniqueNames.size).toBe(toolNames.length); }); it('should have all required tool categories', async () => { const mockWpService = { posts: { listPosts: async () => ({ posts: [], total: 0 }), getPost: async () => ({}), createPost: async () => ({}), updatePost: async () => ({}) }, pages: { listPages: async () => ({ pages: [], total: 0 }), createPage: async () => ({}), updatePage: async () => ({}), listAllContent: async () => ({}) }, media: { getMedia: async () => ({ media: [], total: 0 }), uploadMedia: async () => ({}) }, users: { listUsers: async () => ({ users: [], total: 0 }), createUser: async () => ({}) }, taxonomy: { listCategories: async () => ({ categories: [], total: 0 }), createCategory: async () => ({}), listTags: async () => ({ tags: [], total: 0 }), createTag: async () => ({}) } } as any; const { createWordPressTools } = await import('../src/tools/wordpress-tools'); const wpTools = createWordPressTools(mockWpService); const toolNames = wpTools.map(t => t.name); // Verify we have tools from each category expect(toolNames).toContain('get_posts'); expect(toolNames).toContain('create_page'); expect(toolNames).toContain('get_media'); expect(toolNames).toContain('get_users'); expect(toolNames).toContain('get_categories'); }); });

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/mbrown1837/Ultimate-Elementor-MCP'

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