Skip to main content
Glama

Wireshark MCP Server

test_server.cpython-310.pyc5.6 kB
o �UhD�@s�dZddlZddlZddlZddlmZej�deee �j ��ddl Z e j �dd�Ze j �e�Zej�e�ejZejZdd�Zdd �Zd d �Zed krRe�dSdS) z� Test script for Wireshark MCP Server This script tests the core functionality of the Wireshark MCP server without requiring a full MCP client setup. �N)�Path�wireshark_mcp_serverzwireshark-mcp-server.pyc �s��td�td�z'td�t�}td|j���|jr$td|j���|jr/td|j���WntyJ}ztd|���WYd}~d Sd}~wwtd �zM|��}|d d kr�td |d�d��t|ddd��D]\}}td|d�d|���qn|ddkr�td|dd�d��n td|d���Wnty�}z td|���WYd}~nd}~wwtd�gd�}|D]}t� |�}|r�dnd}td|�d|�d |r�d!nd"���q�gd#�} | D]} t� | �}|r�dnd}td|�d$| �d |r�d!nd"���q�td%�zV|��}|d d k�rY|d�rY|dd&} d| v�r,| � d�d&} nd'} td(| ���|j | dd)d*�} | d d k�rOtd+| d,�d-��ntd.| d���ntd/�Wnt�yx}z td0|���WYd}~nd}~wwtd1�gd2�}|D]#}t� |�}|�r�dnd}|�r�|nd3}td|�d4|�d |����q�td5�td6�td7�td8�td9�td:�d;S)<z+Test the Wireshark interface functionality.u,🧪 Testing Wireshark MCP Server Componentsz2==================================================z01. Testing Wireshark Interface Initialization...u ✅ TShark found at: u ✅ Dumpcap found at: u ✅ Capinfos found at: u/ ❌ Error initializing Wireshark interface: NFz( 2. Testing Network Interface Listing...�status�successu ✅ Found �countz network interfaces:� interfaces�z �z. z ... and z moreu$ ⚠️ Interface listing issue: �messageu! ❌ Error listing interfaces: z" 3. Testing Security Validation...)�eth0�wlan0z Ethernet 2zWi-Fi�1zinvalid;command� ../etc/passwdu✅u❌z z Interface 'z': �Valid�Invalid)z tcp port 80zhost 192.168.1.1z tcp; rm -rf /z normal filterz Filter 'z2 4. Testing Live Capture (if permissions allow)...rr z! Testing capture on interface: � )r�timeoutu ✅ Successfully captured � packet_countz packetsuN ⚠️ Capture test failed (this is expected without proper permissions): u. ⚠️ No interfaces available for testingu? ⚠️ Capture test failed (expected without permissions): z! 5. Testing File Path Security...)z/tmp/test.pcaprzC:\Windows\System32\test.pcapz./nonexistent.pcapztest.txt�Rejectedz Path 'u" 🎉 Component testing completed!z Next steps:z81. Install requirements: pip install -r requirements.txtz42. Configure Claude Desktop with the provided configz03. Test with Claude Desktop or other MCP clientsz44. Ensure proper network capture permissions are setT)�print�WiresharkInterface� tshark_path� dumpcap_path� capinfos_path� Exception�get_interfaces� enumerate�SecurityValidator�validate_interface�validate_capture_filter�split�capture_packets�sanitize_filepath)� wireshark�e�interfaces_result�i� interface�test_interfaces�iface�is_validr� test_filters� filter_expr�first_interface� interface_id�capture_result� test_paths�path� sanitized�result�r4�test_server.py�test_wireshark_interfaces�����  ����  $  $  ��� r6c �s��td�z)tj}td�|�}td�td�td�td�td�td�td �Wd StyL}ztd |���td �WYd }~dSd }~wtye}ztd|���WYd }~dSd }~ww)z,Test the full MCP server (requires FastMCP).z% 6. Testing MCP Server Integration...u- ✅ MCP Server class imported successfullyu* ✅ MCP Server initialized successfullyu 📋 Registered tools:z - get_network_interfaces()z - capture_live_packets()z - analyze_pcap_file()z! - get_protocol_statistics()z - get_capture_file_info()Tu" ⚠️ FastMCP not installed: u) 💡 Install with: pip install fastmcpNFu! ❌ Error testing MCP server: )rr�WiresharkMCPServer� ImportErrorr)r7�serverr$r4r4r5�test_mcp_server{s0����r:c Cs�td�td�t��}t�|�zXz|�t��}|�t��|r*td�td�ntd�Wn%ty<td�Yn tyT}z td|���WYd}~nd}~wwW|� �dSW|� �dSW|� �dS|� �w) zMain test function.z&Wireshark MCP Server - Component Testsz%=====================================u" ✅ Basic component tests passed!z6The server should be ready for MCP client integration.u/ ❌ Some tests failed. Check the output above.u! ⏹️ Test interrupted by useru& ❌ Unexpected error during testing: N) r�asyncio�new_event_loop�set_event_loop�run_until_completer6r:�KeyboardInterruptr�close)�looprr$r4r4r5�main�s0    �  ��� � �rB�__main__)�__doc__r;�json�sys�pathlibrr1�insert�str�__file__�parent�importlib.util� importlib�util�spec_from_file_location�spec�module_from_specr�loader� exec_modulerrr6r:rB�__name__r4r4r4r5�<module>s$   a �

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/mixelpixx/Wireshark-MCP'

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