Skip to main content
Glama

port_conflict

Diagnose port conflicts by identifying the blocking server and suggesting 5 free alternative ports nearby.

Instructions

Diagnose why a port is busy. Returns the blocking server and 5 free alternative ports nearby.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes

Implementation Reference

  • The portConflict function that executes the tool logic. It calls portInfo(port) to find the blocking server, then scans ports (port+1 .. port+49) to find up to 5 free alternative ports. Returns { blocking, free_alternatives }.
    export async function portConflict(port: number): Promise<{
      blocking: DevServer | null;
      free_alternatives: number[];
    }> {
      const blocking = await portInfo(port);
      const all = await listDevServers();
      const taken = new Set(all.map((s) => s.port));
      const free_alternatives: number[] = [];
      for (let p = port + 1; p < port + 50 && free_alternatives.length < 5; p++) {
        if (!taken.has(p)) free_alternatives.push(p);
      }
      return { blocking, free_alternatives };
    }
  • Tool definition (inputSchema) for 'port_conflict'. Declares a required 'port' (number) input and describes the tool's purpose: diagnose why a port is busy, return the blocking server and 5 free alternatives.
    {
      name: "port_conflict",
      description: "Diagnose why a port is busy. Returns the blocking server and 5 free alternative ports nearby.",
      inputSchema: {
        type: "object",
        properties: { port: { type: "number" } },
        required: ["port"],
        additionalProperties: false,
      },
    },
  • src/index.ts:105-109 (registration)
    Handler registration in the CallToolRequestSchema switch-case. Parses the port argument with Zod and calls the portConflict function from dev-servers.ts, returning the result.
    case "port_conflict": {
      const port = z.number().int().parse((args as any)?.port);
      const data = await portConflict(port);
      return ok(data);
    }
  • Helper function portInfo used by portConflict to look up which dev server (if any) is blocking the given port.
    export async function portInfo(port: number): Promise<DevServer | null> {
      const all = await listDevServers();
      return all.find((s) => s.port === port) ?? null;
    }
Behavior3/5

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

With no annotations, the description carries full burden. It discloses that the tool returns blocking server and alternatives, implying read-only behavior. However, it doesn't mention permissions, side effects, or error conditions.

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?

The description is two short sentences front-loading purpose and output. Every word earns its place without redundancy.

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?

For a simple one-parameter diagnostic tool, the description covers purpose and output. However, it lacks instructions on error conditions (e.g., if no blocking server) and fails to leverage sibling tool names for differentiation.

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%. The description indirectly indicates the parameter is a port number ('diagnose why a port is busy'), but does not explicitly describe the parameter format, range, or constraints.

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 tool diagnoses port busyness and returns specific outputs: blocking server and 5 free alternatives. This verb-resource combination is distinct from siblings like kill_server or port_info.

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 explicit guidance on when to use this tool over alternatives like port_info, find_zombies, or kill_server. The description implies it's for conflict diagnosis but provides no exclusions or 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/HasanJahidul/localhost-mcp'

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