Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const execAsync = promisify(exec);
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
const { z } = require('zod');
const path = require('node:path');

// Redirect console.log to stderr
const originalConsoleLog = console.log;
Expand Down Expand Up @@ -51,12 +52,13 @@ server.tool(
{
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'),
directory: z.string().optional().default('/tmp').describe('Directory to store temp pcap files.'),
},
async (args) => {
try {
const tsharkPath = await findTshark();
const { interface, duration } = args;
const tempPcap = 'temp_capture.pcap';
const { interface, duration, directory } = args;
const tempPcap = path.join(directory, 'temp_capture.pcap');
console.error(`Capturing packets on ${interface} for ${duration}s`);

await execAsync(
Expand Down Expand Up @@ -660,4 +662,4 @@ server.connect(new StdioServerTransport())
.catch(err => {
console.error('Failed to start WireMCP:', err);
process.exit(1);
});
});