@@ -58,7 +58,11 @@ func demoElicitationHandler(s *server.MCPServer) server.ToolHandlerFunc {
58
58
return nil , fmt .Errorf ("unexpected response format" )
59
59
}
60
60
61
- projectName := data ["projectName" ].(string )
61
+ projectName , ok := data ["projectName" ].(string )
62
+ if ! ok || projectName == "" {
63
+ return nil , fmt .Errorf ("invalid or missing 'projectName' in elicitation response" )
64
+ }
65
+
62
66
framework := "none"
63
67
if fw , ok := data ["framework" ].(string ); ok {
64
68
framework = fw
@@ -123,8 +127,7 @@ func main() {
123
127
mcp .WithString ("data" , mcp .Required (), mcp .Description ("Data to process" )),
124
128
),
125
129
func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
126
- data := request .GetArguments ()["data" ].(string )
127
-
130
+ data := request .GetString ("data" , "" )
128
131
// Only request elicitation if data seems sensitive
129
132
if len (data ) > 100 {
130
133
elicitationRequest := mcp.ElicitationRequest {
@@ -160,7 +163,11 @@ func main() {
160
163
}, nil
161
164
}
162
165
163
- responseData := result .Response .Value .(map [string ]interface {})
166
+ responseData , ok := result .Response .Value .(map [string ]interface {})
167
+ if ! ok {
168
+ responseData = make (map [string ]interface {})
169
+ }
170
+
164
171
if proceed , ok := responseData ["proceed" ].(bool ); ! ok || ! proceed {
165
172
reason := "No reason provided"
166
173
if r , ok := responseData ["reason" ].(string ); ok && r != "" {
0 commit comments