Skip to main content
Glama
tuliperis

SharkMCP

by tuliperis

analyze_pcap_file

Analyze network packet capture files to extract traffic data, apply filters, and generate reports for security analysis and troubleshooting.

Instructions

Analyze a local pcap/pcapng file. LLMs control all analysis parameters including filters, output formats, and custom fields. Can use saved configurations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the local .pcap or .pcapng file to analyze.
displayFilterNoWireshark display filter for analysis (e.g., "tls.handshake.type == 1")
outputFormatNoOutput format: json (-T json), fields (custom -e), or text (default wireshark output)text
customFieldsNoCustom tshark field list (only used with outputFormat=fields)
sslKeylogFileNoABSOLUTE path to SSL keylog file for TLS decryption
configNameNoName of saved configuration to use for analysis parameters

Implementation Reference

  • The main asynchronous handler function that performs PCAP file analysis, handling input arguments, loading configurations if specified, verifying file existence, calling the shared analyzePcap utility, trimming output, and returning formatted results or errors.
    export async function analyzePcapFileHandler(args: any) {
      try {
        let { filePath, displayFilter, outputFormat, customFields, sslKeylogFile, configName } = args;
    
        // If configName is provided, load and use that configuration for analysis
        if (configName) {
          const savedConfig = await loadFilterConfig(configName);
          if (!savedConfig) {
            return {
              content: [{
                type: 'text' as const,
                text: `Error: Configuration '${configName}' not found. Use manage_config with action 'list' to see available configurations.`,
              }],
              isError: true
            };
          }
          
          // Override analysis parameters with saved config (saved config takes precedence)
          if (savedConfig.displayFilter) displayFilter = savedConfig.displayFilter;
          if (savedConfig.outputFormat) outputFormat = savedConfig.outputFormat;
          if (savedConfig.customFields) customFields = savedConfig.customFields;
          
          console.error(`Using saved configuration '${configName}' for analysis: ${JSON.stringify(savedConfig)}`);
        }
    
        // Verify file exists before proceeding
        await fs.access(filePath);
    
        // Analyze the file using the reusable function
        const output = await analyzePcap(
          filePath,
          displayFilter,
          outputFormat,
          customFields,
          sslKeylogFile
        );
    
        const keylogToUse = sslKeylogFile || process.env.SSLKEYLOGFILE;
    
        // Trim output if too large
        const trimmedOutput = trimOutput(output, outputFormat);
    
        const configInfo = configName ? `\nUsing saved config: ${configName}` : '';
        
        return {
          content: [{
            type: 'text' as const,
            text: `Analysis of '${filePath}' complete!${configInfo}\nDisplay Filter: ${displayFilter || 'none'}\nOutput Format: ${outputFormat}\nSSL Decryption: ${keylogToUse ? 'Enabled' : 'Disabled'}\n\nPacket Analysis Results:\n${trimmedOutput}`,
          }],
        };
      } catch (error: any) {
        console.error(`Error analyzing PCAP file: ${error.message}`);
        return { 
          content: [{ type: 'text' as const, text: `Error: ${error.message}` }], 
          isError: true 
        };
      }
    } 
  • Input schema using Zod for validating tool parameters including file path, display filter, output format, custom fields, SSL keylog file, and optional config name.
    export const analyzePcapFileSchema = {
      filePath: z.string().describe('Path to the local .pcap or .pcapng file to analyze.'),
      displayFilter: z.string().optional().describe('Wireshark display filter for analysis (e.g., "tls.handshake.type == 1")'),
      outputFormat: z.enum(['json', 'fields', 'text']).optional().default('text').describe('Output format: json (-T json), fields (custom -e), or text (default wireshark output)'),
      customFields: z.string().optional().describe('Custom tshark field list (only used with outputFormat=fields)'),
      sslKeylogFile: z.string().optional().describe('ABSOLUTE path to SSL keylog file for TLS decryption'),
      configName: z.string().optional().describe('Name of saved configuration to use for analysis parameters')
    };
  • src/index.ts:39-45 (registration)
    MCP server tool registration for 'analyze_pcap_file', specifying the tool name, description, input schema, and handler function.
    // Tool 3: Analyze an existing PCAP file
    server.tool(
      'analyze_pcap_file',
      'Analyze a local pcap/pcapng file. LLMs control all analysis parameters including filters, output formats, and custom fields. Can use saved configurations.',
      analyzePcapFileSchema,
      async (args) => analyzePcapFileHandler(args)
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that 'LLMs control all analysis parameters' and 'can use saved configurations', but fails to describe critical behaviors like whether this is a read-only analysis, what happens with invalid inputs, performance implications for large files, or error handling. This leaves significant gaps for a tool with 6 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that directly address the tool's functionality. It's front-loaded with the core purpose and efficiently mentions key capabilities without unnecessary elaboration, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (6 parameters, no annotations, no output schema), the description is insufficient. It doesn't explain what the analysis returns, how results are structured, error conditions, or performance considerations. For a tool that analyzes network capture files—a potentially complex operation—this leaves too many contextual gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema, mentioning 'filters, output formats, and custom fields' and 'saved configurations' which map to parameters but don't provide additional semantic context. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('analyze') and resource ('a local pcap/pcapng file'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'start_capture_session' or 'manage_config', which would require a more specific comparison to achieve a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its siblings (e.g., 'start_capture_session' for live capture vs. file analysis) or any prerequisites. It mentions 'saved configurations' but doesn't explain when they're appropriate, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/tuliperis/SharkMCP'

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