Skip to main content
Glama

get_summary_stats

Analyze live network traffic on a specified interface to generate protocol hierarchy statistics, aiding in network diagnostics and LLM insights. Configure duration and interface for precise captures.

Instructions

Capture live traffic and provide protocol hierarchy statistics for LLM analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationNoCapture duration in seconds
interfaceNoNetwork interface to capture from (e.g., eth0, en0)en0

Implementation Reference

  • The main handler function implementing the get_summary_stats tool. Captures live network traffic using tshark for the specified duration and interface, then generates protocol hierarchy statistics (-qz io,phs) and returns them as text content.
    async (args) => { try { const tsharkPath = await findTshark(); const { interface, duration } = args; const tempPcap = 'temp_capture.pcap'; console.error(`Capturing summary stats on ${interface} for ${duration}s`); await execAsync( `${tsharkPath} -i ${interface} -w ${tempPcap} -a duration:${duration}`, { env: { ...process.env, PATH: `${process.env.PATH}:/usr/bin:/usr/local/bin:/opt/homebrew/bin` } } ); const { stdout, stderr } = await execAsync( `${tsharkPath} -r "${tempPcap}" -qz io,phs`, { env: { ...process.env, PATH: `${process.env.PATH}:/usr/bin:/usr/local/bin:/opt/homebrew/bin` } } ); if (stderr) console.error(`tshark stderr: ${stderr}`); await fs.unlink(tempPcap).catch(err => console.error(`Failed to delete ${tempPcap}: ${err.message}`)); return { content: [{ type: 'text', text: `Protocol hierarchy statistics for LLM analysis:\n${stdout}`, }], }; } catch (error) { console.error(`Error in get_summary_stats: ${error.message}`); return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true }; } }
  • Zod schema defining input parameters for get_summary_stats: optional interface (default 'en0') and duration (default 5 seconds).
    { interface: z.string().optional().default('en0').describe('Network interface to capture from (e.g., eth0, en0)'), duration: z.number().optional().default(5).describe('Capture duration in seconds'), },
  • index.js:100-138 (registration)
    The server.tool() call registering the get_summary_stats tool, including its name, description, input schema, and handler function reference.
    server.tool( 'get_summary_stats', 'Capture live traffic and provide protocol hierarchy statistics for LLM analysis', { interface: z.string().optional().default('en0').describe('Network interface to capture from (e.g., eth0, en0)'), duration: z.number().optional().default(5).describe('Capture duration in seconds'), }, async (args) => { try { const tsharkPath = await findTshark(); const { interface, duration } = args; const tempPcap = 'temp_capture.pcap'; console.error(`Capturing summary stats on ${interface} for ${duration}s`); await execAsync( `${tsharkPath} -i ${interface} -w ${tempPcap} -a duration:${duration}`, { env: { ...process.env, PATH: `${process.env.PATH}:/usr/bin:/usr/local/bin:/opt/homebrew/bin` } } ); const { stdout, stderr } = await execAsync( `${tsharkPath} -r "${tempPcap}" -qz io,phs`, { env: { ...process.env, PATH: `${process.env.PATH}:/usr/bin:/usr/local/bin:/opt/homebrew/bin` } } ); if (stderr) console.error(`tshark stderr: ${stderr}`); await fs.unlink(tempPcap).catch(err => console.error(`Failed to delete ${tempPcap}: ${err.message}`)); return { content: [{ type: 'text', text: `Protocol hierarchy statistics for LLM analysis:\n${stdout}`, }], }; } catch (error) { console.error(`Error in get_summary_stats: ${error.message}`); return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true }; } } );
  • Helper function findTshark() used by the handler to dynamically locate the tshark executable, with platform-specific fallbacks.
    async function findTshark() { try { const tsharkPath = await which('tshark'); console.error(`Found tshark at: ${tsharkPath}`); return tsharkPath; } catch (err) { console.error('which failed to find tshark:', err.message); const fallbacks = process.platform === 'win32' ? ['C:\\Program Files\\Wireshark\\tshark.exe', 'C:\\Program Files (x86)\\Wireshark\\tshark.exe'] : ['/usr/bin/tshark', '/usr/local/bin/tshark', '/opt/homebrew/bin/tshark', '/Applications/Wireshark.app/Contents/MacOS/tshark']; for (const path of fallbacks) { try { await execAsync(`${path} -v`); console.error(`Found tshark at fallback: ${path}`); return path; } catch (e) { console.error(`Fallback ${path} failed: ${e.message}`); } } throw new Error('tshark not found. Please install Wireshark (https://www.wireshark.org/download.html) and ensure tshark is in your PATH.'); } }

Other Tools

Related Tools

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/0xKoda/WireMCP'

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