Skip to main content
Glama
test_direct.pyโ€ข3.48 kB
#!/usr/bin/env python3 """Simple direct test for the stateless MCP server.""" import tempfile from pathlib import Path from quantalogic_markdown_mcp.mcp_server import MarkdownMCPServer def main(): 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}...") get_result = server.call_tool_sync("get_section", {"document_path": temp_path, "section_id": first_section_id}) print(f" Result: {get_result.get('success', False)}") if get_result.get('success'): section = get_result.get('section', {}) print(f" Retrieved: {section.get('title', 'Unknown')}") # Test insert_section print("\nโž• Testing insert_section...") insert_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: {insert_result.get('success', False)}") # Verify the section was added print("\n๐Ÿ” Verifying section was added...") final_result = server.call_tool_sync("list_sections", {"document_path": temp_path}) print(f" Result: {final_result.get('success', False)}") if final_result.get('success'): sections = final_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) print("๐Ÿงน Cleaned up test file") if __name__ == "__main__": success = main() if success: print("\n๐ŸŽ‰ Test suite completed successfully!") else: print("\n๐Ÿ’ฅ Test suite failed!") 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