speedtest
Measure internet download and upload speeds by connecting to the nearest server.
Instructions
Run a network speed test using the nearest server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_nettools/server.py:120-133 (handler)The speedtest() function is the handler that runs a network speed test using the speedtest-cli library. It is decorated with @mcp.tool() which registers it as an MCP tool. It gets the best server, measures download/upload speeds in Mbps, and returns the results including ping latency and server name.
@mcp.tool() def speedtest() -> dict: """Run a network speed test using the nearest server.""" try: st = _speedtest_lib.Speedtest() st.get_best_server() return { "download_mbps": round(st.download() / 1_000_000, 2), "upload_mbps": round(st.upload() / 1_000_000, 2), "ping_ms": st.results.ping, "server": st.results.server.get("name"), } except Exception as e: return {"error": str(e), "tool": "speedtest"} - src/mcp_nettools/server.py:120-120 (registration)The @mcp.tool() decorator on line 120 registers the speedtest function as an MCP tool with the FastMCP server instance.
@mcp.tool() - src/mcp_nettools/server.py:121-121 (schema)The speedtest function has no parameters (takes no input), and returns a dict with keys: download_mbps, upload_mbps, ping_ms, server (on success) or error, tool (on failure).
def speedtest() -> dict: - src/mcp_nettools/server.py:11-11 (helper)The speedtest-cli library is imported as _speedtest_lib and used internally by the speedtest handler.
import speedtest as _speedtest_lib - src/mcp_nettools/server.py:16-16 (registration)The FastMCP server instance named 'nettools' that hosts all tools including speedtest.
mcp = FastMCP("nettools")