server.ts•1.22 kB
/**
* Teamserver-related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createServerTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'get_teamserver_info',
description: 'Get information about the Cobalt Strike teamserver (version, license, stats)',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'test_connection',
description: 'Test the connection to the Cobalt Strike REST API server',
inputSchema: {
type: 'object',
properties: {},
},
},
];
}
export async function handleServerTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'get_teamserver_info':
const info = await client.getTeamServerInfo();
return JSON.stringify(info, null, 2);
case 'test_connection':
const connected = await client.testConnection();
return JSON.stringify({ connected, message: connected ? 'Connection successful' : 'Connection failed' }, null, 2);
default:
throw new Error(`Unknown server tool: ${name}`);
}
}