Skip to content

Commit 3d1d113

Browse files
committed
allow to rename tools in opencode
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 00ec8e9 commit 3d1d113

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

opencode/main.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,54 @@ func main() {
8080
Version: "v1.0.0",
8181
}, nil)
8282

83+
startSessionName := os.Getenv("OPENCODE_TOOL_START_SESSION_NAME")
84+
if startSessionName == "" {
85+
startSessionName = "start_session"
86+
}
87+
88+
getSessionStatusName := os.Getenv("OPENCODE_TOOL_GET_SESSION_STATUS_NAME")
89+
if getSessionStatusName == "" {
90+
getSessionStatusName = "get_session_status"
91+
}
92+
93+
getSessionLogsName := os.Getenv("OPENCODE_TOOL_GET_SESSION_LOGS_NAME")
94+
if getSessionLogsName == "" {
95+
getSessionLogsName = "get_session_logs"
96+
}
97+
98+
stopSessionName := os.Getenv("OPENCODE_TOOL_STOP_SESSION_NAME")
99+
if stopSessionName == "" {
100+
stopSessionName = "stop_session"
101+
}
102+
103+
listSessionsName := os.Getenv("OPENCODE_TOOL_LIST_SESSIONS_NAME")
104+
if listSessionsName == "" {
105+
listSessionsName = "list_sessions"
106+
}
107+
83108
// Register tools
84109
mcp.AddTool(server, &mcp.Tool{
85-
Name: "start_session",
110+
Name: startSessionName,
86111
Description: "Start a new opencode session with a message. Returns a session ID that can be used to check status and retrieve logs.",
87112
}, StartSessionHandler)
88113

89114
mcp.AddTool(server, &mcp.Tool{
90-
Name: "get_session_status",
115+
Name: getSessionStatusName,
91116
Description: "Get the status of an opencode session by ID. Returns running, completed, failed, or not_found.",
92117
}, GetSessionStatusHandler)
93118

94119
mcp.AddTool(server, &mcp.Tool{
95-
Name: "get_session_logs",
120+
Name: getSessionLogsName,
96121
Description: "Get the stdout and stderr logs from an opencode session. Optionally specify the number of lines to retrieve (default 100).",
97122
}, GetSessionLogsHandler)
98123

99124
mcp.AddTool(server, &mcp.Tool{
100-
Name: "stop_session",
125+
Name: stopSessionName,
101126
Description: "Stop a running opencode session by ID. Optionally force kill the process.",
102127
}, StopSessionHandler)
103128

104129
mcp.AddTool(server, &mcp.Tool{
105-
Name: "list_sessions",
130+
Name: listSessionsName,
106131
Description: "List all opencode sessions. Optionally filter by status: running, completed, failed, or all.",
107132
}, ListSessionsHandler)
108133

0 commit comments

Comments
 (0)