mcp_hello_world
Demonstrates how to create and integrate custom tools using the Model Control Protocol framework by returning a greeting message.
Instructions
A simple demonstration tool that returns a greeting message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes | Dummy parameter for no-parameter tools |
Implementation Reference
- The handler logic for the 'mcp_hello_world' tool. It returns a TextContent object with a greeting message when the tool is called.if name == "mcp_hello_world": return [ types.TextContent( type="text", text="Hello World! 這是您的第一個 mcp 工具!" ) ]
- The input schema for the 'mcp_hello_world' tool, defining a required dummy 'random_string' parameter.inputSchema={ "type": "object", "properties": { "random_string": { "type": "string", "description": "Dummy parameter for no-parameter tools" } }, "required": ["random_string"], },
- src/southasia/handlers/hello_world.py:13-26 (registration)The registration of the 'mcp_hello_world' tool object in the handle_list_tools function, which includes the name, description, and input schema.types.Tool( name="mcp_hello_world", description="A simple demonstration tool that returns a greeting message", inputSchema={ "type": "object", "properties": { "random_string": { "type": "string", "description": "Dummy parameter for no-parameter tools" } }, "required": ["random_string"], }, ),
- src/southasia/server.py:31-37 (registration)Registration of the hello_world handlers (including mcp_hello_world) in the HANDLERS list, matched by prefix 'mcp_hello'.HANDLERS = [ { "prefixes": ["mcp_hello"], "list_tools": hello_world_list_tools, "call_tool": hello_world_call_tool } ]
- src/southasia/server.py:64-68 (registration)Top-level registration of the combined list_tools and call_tool handlers on the MCP server instance.# 註冊工具列表處理器 server.list_tools()(combined_list_tools) # 註冊工具調用處理器 server.call_tool()(combined_call_tool)