Skip to content

Comments

feat(network): add ip route tool#263

Open
Albe83 wants to merge 30 commits intorhel-lightspeed:mainfrom
Albe83:feat/ip-route-tool
Open

feat(network): add ip route tool#263
Albe83 wants to merge 30 commits intorhel-lightspeed:mainfrom
Albe83:feat/ip-route-tool

Conversation

@Albe83
Copy link

@Albe83 Albe83 commented Feb 7, 2026

Summary

Adds a new read-only MCP tool to fetch routing tables via ip route (IPv4/IPv6), with unit tests and documentation updates. Also adjusts a storage test to avoid false negatives when running as root.

Motivation

Routing tables are a core diagnostic for network issues. Today the server exposes interfaces, connections, and listening ports but no route visibility. This tool completes the basic network triage set without introducing any write capability.

Changes

  • New tool: get_ip_route_table
    • Parameters: family = ipv4 | ipv6 | all (default: ipv4)
    • Uses allowlisted ip route show commands in commands.py
    • Read-only, @log_tool_call, @disallow_local_execution_in_containers, readOnlyHint=True
    • Returns a labeled output block per family
  • Commands registry: added ip_route group with ipv4 and ipv6
  • Tests: cover success, all aggregation, partial failure (one family fails), command failure/empty output, and error propagation
  • Docs: usage, cheatsheet, API index updated with the new tool
  • Test fix: skip restricted-path storage test when geteuid()==0 to prevent false failures in root environments

Security / Read-only

  • No user-supplied shell args; commands are fixed in commands.py
  • Tool annotated as read-only; no writes or side effects

Testing

  • make verify

Notes for Reviewer

  • The family=all path runs both commands and returns a combined output, with per-family error messages if one fails.
  • The root-skip change is deliberately small and avoids masking behavior on non-root runs.

@Albe83 Albe83 marked this pull request as ready for review February 7, 2026 14:42
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 97.74% <100.00%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/linux_mcp_server/commands.py 89.09% <ø> (ø)
src/linux_mcp_server/tools/__init__.py 100.00% <100.00%> (ø)
src/linux_mcp_server/tools/dnf.py 100.00% <100.00%> (ø)
src/linux_mcp_server/tools/network.py 100.00% <100.00%> (ø)
src/linux_mcp_server/utils/validation.py 100.00% <100.00%> (ø)
tests/tools/storage/test_list_directories.py 100.00% <100.00%> (ø)
tests/tools/test_dnf.py 100.00% <100.00%> (ø)
tests/tools/test_network.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Albe83 Albe83 closed this Feb 7, 2026
@Albe83 Albe83 deleted the feat/ip-route-tool branch February 7, 2026 15:07
@Albe83 Albe83 restored the feat/ip-route-tool branch February 7, 2026 22:39
@Albe83 Albe83 reopened this Feb 7, 2026
@Albe83 Albe83 force-pushed the feat/ip-route-tool branch from 89d5846 to 74b8fb0 Compare February 7, 2026 22:58
samdoran and others added 16 commits February 8, 2026 00:14
Rather than passing None and letting FastMCP apply default, explicitly set
default valuse and pass those to FastMCP.
All transport types accetp a log_level parameter.
Remove cli_exit_on_error parameter since that does something different and is
not related to fixing the issue of pytest args getting picked up by Pydantic
Settings and causing tests to not run.

Use an expression to set the value of cli_ignore_unknown_args seems reasonable.
It may be an issue if someone has the string “pytest” in the executable path:

    /home/pytest/.venv/bin/linux-mcp-server

That might be an edge case we don’t need to worry about at this point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants