fix: load ejclaw mcp tools on claude first turn

This commit is contained in:
Eyejoker
2026-05-23 09:30:06 +09:00
committed by GitHub
parent 262534cac9
commit 763828e4f5
6 changed files with 101 additions and 18 deletions

View File

@@ -0,0 +1,35 @@
import type { McpStdioServerConfig } from '@anthropic-ai/claude-agent-sdk';
export interface EjclawMcpServerConfigInput {
chatJid: string;
groupFolder: string;
isMain: boolean;
agentType: string;
roomRole: string;
ipcDir?: string;
hostIpcDir?: string;
}
export function buildEjclawMcpServerConfig(
mcpServerPath: string,
input: EjclawMcpServerConfigInput,
): McpStdioServerConfig {
return {
command: 'node',
args: [mcpServerPath],
alwaysLoad: true,
env: {
EJCLAW_CHAT_JID: input.chatJid,
EJCLAW_GROUP_FOLDER: input.groupFolder,
EJCLAW_IS_MAIN: input.isMain ? '1' : '0',
EJCLAW_AGENT_TYPE: input.agentType,
EJCLAW_ROOM_ROLE: input.roomRole,
...(input.ipcDir && {
EJCLAW_IPC_DIR: input.ipcDir,
}),
...(input.hostIpcDir && {
EJCLAW_HOST_IPC_DIR: input.hostIpcDir,
}),
},
};
}