echo_json
Validate and analyze JSON data by echoing it back with structured analysis for testing MCP protocol functionality.
Instructions
Echo back structured JSON data with validation and analysis.
Args: data: The JSON data to echo back ctx: MCP context
Returns: Echo response with data analysis
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes |
Implementation Reference
- src/mcp_echo/server.py:121-150 (handler)The main handler function for the echo_json MCP tool. It validates, analyzes, and returns the provided JSON data.
@mcp.tool() async def echo_json(data: dict[str, Any], ctx: Context | None = None) -> EchoJsonResponse: """Echo back structured JSON data with validation and analysis. Args: data: The JSON data to echo back ctx: MCP context Returns: Echo response with data analysis """ import json if ctx: await ctx.info(f"Echoing JSON data with {len(data)} keys...") # Analyze the data structure analysis = DataAnalysis( key_count=len(data), keys=list(data.keys()), data_types={key: type(value).__name__ for key, value in data.items()}, total_size=len(json.dumps(data)), ) return EchoJsonResponse( original_data=data, echoed_data=data, analysis=analysis, timestamp=datetime.now(UTC).isoformat(), ) - src/mcp_echo/api_models.py:39-45 (schema)The Pydantic schema defining the response structure for the echo_json tool.
class EchoJsonResponse(BaseModel): """Response model for echo_json tool.""" original_data: dict[str, Any] = Field(..., description="The original JSON data sent") echoed_data: dict[str, Any] = Field(..., description="The echoed JSON data") analysis: DataAnalysis = Field(..., description="Analysis of the data structure") timestamp: str = Field(..., description="ISO 8601 timestamp of the operation")