Skip to content

Commit 18a817e

Browse files
committed
Fix tests
Signed-off-by: Donnie Adams <[email protected]>
1 parent 2821d66 commit 18a817e

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

pkg/mcp/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (l *Local) sessionToTools(ctx context.Context, session *Session, toolName s
142142
Description: tool.Description,
143143
Arguments: &schema,
144144
},
145-
Instructions: types.MCPInvokePrefix + "." + tool.Name + " " + session.ID + " " + tool.Name,
145+
Instructions: types.MCPInvokePrefix + tool.Name + " " + session.ID,
146146
},
147147
}
148148

pkg/mcp/runner.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ import (
1212

1313
func (l *Local) Run(ctx context.Context, _ chan<- types.CompletionStatus, tool types.Tool, input string) (string, error) {
1414
fields := strings.Fields(tool.Instructions)
15-
if len(fields) < 3 {
15+
if len(fields) < 2 {
1616
return "", fmt.Errorf("invalid mcp call, invalid number of fields in %s", tool.Instructions)
1717
}
1818

1919
id := fields[1]
20-
toolName := fields[2]
20+
toolName, ok := strings.CutPrefix(fields[0], types.MCPInvokePrefix)
21+
if !ok {
22+
return "", fmt.Errorf("invalid mcp call, invalid tool name in %s", tool.Instructions)
23+
}
24+
2125
arguments := map[string]any{}
2226

2327
if input != "" {

pkg/tests/runner2_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ name: mcp
308308
],
309309
"type": "object"
310310
},
311-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f append_insight",
311+
"instructions": "#!sys.mcp.invoke.append_insight e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
312312
"id": "inline:append_insight",
313313
"localTools": {
314314
"append_insight": "inline:append_insight",
@@ -341,7 +341,7 @@ name: mcp
341341
],
342342
"type": "object"
343343
},
344-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f create_table",
344+
"instructions": "#!sys.mcp.invoke.create_table e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
345345
"id": "inline:create_table",
346346
"localTools": {
347347
"append_insight": "inline:append_insight",
@@ -374,7 +374,7 @@ name: mcp
374374
],
375375
"type": "object"
376376
},
377-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f describe_table",
377+
"instructions": "#!sys.mcp.invoke.describe_table e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
378378
"id": "inline:describe_table",
379379
"localTools": {
380380
"append_insight": "inline:append_insight",
@@ -398,7 +398,7 @@ name: mcp
398398
"arguments": {
399399
"type": "object"
400400
},
401-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f list_tables",
401+
"instructions": "#!sys.mcp.invoke.list_tables e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
402402
"id": "inline:list_tables",
403403
"localTools": {
404404
"append_insight": "inline:append_insight",
@@ -500,7 +500,7 @@ name: mcp
500500
],
501501
"type": "object"
502502
},
503-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f read_query",
503+
"instructions": "#!sys.mcp.invoke.read_query e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
504504
"id": "inline:read_query",
505505
"localTools": {
506506
"append_insight": "inline:append_insight",
@@ -533,7 +533,7 @@ name: mcp
533533
],
534534
"type": "object"
535535
},
536-
"instructions": "#!sys.mcp.invoke 441826308787ad271e84a381e90d8eccc3fce0fe94503636e679bd0984c79f2f write_query",
536+
"instructions": "#!sys.mcp.invoke.write_query e057d98f5d43e56fda04eb3e7ea6120c93b5bcaf832090fca76e8d744e2de494",
537537
"id": "inline:write_query",
538538
"localTools": {
539539
"append_insight": "inline:append_insight",

pkg/types/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
EchoPrefix = "#!sys.echo"
2222
CallPrefix = "#!sys.call"
2323
MCPPrefix = "#!mcp"
24-
MCPInvokePrefix = "#!sys.mcp.invoke"
24+
MCPInvokePrefix = "#!sys.mcp.invoke."
2525
CommandPrefix = "#!"
2626
PromptPrefix = "!!"
2727
)

pkg/types/toolstring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func ToDisplayText(tool Tool, input string) string {
4444
}
4545

4646
func ToSysDisplayString(id string, args map[string]string) (string, error) {
47-
if suffix, ok := strings.CutPrefix(id, "sys.mcp.invoke."); ok {
47+
if suffix, ok := strings.CutPrefix(id, MCPInvokePrefix); ok {
4848
return fmt.Sprintf("Invoking MCP `%s`", suffix), nil
4949
}
5050

0 commit comments

Comments
 (0)