Skip to main content
Glama

axom_mcp_transform

Read-onlyIdempotent

Transform data between JSON, YAML, CSV, markdown, and code formats using field mapping, filtering, sorting, aggregation, and Jinja2 templates for custom output formatting.

Instructions

Transform data between formats and structures.

Supported Formats:

  • json: JSON objects and arrays

  • yaml: YAML documents

  • csv: Comma-separated values

  • markdown: Markdown documents

  • code: Source code (with language detection)

Transformation Rules:

  • field_mapping: Rename or restructure fields

  • filter: Include/exclude specific fields

  • sort: Sort arrays by field

  • aggregate: Group and aggregate data

Template Support: Use Jinja2 templates for custom output formatting.

Chain Support: Use chain parameter to continue processing transformed data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesInput data to transform
input_formatNoInput format (auto-detected if not specified)
output_formatYesOutput format
rulesNoTransformation rules
templateNoTemplate for transformation
chainNoChain operations after transformation

Implementation Reference

  • Main handler function 'handle_transform' that executes the axom_mcp_transform tool. It validates input using TransformInput schema, auto-detects input format, parses the input, applies transformation rules, and formats the output.
    async def handle_transform(arguments: Dict[str, Any]) -> str:
        """Handle axom_mcp_transform tool calls.
    
        Args:
            arguments: Tool arguments containing input data and format parameters
    
        Returns:
            JSON string with transformation result
        """
        # Validate input
        input_data = TransformInput(**arguments)
        input_str = input_data.input
        input_format = input_data.input_format
        output_format = input_data.output_format
        rules = input_data.rules or []
        template = input_data.template
    
        try:
            # Auto-detect input format if not specified
            if input_format is None:
                input_format = _detect_format(input_str)
    
            # Parse input to Python object
            parsed = _parse_input(input_str, input_format)
    
            # Apply transformation rules
            for rule in rules:
                parsed = _apply_rule(parsed, rule)
    
            # Convert to output format
            result = _format_output(parsed, output_format, template)
    
            return json.dumps(
                {
                    "success": True,
                    "input_format": input_format,
                    "output_format": output_format,
                    "result": result,
                }
            )
    
        except Exception as e:
            logger.error(f"Transform failed: {e}")
            return json.dumps({"error": str(e)})
  • Input schema definition 'TransformInput' for the axom_mcp_transform tool. Defines required fields (input, output_format) and optional fields (input_format, rules, template, chain) with validation constraints.
    class TransformInput(BaseModel):
        """Input schema for axom_mcp_transform tool."""
    
        model_config = {"extra": "forbid"}
    
        input: str = Field(
            ..., min_length=1, max_length=10_000_000, description="Input data to transform"
        )
        input_format: Optional[str] = Field(
            default=None,
            pattern="^(json|yaml|csv|markdown|code)$",
            description="Input format (auto-detected if not specified)",
        )
        output_format: str = Field(
            ..., pattern="^(json|yaml|csv|markdown|code)$", description="Output format"
        )
        rules: Optional[List[Dict[str, Any]]] = Field(
            default=None, description="Transformation rules"
        )
        template: Optional[str] = Field(
            default=None, max_length=10000, description="Template for transformation"
        )
        chain: Optional[List[Dict[str, Any]]] = Field(
            default=None, max_length=10, description="Chain operations after transformation"
        )
  • Tool registration for axom_mcp_transform in the TOOLS list. Defines the tool's name, description, input schema, and annotations. The schema specifies all supported formats (json, yaml, csv, markdown, code) and transformation options.
        Tool(
            name="axom_mcp_transform",
            description="""Transform data between formats and structures.
    
    Supported Formats:
    - json: JSON objects and arrays
    - yaml: YAML documents
    - csv: Comma-separated values
    - markdown: Markdown documents
    - code: Source code (with language detection)
    
    Transformation Rules:
    - field_mapping: Rename or restructure fields
    - filter: Include/exclude specific fields
    - sort: Sort arrays by field
    - aggregate: Group and aggregate data
    
    Template Support:
    Use Jinja2 templates for custom output formatting.
    
    Chain Support:
    Use chain parameter to continue processing transformed data.""",
            inputSchema={
                "type": "object",
                "properties": {
                    "input": {"type": "string", "description": "Input data to transform"},
                    "input_format": {
                        "type": "string",
                        "enum": ["json", "yaml", "csv", "markdown", "code"],
                        "description": "Input format (auto-detected if not specified)",
                    },
                    "output_format": {
                        "type": "string",
                        "enum": ["json", "yaml", "csv", "markdown", "code"],
                        "description": "Output format",
                    },
                    "rules": {
                        "type": "array",
                        "items": {"type": "object"},
                        "description": "Transformation rules",
                    },
                    "template": {
                        "type": "string",
                        "description": "Template for transformation",
                    },
                    "chain": {
                        "type": "array",
                        "items": {"type": "object"},
                        "description": "Chain operations after transformation",
                    },
                },
                "required": ["input", "output_format"],
            },
            annotations=TOOL_ANNOTATIONS["transform"],
        ),
  • Routing logic that calls handle_transform when the axom_mcp_transform tool is invoked. Maps the tool name to its handler function.
    elif name == "axom_mcp_transform":
        result = await handle_transform(arguments)
  • Helper function _detect_format that auto-detects input format based on content patterns. Checks for JSON, YAML, CSV, markdown, and defaults to code format using regex heuristics.
    def _detect_format(input_str: str) -> str:
        """Auto-detect input format based on content."""
        stripped = input_str.strip()
    
        # Check for JSON
        if stripped.startswith("{") or stripped.startswith("["):
            try:
                json.loads(stripped)
                return "json"
            except json.JSONDecodeError:
                pass
    
        # Check for YAML (basic heuristics)
        yaml_indicators = [
            r"^\w+:\s*",  # key: value
            r"^-\s+",  # - list item (can be at start of line)
            r"^\s+-\s+",  # - list item (with indentation)
            r"^---\s*$",  # YAML document separator
        ]
        for pattern in yaml_indicators:
            if re.search(pattern, stripped, re.MULTILINE):
                return "yaml"
    
        # Check for CSV
        lines = stripped.split("\n")
        if len(lines) > 1:
            # Check if all lines have similar number of commas
            comma_counts = [line.count(",") for line in lines[:5]]
            if len(set(comma_counts)) == 1 and comma_counts[0] > 0:
                return "csv"
    
        # Check for Markdown
        md_indicators = [
            r"^#+\s+",  # Headers
            r"^\*\s+",  # Unordered lists
            r"^\d+\.\s+",  # Ordered lists
            r"\[.*\]\(.*\)",  # Links
            r"```",  # Code blocks
        ]
        for pattern in md_indicators:
            if re.search(pattern, stripped, re.MULTILINE):
                return "markdown"
    
        # Default to code
        return "code"
