Skip to content

Commit bc5d245

Browse files
committed
fix(codersdk/toolsdk): fix tool schemata
1 parent 6330b0d commit bc5d245

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cli/exp_mcp.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ func getAgentToken(fs afero.Fs) (string, error) {
689689
// mcpFromSDK adapts a toolsdk.Tool to go-mcp's server.ServerTool.
690690
// It assumes that the tool responds with a valid JSON object.
691691
func mcpFromSDK(sdkTool toolsdk.Tool[any]) server.ServerTool {
692+
// NOTE: some clients will silently refuse to use tools if there is an issue
693+
// with the tool's schema or configuration.
694+
if sdkTool.Schema.Properties == nil {
695+
panic("developer error: schema properties cannot be nil")
696+
}
692697
return server.ServerTool{
693698
Tool: mcp.Tool{
694699
Name: sdkTool.Tool.Name,

codersdk/toolsdk/toolsdk.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ is provisioned correctly and the agent can connect to the control plane.
259259
Tool: aisdk.Tool{
260260
Name: "coder_list_templates",
261261
Description: "Lists templates for the authenticated user.",
262+
Schema: aisdk.Schema{
263+
Properties: map[string]any{},
264+
Required: []string{},
265+
},
262266
},
263267
Handler: func(ctx context.Context, _ map[string]any) ([]MinimalTemplate, error) {
264268
client, err := clientFromContext(ctx)
@@ -318,6 +322,10 @@ is provisioned correctly and the agent can connect to the control plane.
318322
Tool: aisdk.Tool{
319323
Name: "coder_get_authenticated_user",
320324
Description: "Get the currently authenticated user, similar to the `whoami` command.",
325+
Schema: aisdk.Schema{
326+
Properties: map[string]any{},
327+
Required: []string{},
328+
},
321329
},
322330
Handler: func(ctx context.Context, _ map[string]any) (codersdk.User, error) {
323331
client, err := clientFromContext(ctx)

0 commit comments

Comments
 (0)