Skip to main content
Glama

Elasticsearch Knowledge Graph for MCP

by j3k0
empty-name-validation.test.ts2.2 kB
import { KnowledgeGraphClient } from '../src/kg-client.js'; import { createTestKGClient, cleanupTestData, TEST_ZONE_A } from './test-config.js'; describe('Empty Name Entity Validation', () => { let client: KnowledgeGraphClient; beforeAll(async () => { client = createTestKGClient(); await client.initialize(); await cleanupTestData(client); }); afterAll(async () => { await cleanupTestData(client); }); test('should reject entity creation with empty name', async () => { // Empty string await expect(client.saveEntity({ name: '', entityType: 'test', observations: ['Test observation'], relevanceScore: 1.0 }, TEST_ZONE_A)).rejects.toThrow('Entity name cannot be empty'); // Only whitespace await expect(client.saveEntity({ name: ' ', entityType: 'test', observations: ['Test observation'], relevanceScore: 1.0 }, TEST_ZONE_A)).rejects.toThrow('Entity name cannot be empty'); }); test('should reject entity deletion with empty name', async () => { // Empty string await expect(client.deleteEntity('', TEST_ZONE_A)) .rejects.toThrow('Entity name cannot be empty'); // Only whitespace await expect(client.deleteEntity(' ', TEST_ZONE_A)) .rejects.toThrow('Entity name cannot be empty'); }); test('should validate entity names in relationship creation', async () => { // First create a valid entity await client.saveEntity({ name: 'ValidEntity', entityType: 'test', observations: ['Valid entity for relationship test'], relevanceScore: 1.0 }, TEST_ZONE_A); // Empty 'from' entity name await expect(client.saveRelation({ from: '', to: 'ValidEntity', relationType: 'test_relation' }, TEST_ZONE_A, TEST_ZONE_A, { autoCreateMissingEntities: false })) .rejects.toThrow('Entity name cannot be empty'); // Empty 'to' entity name await expect(client.saveRelation({ from: 'ValidEntity', to: '', relationType: 'test_relation' }, TEST_ZONE_A, TEST_ZONE_A, { autoCreateMissingEntities: false })) .rejects.toThrow('Entity name cannot be empty'); }); });

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/j3k0/mcp-brain-tools'

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