Skip to main content
Glama

compose_port

Read-only

Resolve the published host address and port for a Docker Compose service's internal port, returning all bindings.

Instructions

Resolve the host binding for a service's container port.

The compose equivalent of docker port: which host address/port a service's private port is published on. published is None when the port isn't published. For non-compose containers read container_inspect's NetworkSettings.Ports instead. Raises RemoteFailureError if the CLI call fails.

Args: service: Service name from the compose file private_port: The container-internal port to look up protocol: "tcp" (default) or "udp" index: Container index when the service has multiple replicas project_dir: Dir with the compose file (default: server cwd; copied to the target host if no local plugin) files: Explicit compose file paths (repeatable, -f) project_name: Compose project name override

Returns: dict: {"service", "private_port", "protocol", "published": "host:port"|None, "host": str|None, "port": int|None, "bindings": list[str]}. published/host/port describe the first binding; bindings lists every line (a port can be published on more than one address, e.g. IPv4 and IPv6).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesNo
indexNo
serviceYes
protocolNotcp
project_dirNo
private_portYes
project_nameNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.1.4
  2. Removedv2.1.4
  3. First observedv1.9.0

TDQS

A5/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, and the description adds meaningful behavioral context beyond that: `published` is None when unpublished, `bindings` can contain multiple entries for addresses like IPv4/IPv6, and RemoteFailureError is raised on CLI failure. It also discloses copy-to-host behavior for project_dir, which is not visible in the schema or annotations.

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 front-loaded with the core purpose, then adds a one-line analogy, targeted edge cases, and compact Args/Returns sections. No sentence is wasted, and the structure makes it easy to scan before invoking the tool.

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

Completeness5/5

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

There is no output schema, so the description supplies a detailed return contract including the returned keys and the distinction between the first binding and the full bindings list. It also mentions the failure exception and parameter defaults, making the tool fully actionable without external lookups.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully, and it does. Every parameter has an explanatory line: service, private_port, protocol with default, index, project_dir with default behavior, files with `-f` repeatability, and project_name. This materially helps an agent select and fill parameters correctly.

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 opens with a specific verb and resource: 'Resolve the host binding for a service's container port.' It names the Docker equivalent (`docker port`) and states the exact question answered. It also distinguishes itself from `container_inspect` by directing non-compose containers elsewhere, making its scope unambiguous among the large sibling list.

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

Usage Guidelines5/5

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

The description gives an explicit alternative and the condition under which to use it: 'For non-compose containers read container_inspect's NetworkSettings.Ports instead.' It also describes the compose-specific context and the fallback/default behavior for project_dir. This gives an agent clear routing instructions without needing to inspect sibling tools.

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

Deploy Server

Other Tools