1
+ #!/usr/bin/env python3
2
+ """
3
+ Hello World MCP Server - Absolute minimal test
4
+ Zero dependencies beyond Python standard library
5
+ Tests basic STDIO MCP functionality on Smithery
6
+ """
7
+
8
+ import json
9
+ import sys
10
+
11
+ def main ():
12
+ """Main server loop - pure STDIO MCP protocol."""
13
+ for line in sys .stdin :
14
+ try :
15
+ line = line .strip ()
16
+ if not line :
17
+ continue
18
+
19
+ request = json .loads (line )
20
+ method = request .get ("method" )
21
+ request_id = request .get ("id" )
22
+
23
+ if method == "initialize" :
24
+ response = {
25
+ "jsonrpc" : "2.0" ,
26
+ "id" : request_id ,
27
+ "result" : {
28
+ "protocolVersion" : "2024-11-05" ,
29
+ "capabilities" : {"tools" : {"listChanged" : False }},
30
+ "serverInfo" : {"name" : "hello-mcp" , "version" : "1.0.0" }
31
+ }
32
+ }
33
+
34
+ elif method == "tools/list" :
35
+ response = {
36
+ "jsonrpc" : "2.0" ,
37
+ "id" : request_id ,
38
+ "result" : {
39
+ "tools" : [{
40
+ "name" : "hello" ,
41
+ "description" : "Say hello" ,
42
+ "inputSchema" : {
43
+ "type" : "object" ,
44
+ "properties" : {"name" : {"type" : "string" , "default" : "World" }}
45
+ }
46
+ }]
47
+ }
48
+ }
49
+
50
+ elif method == "tools/call" :
51
+ tool_name = request ["params" ]["name" ]
52
+ arguments = request ["params" ].get ("arguments" , {})
53
+
54
+ if tool_name == "hello" :
55
+ name = arguments .get ("name" , "World" )
56
+ result = f"Hello, { name } ! 👋 MCP server working on Smithery!"
57
+
58
+ response = {
59
+ "jsonrpc" : "2.0" ,
60
+ "id" : request_id ,
61
+ "result" : {
62
+ "content" : [{"type" : "text" , "text" : result }]
63
+ }
64
+ }
65
+ else :
66
+ response = {
67
+ "jsonrpc" : "2.0" ,
68
+ "id" : request_id ,
69
+ "error" : {"code" : - 32601 , "message" : f"Unknown tool: { tool_name } " }
70
+ }
71
+
72
+ else :
73
+ response = {
74
+ "jsonrpc" : "2.0" ,
75
+ "id" : request_id ,
76
+ "error" : {"code" : - 32601 , "message" : f"Method not found: { method } " }
77
+ }
78
+
79
+ print (json .dumps (response ), flush = True )
80
+
81
+ except Exception as e :
82
+ error_response = {
83
+ "jsonrpc" : "2.0" ,
84
+ "id" : request .get ("id" ) if 'request' in locals () else None ,
85
+ "error" : {"code" : - 32603 , "message" : f"Error: { str (e )} " }
86
+ }
87
+ print (json .dumps (error_response ), flush = True )
88
+
89
+ if __name__ == "__main__" :
90
+ main ()
0 commit comments