Behavior4/5

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

The description adds valuable context beyond annotations by detailing supported formats, transformation rules, template support, and chain operations. Annotations already indicate it's read-only, non-destructive, and idempotent, but the description clarifies what 'transformation' entails (e.g., field mapping, filtering, sorting) and mentions advanced features like Jinja2 templates and chaining, which enhance behavioral understanding without contradicting 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 well-structured and appropriately sized, using bullet points and clear sections ('Supported Formats', 'Transformation Rules', 'Template Support', 'Chain Support') to organize information efficiently. Each sentence adds value without redundancy, making it easy to scan and understand the tool's capabilities quickly.

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

Completeness4/5

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

Given the tool's complexity (6 parameters, multiple formats and rules) and rich annotations, the description is largely complete. It covers key aspects like formats, rules, templates, and chaining. However, without an output schema, it does not describe return values or error handling, which could be helpful for a transformation tool. The annotations provide safety context, but output details are missing.

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?

With 100% schema description coverage, the input schema already documents all 6 parameters thoroughly. The description adds some semantic context by listing formats and rules that correspond to parameters like 'input_format', 'output_format', and 'rules', but does not provide additional syntax, examples, or details beyond what the schema specifies. This meets the baseline for high schema coverage.

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 verbs ('Transform data between formats and structures') and lists the supported formats and transformation rules. It distinguishes itself from sibling tools like 'analyze', 'discover', 'exec', and 'memory' by focusing specifically on data transformation rather than analysis, discovery, execution, or memory operations.

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 through the listing of supported formats and transformation rules, suggesting this tool should be used for data format conversion and restructuring tasks. However, it does not explicitly state when to use this tool versus alternatives like 'axom_mcp_analyze' for data analysis or provide specific exclusions or prerequisites for usage.

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/PugzUI/axom-mcp'

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