Skip to main content
Glama
jskorlol

JSON Skeleton MCP Server

by jskorlol

json_skeleton

Create compact JSON skeletons by preserving structure while truncating values and deduplicating arrays to handle large JSON files that exceed size limits.

Instructions

Create a lightweight JSON skeleton that preserves structure with truncated values and deduplicated arrays. Useful when encountering 'File content exceeds maximum allowed size' errors with large JSON files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the JSON file to process
max_lengthNoMaximum length for string values (default: 200)
type_onlyNoReturn only value types instead of values. Most compact output. (default: false)

Implementation Reference

  • Core handler that loads the JSON file from disk, generates the skeleton recursively, and returns a result dictionary with file metadata and the skeleton.
    def process_file(self, file_path: str, max_length: int = None, type_only: bool = False) -> Dict[str, Any]:
        """Process a JSON file and return skeleton."""
        # Update max_length if provided
        if max_length is not None:
            self.max_value_length = max_length
        
        # Set type_only mode
        self.type_only_mode = type_only
        
        path = Path(file_path)
        
        if not path.exists():
            raise FileNotFoundError(f"File not found: {file_path}")
        
        if not path.is_file():
            raise ValueError(f"Path is not a file: {file_path}")
        
        try:
            with open(path, 'r', encoding='utf-8') as f:
                data = json.load(f)
        except json.JSONDecodeError as e:
            raise ValueError(f"Invalid JSON file: {e}")
        except Exception as e:
            raise Exception(f"Error reading file: {e}")
        
        skeleton = self.create_skeleton(data)
        
        return {
            "file_path": str(path.absolute()),
            "file_size": path.stat().st_size,
            "skeleton": skeleton
        }
  • Input schema defining parameters: file_path (required), optional max_length and type_only.
    inputSchema={
        "type": "object",
        "properties": {
            "file_path": {
                "type": "string",
                "description": "Path to the JSON file to process"
            },
            "max_length": {
                "type": "integer",
                "description": "Maximum length for string values (default: 200)",
                "default": 200
            },
            "type_only": {
                "type": "boolean",
                "description": "Return only value types instead of values. Most compact output. (default: false)",
                "default": False
            }
        },
        "required": ["file_path"]
    }
  • Registers the 'json_skeleton' tool in the MCP server with name, description, and input schema.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        """List available tools."""
        return [
            Tool(
                name="json_skeleton",
                description="Create a lightweight JSON skeleton that preserves structure with truncated values and deduplicated arrays. Useful when encountering 'File content exceeds maximum allowed size' errors with large JSON files.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "file_path": {
                            "type": "string",
                            "description": "Path to the JSON file to process"
                        },
                        "max_length": {
                            "type": "integer",
                            "description": "Maximum length for string values (default: 200)",
                            "default": 200
                        },
                        "type_only": {
                            "type": "boolean",
                            "description": "Return only value types instead of values. Most compact output. (default: false)",
                            "default": False
                        }
                    },
                    "required": ["file_path"]
                }
            )
        ]
  • MCP server handler for tool calls; specifically handles 'json_skeleton' by invoking SkeletonGenerator.process_file and returning formatted skeleton as TextContent.
    @server.call_tool()
    async def call_tool(name: str, arguments: Dict[str, Any]) -> list[TextContent]:
        """Handle tool calls."""
        try:
            if name == "json_skeleton":
                file_path = arguments.get("file_path")
                if not file_path:
                    return [TextContent(type="text", text="Error: file_path is required")]
                
                max_length = arguments.get("max_length", 200)
                type_only = arguments.get("type_only", False)
                result = skeleton_generator.process_file(file_path, max_length=max_length, type_only=type_only)
                
                # Format the output - just the skeleton
                output = json.dumps(result['skeleton'], indent=2, ensure_ascii=False)
                
                return [TextContent(type="text", text=output)]
            
            else:
                return [TextContent(type="text", text=f"Error: Unknown tool '{name}'")]
        
        except FileNotFoundError as e:
            return [TextContent(type="text", text=f"Error: {str(e)}")]
        except ValueError as e:
            return [TextContent(type="text", text=f"Error: {str(e)}")]
        except Exception as e:
            # Log error to stderr for debugging
            import sys
            print(f"Error processing file: {str(e)}", file=sys.stderr)
            return [TextContent(type="text", text=f"Error: Failed to process file - {str(e)}")]
  • Delegates to recursive _process_value for generating the skeleton from JSON data.
    def create_skeleton(self, data: Any) -> Any:
        """
        Create a lightweight skeleton with:
        - Truncated string values (configurable max length)
        - Deduplicated array items (keeping unique DTOs)
        """
        return self._process_value(data)
Behavior4/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 effectively describes key behavioral traits: the tool creates a transformed version of JSON files (preserving structure while truncating values and deduplicating arrays), addresses size constraints, and mentions the specific error scenario it helps resolve. It doesn't cover all potential behavioral aspects like error handling or performance characteristics, but provides substantial operational context beyond basic functionality.

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 perfectly concise with two sentences that each serve distinct purposes: the first explains what the tool does and its key features, the second provides the specific usage context. There's zero wasted language, and the most important information (what it creates and why) is front-loaded. Every word earns its place.

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 moderate complexity (3 parameters, no output schema, no annotations), the description provides good contextual completeness. It explains the tool's purpose, when to use it, and key behavioral characteristics. The main gap is the lack of information about the output format - what exactly the 'JSON skeleton' looks like, whether it maintains the original file structure completely, or if there are any limitations on the transformations. However, for a tool with good schema coverage and clear purpose, it's mostly complete.

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?

The schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema - it doesn't explain how 'max_length' relates to 'truncated values' or how 'type_only' affects the deduplication process. However, it provides overall context about what the parameters collectively achieve, which maintains the baseline score.

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 ('create', 'preserves', 'truncated', 'deduplicated') and resources ('JSON skeleton', 'large JSON files'). It distinguishes itself by addressing a specific error scenario ('File content exceeds maximum allowed size') and explains what makes the output 'lightweight' - truncated values and deduplicated arrays. This goes beyond just restating the name/title.

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 for when to use this tool: 'when encountering File content exceeds maximum allowed size errors with large JSON files.' This gives a specific trigger condition. However, it doesn't mention when NOT to use it or discuss alternatives (though there are no sibling tools listed, so this limitation is understandable). The guidance is explicit but lacks exclusion criteria.

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/jskorlol/json-skeleton-mcp'

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