Skip to main content
Glama

solve_traveling_salesman_problem

Find the shortest route visiting all specified locations using the Traveling Salesman Problem solver. Supports custom distance matrix, start location, return-to-start, and time limit.

Instructions

Solve Traveling Salesman Problem (TSP) to find the shortest route visiting all locations.

    Args:
        locations: List of location dictionaries with name and coordinates
        distance_matrix: Optional pre-calculated distance matrix
        start_location: Index of starting location (default: 0)
        return_to_start: Whether to return to starting location (default: True)
        time_limit_seconds: Maximum solving time in seconds (default: 30.0)

    Returns:
        Optimization result with route and total distance
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationsYes
distance_matrixNo
start_locationNo
return_to_startNo
time_limit_secondsNo
Behavior2/5

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

With no annotations, the description should disclose behavioral traits. It mentions time limit and return-to-start but omits critical details like non-destructive nature, input validation, error handling, or algorithmic approach (exact/heuristic).

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

Conciseness4/5

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

The description is short, front-loaded with purpose, and uses a clear docstring format with Args and Returns. Every sentence adds value, though it could be slightly more concise.

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

Completeness2/5

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

Given no output schema, the description should fully describe the return value. It only says 'Optimization result with route and total distance,' which is vague. It also lacks constraints on input size or behavior with invalid data, leaving the agent underinformed.

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

Parameters3/5

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

Schema coverage is 0%, so the description must add meaning. It explains that locations have name and coordinates, distance_matrix is optional, and start_location indices are zero-based. However, it lacks precise format for coordinates and does not specify required keys in location dictionaries.

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 solves the Traveling Salesman Problem to find the shortest route. It uses specific verb 'solve' and resource 'TSP', and is distinct from sibling optimization tools like portfolio or production planning.

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?

The description implies usage for shortest route problems but does not explicitly state when to use this tool over alternatives like vehicle routing or assignment. No exclusions or contextual advice are provided.

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/dmitryanchikov/mcp-optimizer'

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