Skip to content

Commit 4039722

Browse files
committed
feat(plugin): integrate skill_mcp tool with session-scoped lifecycle management
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent 439785e commit 4039722

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ import {
5858
setMainSession,
5959
getMainSessionID,
6060
} from "./features/claude-code-session-state";
61-
import { builtinTools, createCallOmoAgent, createBackgroundTools, createLookAt, createSkillTool, interactive_bash, getTmuxPath } from "./tools";
61+
import { builtinTools, createCallOmoAgent, createBackgroundTools, createLookAt, createSkillTool, createSkillMcpTool, interactive_bash, getTmuxPath } from "./tools";
6262
import { BackgroundManager } from "./features/background-agent";
63+
import { SkillMcpManager } from "./features/skill-mcp-manager";
6364
import { createBuiltinMcps } from "./mcp";
6465
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig, type HookName } from "./config";
6566
import { log, deepMerge, getUserConfigDir, addConfigLoadError, parseJsonc, detectConfigFile, migrateConfigFile } from "./shared";
@@ -292,7 +293,18 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
292293
includeClaudeSkills ? discoverProjectClaudeSkills() : [],
293294
discoverOpencodeProjectSkills(),
294295
);
295-
const skillTool = createSkillTool({ skills: mergedSkills });
296+
const skillMcpManager = new SkillMcpManager();
297+
const getSessionIDForMcp = () => getMainSessionID() || "";
298+
const skillTool = createSkillTool({
299+
skills: mergedSkills,
300+
mcpManager: skillMcpManager,
301+
getSessionID: getSessionIDForMcp,
302+
});
303+
const skillMcpTool = createSkillMcpTool({
304+
manager: skillMcpManager,
305+
getLoadedSkills: () => mergedSkills,
306+
getSessionID: getSessionIDForMcp,
307+
});
296308

297309
const googleAuthHooks = pluginConfig.google_auth !== false
298310
? await createGoogleAntigravityAuthPlugin(ctx)
@@ -309,6 +321,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
309321
call_omo_agent: callOmoAgent,
310322
look_at: lookAt,
311323
skill: skillTool,
324+
skill_mcp: skillMcpTool,
312325
...(tmuxAvailable ? { interactive_bash } : {}),
313326
},
314327

@@ -593,6 +606,9 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
593606
if (sessionInfo?.id === getMainSessionID()) {
594607
setMainSession(undefined);
595608
}
609+
if (sessionInfo?.id) {
610+
await skillMcpManager.disconnectSession(sessionInfo.id);
611+
}
596612
}
597613

598614
if (event.type === "session.error") {

src/tools/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
export { interactive_bash, startBackgroundCheck as startTmuxCheck } from "./interactive-bash"
3232
export { createSkillTool } from "./skill"
3333
export { getTmuxPath } from "./interactive-bash/utils"
34+
export { createSkillMcpTool } from "./skill-mcp"
3435

3536
import {
3637
createBackgroundTask,

0 commit comments

Comments
 (0)