getDockerInfo
Retrieve Docker configuration and status details from the current operating environment to assess container availability and system setup.
Instructions
获取当前设备的 Docker 信息,若未安装则返回空
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getDockerInfo"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:714-740 (handler)Handler for getDockerInfo tool: executes Docker CLI commands to retrieve version, images, and all containers; returns JSON or empty object if Docker not installed or error.
case "getDockerInfo": { let dockerInfo = {}; try { // 检查 Docker 是否安装 execSync('docker --version'); // 获取 Docker 信息 const dockerVersion = execSync('docker version --format \'{{json .}}\'').toString(); const dockerImages = execSync('docker images --format \'{{json .}}\'').toString().split('\n').filter(Boolean).map(line => JSON.parse(line)); const dockerContainers = execSync('docker ps -a --format \'{{json .}}\'').toString().split('\n').filter(Boolean).map(line => JSON.parse(line)); dockerInfo = { version: JSON.parse(dockerVersion), images: dockerImages, containers: dockerContainers }; } catch (error) { // Docker 未安装或者出错,返回空对象 dockerInfo = {}; } return { content: [{ type: "text", text: JSON.stringify(dockerInfo, null, 2) }] }; } - src/index.ts:262-270 (registration)Registration of getDockerInfo tool in the list of tools returned by handleRequest, including description and inputSchema (no parameters).
{ name: "getDockerInfo", description: "获取当前设备的 Docker 信息,若未安装则返回空", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:265-269 (schema)Input schema for getDockerInfo: empty object (no input parameters required).
inputSchema: { type: "object", properties: {}, required: [] }