Skip to main content
Glama
test_stateless_simple.py•3.62 kB
#!/usr/bin/env python3 """Simple test for the stateless MCP server.""" import tempfile import sys from pathlib import Path print("šŸ”§ Starting test script...") # Add the src directory to the path sys.path.insert(0, str(Path(__file__).parent / "src")) from quantalogic_markdown_mcp.mcp_server import MarkdownMCPServer def test_stateless_server(): """Test basic functionality of the stateless server.""" print("šŸ”§ Starting stateless server test...") # Create a temporary markdown file with tempfile.NamedTemporaryFile(mode='w', suffix='.md', delete=False) as f: f.write("""# Test Document ## Introduction This is a test document for the stateless server. ## Features - Feature 1 - Feature 2 ## Conclusion End of document. """) temp_path = f.name print(f"šŸ“„ Created test document: {temp_path}") try: # Initialize the server print("šŸš€ Initializing MCP server...") server = MarkdownMCPServer() print("āœ… Server initialized successfully!") # Test list_sections print("\nšŸ“‹ Testing list_sections...") result = server.call_tool_sync("list_sections", {"document_path": temp_path}) print(f" Result: {result.get('success', False)}") if result.get('success'): sections = result.get('sections', []) print(f" Found {len(sections)} sections") for section in sections: print(f" - {section.get('title', 'Unknown')} (ID: {section.get('id', 'Unknown')})") # Test get_section if result.get('success') and result.get('sections'): first_section_id = result['sections'][0]['id'] print(f"\nšŸ“– Testing get_section with ID: {first_section_id}...") result = server.call_tool_sync("get_section", {"document_path": temp_path, "section_id": first_section_id}) print(f" Result: {result.get('success', False)}") if result.get('success'): section = result.get('section', {}) print(f" Retrieved: {section.get('title', 'Unknown')}") # Test insert_section print("\nāž• Testing insert_section...") result = server.call_tool_sync("insert_section", { "document_path": temp_path, "heading": "New Section", "content": "This is a new section added by the stateless server.", "position": 2 }) print(f" Result: {result.get('success', False)}") # Verify the section was added print("\nšŸ” Verifying section was added...") result = server.call_tool_sync("list_sections", {"document_path": temp_path}) print(f" Result: {result.get('success', False)}") if result.get('success'): sections = result.get('sections', []) print(f" Now have {len(sections)} sections") for section in sections: print(f" - {section.get('title', 'Unknown')} (ID: {section.get('id', 'Unknown')})") print("\nāœ… All tests completed successfully!") return True except Exception as e: print(f"\nāŒ Error during testing: {e}") import traceback traceback.print_exc() return False finally: # Clean up Path(temp_path).unlink(missing_ok=True) if __name__ == "__main__": success = test_stateless_server() if success: print("\nšŸŽ‰ Test suite completed successfully!") else: print("\nšŸ’„ Test suite failed!") sys.exit(1)

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/quantalogic/quantalogic_markdown_mcp'

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