loading…
Search for a command to run...
loading…
This MCP server provides read-only Linux system diagnostics tools for inspecting system information, processes, and log snapshots. It enables AI models to analy
This MCP server provides read-only Linux system diagnostics tools for inspecting system information, processes, and log snapshots. It enables AI models to analyze Linux system health, troubleshoot issues, and review security through workflow prompts and HTTP transport with API key authentication.
A Python/Linux adaptation of the original MCPDemo teaching repository. This repo now reaches Milestone 7 parity for the public teaching flow: compact system inspection, Linux process drill-down, log snapshots as resources, workflow prompts, authenticated MCP over HTTP on /mcp, explicit elicitation before process termination, sampling-assisted Linux diagnostics, and allowed-root proc/sys snapshots.
This lecture demo now includes:
get_system_info, get_process_list, get_process_by_id, get_process_by_name, and elicitation-gated kill_processsyslog://snapshot/... log snapshot resourceshttp://127.0.0.1:5000/mcpX-API-Key header or ?apiKey=secure-mcp-keykill_process/proc and /sys snapshotsServer-only install:
python3 -m pip install --user --break-system-packages -e .
Install the lecture chat client extras:
python3 -m pip install --user --break-system-packages -e '.[llm]'
python3 scripts/smoke_test.py
This script:
401 Unauthorized without an API key/mcpmcp-session-id flow works across requestskill_process fails safely when the client does not advertise elicitation supportpython3 -m mcp_linux_diag_server
The server listens on:
http://127.0.0.1:5000/mcpsecure-mcp-keyStart the server in one terminal, then connect using the HTTP endpoint above.
This repo includes .vscode/mcp.json with the required header:
{
"servers": {
"linux-diag-demo": {
"url": "http://127.0.0.1:5000/mcp",
"headers": {
"X-API-Key": "secure-mcp-key"
}
}
}
}
If your inspector accepts a URL directly, this query-string form also works:
http://127.0.0.1:5000/mcp?apiKey=secure-mcp-key
Copy the sample environment file and fill in your local Azure OpenAI settings:
cp .env.example .env.local
$EDITOR .env.local
python3 -m mcp_linux_diag_server.client --prompt "Summarize this machine."
To mirror the original .NET credential flow more closely, set:
MCP_DEMO_AZURE_OPENAI_USE_DEFAULT_CREDENTIAL=true
and omit the API key.
Run interactive chat:
python3 -m mcp_linux_diag_server.client
Or run a single prompt:
python3 -m mcp_linux_diag_server.client --prompt "What is the system information?"
get_system_info - Returns a compact Linux or WSL system snapshotget_process_list - Returns a lightweight list of running processes with names and PIDsget_process_by_id - Returns detailed Linux process information for one PIDget_process_by_name - Returns paged detailed process information for a process namepage_number=1page_size=5kill_process - Terminates a Linux process only after explicit elicitationprocess_id is omitted, the server samples the top CPU consumers and asks the client to choose oneCONFIRM PID {pid}troubleshoot_linux_diagnostics - Uses sampling to convert a natural-language Linux diagnostics question into a validated /proc or /sys readPATH or PATH | grep FIELD line instead of WQLcreate_proc_snapshot - Creates an immutable read-only snapshot from an allowed /proc or /sys path and returns resource URIsrequest_proc_access - Uses elicitation to request read-only access to an additional /proc or /sys rootcreate_log_snapshot - Creates an immutable snapshot from a common Linux log file and returns resource URIssystem, security, kernel, and package log groupsfilter_text narrows the snapshot to matching linessyslog://snapshot/{snapshot_id} - Reads a stored Linux log snapshot with default paginationsyslog://snapshot/{snapshot_id}?limit={limit}&offset={offset} - Reads a specific page from a stored snapshotproc://snapshot/{snapshot_id} - Reads a stored proc/sys snapshot with default paginationproc://snapshot/{snapshot_id}?limit={limit}&offset={offset} - Reads a specific page from a stored proc/sys snapshotEvery resource read returns:
total_count, returned_count, limit, offset, has_more, next_offset)AnalyzeRecentApplicationErrors - Error-focused log analysis workflowExplainHighCpu - Correlate CPU-heavy processes with Linux logsDetectSecurityAnomalies - Review suspicious processes plus auth/security log evidenceDiagnoseSystemHealth - End-to-end system health workflowTroubleshootLinuxComponent - Focused deep-dive workflow that steers the agent toward troubleshoot_linux_diagnosticssrc/mcp_linux_diag_server/server.pyThe authenticated HTTP MCP server exposing the Milestone 1-7 diagnostics tools, resources, and workflow prompts.
src/mcp_linux_diag_server/client.pyThe lecture chat client that:
kill_process| Method | Visual | Interactive | LLM | Best For |
|---|---|---|---|---|
python3 scripts/smoke_test.py |
❌ No | ❌ No | ❌ No | quick verification of M1-M7 server behavior |
MCP Inspector / .vscode/mcp.json |
✅ Yes | ✅ Yes | ❌ No | development, debugging, teaching |
python3 -m mcp_linux_diag_server.client |
❌ No | ✅ Yes | ✅ Yes | lecture demo flow |
For the Milestone 1 validation checklist that still underpins the base lecture flow, see M1_VALIDATION_GUIDE.md.
MCPPythonDemo/
├── README.md
├── LICENSE.txt
├── pyproject.toml
├── .env.example
├── .vscode/
│ └── mcp.json
├── scripts/
│ └── smoke_test.py
├── src/
│ └── mcp_linux_diag_server/
│ ├── __main__.py
│ ├── client.py
│ ├── http_config.py
│ ├── server.py
│ └── tools/
│ ├── log_snapshots.py
│ ├── proc_snapshots.py
│ ├── processes.py
│ └── system_info.py
├── tests/
│ ├── http_harness.py
│ ├── test_client.py
│ ├── test_m1_smoke.py
│ ├── test_m2_smoke.py
│ ├── test_m3_smoke.py
│ ├── test_m4_http.py
│ ├── test_log_snapshots.py
│ ├── test_processes.py
│ └── test_system_info.py
mcp[cli]✅ Milestone 1 - Minimal diagnostics tool over stdio plus lecture chat client
✅ Milestone 2 - Process inspection
✅ Milestone 3 - Log snapshot resources and prompts
✅ Milestone 4 - HTTP transport and security
✅ Milestone 5 - Elicitation-backed kill_process
✅ Milestone 6 - Sampling-assisted Linux diagnostics
✅ Milestone 7 - Roots and proc/sys snapshots
MIT. See LICENSE.txt.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"linux-diagnostics-mcp-server": {
"command": "npx",
"args": []
}
}
}