feat: more work on mcp server integration
This commit is contained in:
@@ -125,6 +125,16 @@ function runWebContentsMenuAction(sender: any, action: AppMenuAction): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function buildMcpUrl(): string {
|
||||
try {
|
||||
const { getMCPServer } = require('../engine/MCPServer');
|
||||
const port = getMCPServer().getPort() ?? 4124;
|
||||
return `http://127.0.0.1:${port}/mcp`;
|
||||
} catch {
|
||||
return 'http://127.0.0.1:4124/mcp';
|
||||
}
|
||||
}
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
// ============ Git Handlers ============
|
||||
|
||||
@@ -1562,6 +1572,47 @@ export function registerIpcHandlers(): void {
|
||||
registerBlogHandlers(safeHandle);
|
||||
registerPublishHandlers(safeHandle);
|
||||
|
||||
// ============ MCP Config Handlers ============
|
||||
|
||||
safeHandle('mcp:getAgents', async () => {
|
||||
const { MCPAgentConfigEngine } = await import('../engine/MCPAgentConfigEngine');
|
||||
const engine = new MCPAgentConfigEngine({
|
||||
homeDir: require('os').homedir(),
|
||||
platform: process.platform,
|
||||
mcpUrl: buildMcpUrl(),
|
||||
});
|
||||
return engine.getAgents();
|
||||
});
|
||||
|
||||
safeHandle('mcp:addToAgentConfig', async (_event: unknown, agentId: string) => {
|
||||
const { MCPAgentConfigEngine } = await import('../engine/MCPAgentConfigEngine');
|
||||
const engine = new MCPAgentConfigEngine({
|
||||
homeDir: require('os').homedir(),
|
||||
platform: process.platform,
|
||||
mcpUrl: buildMcpUrl(),
|
||||
});
|
||||
return engine.addToConfig(agentId as import('../engine/MCPAgentConfigEngine').MCPAgentId);
|
||||
});
|
||||
|
||||
safeHandle('mcp:isConfigured', async (_event: unknown, agentId: string) => {
|
||||
const { MCPAgentConfigEngine } = await import('../engine/MCPAgentConfigEngine');
|
||||
const engine = new MCPAgentConfigEngine({
|
||||
homeDir: require('os').homedir(),
|
||||
platform: process.platform,
|
||||
mcpUrl: buildMcpUrl(),
|
||||
});
|
||||
return engine.isConfigured(agentId as import('../engine/MCPAgentConfigEngine').MCPAgentId);
|
||||
});
|
||||
|
||||
safeHandle('mcp:getPort', async () => {
|
||||
try {
|
||||
const { getMCPServer } = await import('../engine/MCPServer');
|
||||
return getMCPServer().getPort();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// ============ Event Forwarding ============
|
||||
|
||||
// Forward engine events to renderer
|
||||
|
||||
Reference in New Issue
Block a user