Skip to main content
Glama
es3154

Turf-MCP

by es3154

data_sample

Randomly sample a specified number of features from a GeoJSON FeatureCollection to create smaller, representative datasets for geospatial analysis.

Instructions

从特征集合中随机采样指定数量的特征。

此功能从输入的特征集合中随机选择指定数量的特征,返回一个新的特征集合。

Args: feature_collection: 输入特征集合 - 类型: str (JSON 字符串格式的 GeoJSON FeatureCollection) - 格式: 任何有效的 GeoJSON FeatureCollection - 示例: '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}, ...]}'

num: 采样数量
    - 类型: int
    - 描述: 要从输入集合中随机选择特征的数量
    - 示例: 5

Returns: str: JSON 字符串格式的 GeoJSON FeatureCollection - 类型: GeoJSON FeatureCollection - 格式: {"type": "FeatureCollection", "features": [...]} - 示例: '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}, ...]}'

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

Example: >>> import asyncio >>> feature_collection = '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}, ...]}' >>> result = asyncio.run(sample(feature_collection, 5)) >>> print(result) '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}, ...]}'

Notes: - 输入参数 feature_collection 必须是有效的 JSON 字符串 - 采样数量不能超过输入特征集合中的特征总数 - 如果采样数量为0,返回空的特征集合 - 采样是随机进行的,每次调用可能得到不同的结果 - 依赖于 Turf.js 库和 Node.js 环境

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
feature_collectionYes
numYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: random nature of sampling (may yield different results each time), constraints on input (must be valid JSON), dependencies (Turf.js and Node.js), error conditions (JavaScript failures, timeouts, bad input), and special cases (num=0 returns empty collection). It doesn't mention performance characteristics or rate limits, but covers most essential behavioral aspects.

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 appropriately sized but not optimally structured. While it contains valuable information, it mixes purpose, parameters, returns, raises, example, and notes in a somewhat unstructured way. The front-loaded purpose statement is clear, but the subsequent sections could be better organized for quick scanning.

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 tool's moderate complexity, no annotations, and the presence of an output schema, the description is remarkably complete. It covers purpose, parameters, return values, error conditions, examples, and important notes about constraints and dependencies. The output schema handles return format documentation, allowing the description to focus on operational context.

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?

With 0% schema description coverage, the description fully compensates by providing detailed parameter documentation. It explains both parameters thoroughly: feature_collection (JSON string format, GeoJSON FeatureCollection type, examples) and num (sampling count, integer type, constraints). The description adds substantial value beyond the bare schema.

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's purpose with specific verb ('随机采样' - random sampling) and resource ('特征集合' - feature collection). It distinguishes from siblings by focusing on random sampling rather than aggregation, classification, or transformation operations listed among sibling tools.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool (random sampling from feature collections) and includes important constraints (sampling count cannot exceed total features, returns empty collection if num=0). However, it doesn't explicitly mention when NOT to use it or name specific alternative tools for different sampling needs.

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