db_hosts
Lists all hosts discovered in the current Metasploit workspace to provide visibility into target systems during penetration testing and security assessments.
Instructions
List all hosts in the current workspace
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | No | Optional: workspace name to query |
Input Schema (JSON Schema)
{
"properties": {
"workspace": {
"description": "Optional: workspace name to query",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:469-506 (handler)Handler implementation for the 'db_hosts' tool. Extracts optional workspace from arguments, constructs msfconsole commands to switch workspace if specified and list hosts, executes them, and returns formatted JSON response or error.case "db_hosts": { const { workspace } = args as { workspace?: string }; const commands = workspace ? [`workspace ${workspace}`, `hosts`] : [`hosts`]; try { const hosts = await executeMsfCommand(commands); return { content: [ { type: "text", text: JSON.stringify( { success: true, workspace: workspace || "default", hosts, }, null, 2 ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: error.message, }), }, ], }; } }
- src/index.ts:153-165 (registration)Registration of the 'db_hosts' tool in the tools array passed to ListToolsRequestHandler. Includes name, description, and input schema definition.{ name: "db_hosts", description: "List all hosts in the current workspace", inputSchema: { type: "object", properties: { workspace: { type: "string", description: "Optional: workspace name to query", }, }, }, },
- src/index.ts:156-164 (schema)Input schema for the 'db_hosts' tool defining optional 'workspace' parameter.inputSchema: { type: "object", properties: { workspace: { type: "string", description: "Optional: workspace name to query", }, }, },