Skip to main content
Glama

find_free_port

Locate unused TCP ports in a range by checking listening status and OS bind availability, returning the lowest free ports for the specified host and count.

Instructions

Find unused TCP port(s) in start..end (inclusive), lowest first.

A port counts as free only if nothing is listening on it AND the OS lets us bind it on host, so ports reserved by the OS (Windows excluded ranges) are skipped. count returns that many ports. Use host "0.0.0.0" to require that the port is free on every interface.

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": "find_free_port"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNo
hostNo127.0.0.1
countNo
startNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it defines what 'free' means (nothing listening AND the OS permits binding on host), notes that OS-reserved ranges are skipped, and explains that count returns multiple ports. It omits the practical caveat that a bind probe is inherently racy and that a successful probe releases the port immediately.

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?

Three short sentences, front-loaded with the primary action and scope, then the definition of 'free', then the two usage-relevant quirks. No filler and nothing redundant with the schema.

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

Completeness4/5

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

An output schema exists, so return shape need not be explained, and the description covers the non-obvious semantics of the four parameters. What is missing is failure behavior (no free port found in range) and the ephemeral nature of the bind test, which matter for an agent that later tries to use the port.

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

Parameters4/5

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

Schema coverage is 0%, so the description must compensate, and it does for the core semantics: start/end define an inclusive range, count controls how many ports are returned, and host is explained via the 0.0.0.0 example. Defaults (start 3000, end 3999, host 127.0.0.1, count 1) live only in the schema and behavior when the range is exhausted is not described.

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

Purpose4/5

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

States a specific verb and resource ('Find unused TCP port(s)'), the scan scope ('start..end (inclusive)'), and the ordering ('lowest first'). That is enough to distinguish it from siblings like whats_on_port or check_port_reachable, though it never names an alternative explicitly.

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

Usage Guidelines3/5

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

Gives one concrete usage instruction — use host "0.0.0.0" when the port must be free on every interface — which implies the default is loopback-only. It offers no guidance on when to prefer this over check_port_reachable or whats_on_port, so routing is left to inference.

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