@@ -58,7 +58,10 @@ 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 := "default-project"
62
+ if name , ok := data ["projectName" ].(string ); ok {
63
+ projectName = name
64
+ }
62
65
framework := "none"
63
66
if fw , ok := data ["framework" ].(string ); ok {
64
67
framework = fw
@@ -123,8 +126,7 @@ func main() {
123
126
mcp .WithString ("data" , mcp .Required (), mcp .Description ("Data to process" )),
124
127
),
125
128
func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
126
- data := request .GetArguments ()["data" ].(string )
127
-
129
+ data := request .GetString ("data" , "" )
128
130
// Only request elicitation if data seems sensitive
129
131
if len (data ) > 100 {
130
132
elicitationRequest := mcp.ElicitationRequest {
@@ -160,7 +162,11 @@ func main() {
160
162
}, nil
161
163
}
162
164
163
- responseData := result .Response .Value .(map [string ]interface {})
165
+ responseData , ok := result .Response .Value .(map [string ]interface {})
166
+ if ! ok {
167
+ responseData = make (map [string ]interface {})
168
+ }
169
+
164
170
if proceed , ok := responseData ["proceed" ].(bool ); ! ok || ! proceed {
165
171
reason := "No reason provided"
166
172
if r , ok := responseData ["reason" ].(string ); ok && r != "" {
0 commit comments