db_hosts
List all hosts in a Metasploit workspace to manage penetration testing targets and organize network reconnaissance data.
Instructions
List all hosts in the current workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | No | Optional: workspace name to query |
Implementation Reference
- src/index.ts:469-506 (handler)Handler for the 'db_hosts' tool: executes Metasploit 'hosts' command (optionally after switching workspace) via executeMsfCommand and returns formatted JSON response.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:156-164 (schema)Input schema for 'db_hosts' tool defining optional 'workspace' parameter.inputSchema: { type: "object", properties: { workspace: { type: "string", description: "Optional: workspace name to query", }, }, },
- src/index.ts:153-165 (registration)Registration of the 'db_hosts' tool in the MCP tools array, including name, description, and input schema.{ name: "db_hosts", description: "List all hosts in the current workspace", inputSchema: { type: "object", properties: { workspace: { type: "string", description: "Optional: workspace name to query", }, }, }, },