Skip to main content
Glama

Agent Knowledge MCP

test_strict_validation.pyโ€ข3.18 kB
#!/usr/bin/env python3 """ Test script to verify strict schema validation is working properly. """ import sys import os import importlib.util # Import document_schema directly from the file spec = importlib.util.spec_from_file_location("document_schema", os.path.join(os.path.dirname(__file__), '..', 'src', 'document_schema.py')) document_schema = importlib.util.module_from_spec(spec) spec.loader.exec_module(document_schema) validate_document_structure = document_schema.validate_document_structure DocumentValidationError = document_schema.DocumentValidationError import json def test_strict_validation(): """Test strict validation functionality.""" print("๐Ÿงช Testing strict schema validation...") # Test 1: Valid knowledge base document print("\n๐Ÿ“‹ Test 1: Valid knowledge base document") valid_doc = { "id": "test-doc-1", "title": "Test Document", "summary": "A test document", "file_path": "test.md", "file_name": "test.md", "directory": "", "priority": "medium", "tags": ["test"], "source_type": "markdown", "last_modified": "2025-01-04T10:30:00Z", "key_points": ["Point 1", "Point 2"], "related": [] } try: result = validate_document_structure(valid_doc, is_knowledge_doc=True) print("โœ… Valid document passed validation") except DocumentValidationError as e: print(f"โŒ Valid document failed: {e}") # Test 2: Knowledge base document with extra fields (should fail if strict mode enabled) print("\n๐Ÿ“‹ Test 2: Knowledge base document with extra fields") doc_with_extra = valid_doc.copy() doc_with_extra["extra_field"] = "This should not be allowed" doc_with_extra["another_extra"] = "Neither should this" try: result = validate_document_structure(doc_with_extra, is_knowledge_doc=True) print("โš ๏ธ Document with extra fields passed (strict mode may be disabled)") except DocumentValidationError as e: print(f"โœ… Document with extra fields correctly rejected: {e}") # Test 3: Non-knowledge document print("\n๐Ÿ“‹ Test 3: Non-knowledge document") custom_doc = { "name": "Custom Document", "data": {"key": "value"}, "timestamp": "2025-01-04" } try: result = validate_document_structure(custom_doc, is_knowledge_doc=False) print("โœ… Custom document passed validation") except DocumentValidationError as e: print(f"โŒ Custom document failed: {e}") # Test 4: Missing required fields print("\n๐Ÿ“‹ Test 4: Knowledge base document missing required fields") incomplete_doc = { "id": "incomplete-doc", "title": "Incomplete Document" # Missing other required fields } try: result = validate_document_structure(incomplete_doc, is_knowledge_doc=True) print("โš ๏ธ Incomplete document passed (validation may be lenient)") except DocumentValidationError as e: print(f"โœ… Incomplete document correctly rejected: {e}") if __name__ == "__main__": test_strict_validation()

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/itshare4u/AgentKnowledgeMCP'

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