echo_message
Echo back messages with optional uppercase formatting to test MCP protocol functionality and verify communication channels.
Instructions
Echo back a message with optional formatting.
Args: message: The message to echo back uppercase: Whether to convert the message to uppercase ctx: MCP context
Returns: Complete echo response with metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | ||
| uppercase | No |
Implementation Reference
- src/mcp_echo/server.py:59-83 (handler)The main handler function for the `echo_message` tool.
async def echo_message( message: str, uppercase: bool = False, ctx: Context | None = None ) -> EchoMessageResponse: """Echo back a message with optional formatting. Args: message: The message to echo back uppercase: Whether to convert the message to uppercase ctx: MCP context Returns: Complete echo response with metadata """ if ctx: await ctx.info(f"Echoing message (uppercase={uppercase}): {message[:50]}...") result_message = message.upper() if uppercase else message return EchoMessageResponse( original_message=message, echoed_message=result_message, uppercase_applied=uppercase, message_length=len(message), timestamp=datetime.now(UTC).isoformat(), ) - src/mcp_echo/server.py:58-58 (registration)Registration of the `echo_message` tool using the `@mcp.tool()` decorator.
@mcp.tool() - src/mcp_echo/api_models.py:8-12 (schema)Response schema definition for the `echo_message` tool.
class EchoMessageResponse(BaseModel): """Response model for echo_message tool.""" original_message: str = Field(..., description="The original message sent") echoed_message: str = Field(..., description="The echoed message (possibly transformed)")