✅ WordPerfect Production Support: - Comprehensive WordPerfect processor with 5-layer fallback chain - Support for WP 4.2, 5.0-5.1, 6.0+ (.wpd, .wp, .wp5, .wp6) - libwpd integration (wpd2text, wpd2html, wpd2raw) - Binary strings extraction and emergency parsing - Password detection and encoding intelligence - Document structure analysis and integrity checking 🏗️ Infrastructure Enhancements: - Created comprehensive CLAUDE.md development guide - Updated implementation status documentation - Added WordPerfect processor test suite - Enhanced format detection with WP magic signatures - Production-ready with graceful dependency handling 📊 Project Status: - 2/4 core processors complete (dBASE + WordPerfect) - 25+ legacy format detection engine operational - Phase 2 complete: Ready for Lotus 1-2-3 implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
193 lines
6.5 KiB
Python
193 lines
6.5 KiB
Python
"""
|
|
Verify MCP Legacy Files installation and basic functionality.
|
|
"""
|
|
|
|
import asyncio
|
|
import tempfile
|
|
import os
|
|
from pathlib import Path
|
|
|
|
def create_test_files():
|
|
"""Create test files for verification."""
|
|
test_files = {}
|
|
|
|
# Create mock dBASE file
|
|
with tempfile.NamedTemporaryFile(suffix='.dbf', delete=False) as f:
|
|
# dBASE III header
|
|
header = bytearray(32)
|
|
header[0] = 0x03 # dBASE III version
|
|
header[1:4] = [24, 1, 1] # Date: 2024-01-01
|
|
header[4:8] = (5).to_bytes(4, 'little') # 5 records
|
|
header[8:10] = (97).to_bytes(2, 'little') # Header length (32 + 2*32 + 1)
|
|
header[10:12] = (20).to_bytes(2, 'little') # Record length
|
|
|
|
# Field descriptors for 2 fields (32 bytes each)
|
|
field1 = bytearray(32)
|
|
field1[0:8] = b'NAME ' # Field name
|
|
field1[11] = ord('C') # Character type
|
|
field1[16] = 15 # Field length
|
|
|
|
field2 = bytearray(32)
|
|
field2[0:8] = b'AGE ' # Field name
|
|
field2[11] = ord('N') # Numeric type
|
|
field2[16] = 3 # Field length
|
|
|
|
# Header terminator
|
|
terminator = b'\x0D'
|
|
|
|
# Sample records (20 bytes each)
|
|
record1 = b' John Doe 25 '
|
|
record2 = b' Jane Smith 30 '
|
|
record3 = b' Bob Johnson 45 '
|
|
record4 = b' Alice Brown 28 '
|
|
record5 = b' Charlie Davis 35 '
|
|
|
|
# Write complete file
|
|
f.write(header)
|
|
f.write(field1)
|
|
f.write(field2)
|
|
f.write(terminator)
|
|
f.write(record1)
|
|
f.write(record2)
|
|
f.write(record3)
|
|
f.write(record4)
|
|
f.write(record5)
|
|
f.flush()
|
|
|
|
test_files['dbase'] = f.name
|
|
|
|
# Create mock WordPerfect file
|
|
with tempfile.NamedTemporaryFile(suffix='.wpd', delete=False) as f:
|
|
# WordPerfect 6.0 signature + some content
|
|
content = b'\xFF\x57\x50\x43' + b'WordPerfect Document\x00Sample content for testing.\x00'
|
|
f.write(content)
|
|
f.flush()
|
|
test_files['wordperfect'] = f.name
|
|
|
|
return test_files
|
|
|
|
def cleanup_test_files(test_files):
|
|
"""Clean up test files."""
|
|
for file_path in test_files.values():
|
|
try:
|
|
os.unlink(file_path)
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
async def main():
|
|
"""Main verification routine."""
|
|
print("🏛️ MCP Legacy Files - Installation Verification")
|
|
print("=" * 60)
|
|
|
|
# Test imports
|
|
print("\n📦 Testing package imports...")
|
|
try:
|
|
from mcp_legacy_files import __version__
|
|
from mcp_legacy_files.core.detection import LegacyFormatDetector
|
|
from mcp_legacy_files.core.processing import ProcessingEngine
|
|
from mcp_legacy_files.core.server import app
|
|
print(f"✅ Package imported successfully - Version: {__version__}")
|
|
except ImportError as e:
|
|
print(f"❌ Import failed: {str(e)}")
|
|
return False
|
|
|
|
# Test core components
|
|
print("\n🔧 Testing core components...")
|
|
try:
|
|
detector = LegacyFormatDetector()
|
|
engine = ProcessingEngine()
|
|
print("✅ Core components initialized successfully")
|
|
except Exception as e:
|
|
print(f"❌ Component initialization failed: {str(e)}")
|
|
return False
|
|
|
|
# Test format detection
|
|
print("\n🔍 Testing format detection...")
|
|
test_files = create_test_files()
|
|
|
|
try:
|
|
# Test dBASE detection
|
|
dbase_info = await detector.detect_format(test_files['dbase'])
|
|
if dbase_info.format_family == 'dbase' and dbase_info.is_legacy_format:
|
|
print("✅ dBASE format detection working")
|
|
else:
|
|
print(f"⚠️ dBASE detection issue: {dbase_info.format_name}")
|
|
|
|
# Test WordPerfect detection
|
|
wp_info = await detector.detect_format(test_files['wordperfect'])
|
|
if wp_info.format_family == 'wordperfect' and wp_info.is_legacy_format:
|
|
print("✅ WordPerfect format detection working")
|
|
else:
|
|
print(f"⚠️ WordPerfect detection issue: {wp_info.format_name}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Format detection failed: {str(e)}")
|
|
return False
|
|
|
|
# Test dBASE processing
|
|
print("\n⚙️ Testing dBASE processing...")
|
|
try:
|
|
result = await engine.process_document(
|
|
file_path=test_files['dbase'],
|
|
format_info=dbase_info,
|
|
preserve_formatting=True,
|
|
method="auto",
|
|
enable_ai_enhancement=True
|
|
)
|
|
|
|
if result.success:
|
|
print("✅ dBASE processing successful")
|
|
if result.text_content and "John Doe" in result.text_content:
|
|
print("✅ Content extraction working")
|
|
else:
|
|
print("⚠️ Content extraction may have issues")
|
|
else:
|
|
print(f"⚠️ dBASE processing failed: {result.error_message}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ dBASE processing error: {str(e)}")
|
|
|
|
# Test supported formats
|
|
print("\n📋 Testing supported formats...")
|
|
try:
|
|
formats = await detector.get_supported_formats()
|
|
dbase_formats = [f for f in formats if f['format_family'] == 'dbase']
|
|
if dbase_formats:
|
|
print(f"✅ Format database loaded - {len(formats)} formats supported")
|
|
else:
|
|
print("⚠️ Format database may have issues")
|
|
except Exception as e:
|
|
print(f"❌ Format database error: {str(e)}")
|
|
|
|
# Test FastMCP server
|
|
print("\n🖥️ Testing FastMCP server...")
|
|
try:
|
|
# Just check that the app object exists and has tools
|
|
if hasattr(app, 'get_tools'):
|
|
tools = app.get_tools()
|
|
if tools:
|
|
print(f"✅ FastMCP server ready - {len(tools)} tools available")
|
|
else:
|
|
print("⚠️ No tools registered")
|
|
else:
|
|
print("✅ FastMCP app object created")
|
|
except Exception as e:
|
|
print(f"❌ FastMCP server error: {str(e)}")
|
|
|
|
# Cleanup
|
|
cleanup_test_files(test_files)
|
|
|
|
# Final status
|
|
print("\n" + "=" * 60)
|
|
print("🏆 Installation verification completed!")
|
|
print("\n💡 To start the MCP server:")
|
|
print(" mcp-legacy-files")
|
|
print("\n💡 To use the CLI:")
|
|
print(" legacy-files-cli detect <file>")
|
|
print(" legacy-files-cli process <file>")
|
|
print(" legacy-files-cli formats")
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |