Skip to main content
Glama

port_check

Check if a TCP port is open on a specified host to verify network connectivity and service availability.

Instructions

Check if a TCP port is open on a host.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
portYes
timeoutNo

Implementation Reference

  • The port_check tool handler: uses a TCP socket with connect_ex() to check if a given port is open on a host. Returns {'host', 'port', 'open'} on success, or {'error', 'tool', 'host', 'port'} on exception.
    @mcp.tool()
    def port_check(host: str, port: int, timeout: int = 5) -> dict:
        """Check if a TCP port is open on a host."""
        try:
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
                sock.settimeout(timeout)
                result = sock.connect_ex((host, port))
            return {"host": host, "port": port, "open": result == 0}
        except Exception as e:
            return {"error": str(e), "tool": "port_check", "host": host, "port": port}
  • The @mcp.tool() decorator registers port_check as an MCP tool on the FastMCP('nettools') instance.
    @mcp.tool()
    def port_check(host: str, port: int, timeout: int = 5) -> dict:
  • Input schema: host (str), port (int), timeout (int, default 5). Output schema: dict with host, port, open (bool) or error info.
    @mcp.tool()
    def port_check(host: str, port: int, timeout: int = 5) -> dict:
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full behavioral burden. It correctly indicates a read-only check (no side effects), but does not mention timeout behavior or response format. For a simple tool, this is mostly adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no unnecessary words. Every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no output schema, 3 params), the description is minimal but misses parameter semantics and return hints. It is on the edge of adequacy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description does not explain parameter details beyond what the schema provides. It does not clarify timeout meaning, host format, or return value types.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Check', the resource 'TCP port', and the context 'on a host'. It distinguishes from siblings like ping (ICMP reachability) and DNS lookup.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like ping or traceroute. The description implies usage (checking TCP port openness) but does not provide explicit when-to-use or when-not-to-use context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aaronckj/mcp-nettools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server