Skip to main content
Glama
es3154

Turf-MCP

by es3154

misc_nearest_point_on_line

Calculate the closest point on a line to a given geographic coordinate, returning the position and distance for spatial analysis.

Instructions

找到线上距离给定点最近的位置。

此功能在线段上找到距离给定点最近的位置,返回该位置坐标及距离信息。

Args: line: 线 GeoJSON 特征或几何图形 - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 必须符合 GeoJSON LineString 规范 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "LineString", "coordinates": [[-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], [-77.025661, 38.885821], [-77.021884, 38.889563], [-77.019824, 38.892368]]}'

point: 点 GeoJSON 特征或几何图形
    - 类型: str (JSON 字符串格式的 GeoJSON)
    - 格式: 必须符合 GeoJSON Point 规范
    - 坐标系: WGS84 (经度在前,纬度在后)
    - 示例: '{"type": "Point", "coordinates": [-77.037076, 38.884017]}'

options: 可选参数配置
    - 类型: str (JSON 字符串) 或 None
    - 可选字段:
        - units: 距离单位 (默认: 'kilometers')
            - 有效值: 'miles', 'nauticalmiles', 'kilometers', 'meters', 'yards', 'feet', 'inches'
    - 示例: '{"units": "miles"}'

Returns: str: JSON 字符串格式的 GeoJSON Point 特征 - 类型: GeoJSON Feature with Point geometry - 格式: {"type": "Feature", "geometry": {"type": "Point", "coordinates": [lng, lat]}, "properties": {"location": 距离起点位置, "distance": 距离值}}

Raises: Exception: 当 JavaScript 执行失败、超时或输入数据格式错误时抛出异常

Example: >>> import asyncio >>> line = '{"type": "LineString", "coordinates": [[-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], [-77.025661, 38.885821], [-77.021884, 38.889563], [-77.019824, 38.892368]]}' >>> point = '{"type": "Point", "coordinates": [-77.037076, 38.884017]}' >>> options = '{"units": "miles"}' >>> result = asyncio.run(nearest_point_on_line(line, point, options)) >>> print(result) '{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.03, 38.883]}, "properties": {"location": 0.5, "distance": 0.2}}'

Notes: - 输入参数 line 和 point 必须是有效的 JSON 字符串 - 坐标顺序为 [经度, 纬度] (WGS84 坐标系) - 返回线上距离给定点最近的位置及相关信息 - 依赖于 Turf.js 库和 Node.js 环境

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineYes
pointYes
optionsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds some context: it specifies the coordinate system (WGS84 with longitude first), notes dependencies (Turf.js and Node.js), and mentions error conditions (JavaScript execution failures, timeouts, or input format errors). However, it doesn't cover aspects like performance expectations, rate limits, or authentication needs, leaving gaps for a tool with computational geometry operations.

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

Conciseness3/5

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

The description is well-structured with sections (Args, Returns, Raises, Example, Notes), but it's overly verbose for a tool description. Much of the detail (like full JSON examples and implementation notes) could be moved to documentation or schema descriptions. While informative, it's not front-loaded efficiently, with core purpose stated upfront but buried in extensive parameter details.

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?

Given the complexity (geospatial computation with specific formats), 0% schema coverage, and no annotations, the description provides comprehensive context. It fully documents parameters, return values (including output schema details), error conditions, examples, and implementation notes. The presence of an output schema is noted, but the description still explains return values thoroughly, ensuring the agent has complete information for correct tool invocation.

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?

The schema description coverage is 0%, so the description must fully compensate. It does this excellently: it documents all three parameters (line, point, options) with detailed semantics, including types, formats, coordinate systems, examples, and optional fields with enums for 'units'. This goes far beyond the basic schema, providing the agent with everything needed to construct valid inputs.

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?

The description clearly states the tool's purpose: '找到线上距离给定点最近的位置' (find the nearest point on a line to a given point). It specifies the verb ('找到' - find) and resource ('线上...位置' - point on a line), making the function distinct. However, it doesn't explicitly differentiate from sibling tools like 'measurement_pointToLineDistance' or 'booleans_booleanPointOnLine', which reduces the score from 5 to 4.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'measurement_pointToLineDistance' (which might return just distance) or 'booleans_booleanPointOnLine' (which checks if a point is on a line), leaving the agent without context for tool selection. Usage is implied only through the function name and description, but no explicit when/when-not instructions are given.

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/es3154/turf-mcp'

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