tasks.ts•3.31 kB
/**
* Task-related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createTaskTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'list_tasks',
description: 'List all tasks across all beacons or filter by beacon ID',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'Optional beacon ID to filter tasks',
},
},
},
},
{
name: 'get_task',
description: 'Get detailed information about a specific task by ID',
inputSchema: {
type: 'object',
properties: {
taskId: {
type: 'string',
description: 'The ID of the task to retrieve',
},
},
required: ['taskId'],
},
},
{
name: 'get_task_error',
description: 'Get error information for a specific task',
inputSchema: {
type: 'object',
properties: {
taskId: {
type: 'string',
description: 'The ID of the task',
},
},
required: ['taskId'],
},
},
{
name: 'get_task_log',
description: 'Get log information for a specific task',
inputSchema: {
type: 'object',
properties: {
taskId: {
type: 'string',
description: 'The ID of the task',
},
},
required: ['taskId'],
},
},
{
name: 'get_beacon_tasks_summary',
description: 'Get task summary for a specific beacon',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
{
name: 'get_beacon_tasks_detail',
description: 'Get detailed task information for a specific beacon',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
];
}
export async function handleTaskTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'list_tasks':
const tasks = await client.listTasks(args.beaconId);
return JSON.stringify(tasks, null, 2);
case 'get_task':
const task = await client.getTask(args.taskId);
return JSON.stringify(task, null, 2);
case 'get_task_error':
const error = await client.getTaskError(args.taskId);
return JSON.stringify(error, null, 2);
case 'get_task_log':
const log = await client.getTaskLog(args.taskId);
return JSON.stringify(log, null, 2);
case 'get_beacon_tasks_summary':
const summary = await client.getBeaconTasksSummary(args.beaconId);
return JSON.stringify(summary, null, 2);
case 'get_beacon_tasks_detail':
const detail = await client.getBeaconTasksDetail(args.beaconId);
return JSON.stringify(detail, null, 2);
default:
throw new Error(`Unknown task tool: ${name}`);
}
}