@gork-labs/secondbrain-mcp
Version:
Second Brain MCP Server - Agent team orchestration with dynamic tool discovery
57 lines (56 loc) • 1.82 kB
TypeScript
/**
* Simple Integration Example for OpenAI Function Calling
*
* This shows how to integrate the OpenAI function calling executor into
* the existing SecondBrain MCP server to replace regex-based tool parsing.
*
* Created: 2025-07-25T17:17:13+02:00
* Author: Staff Software Engineer - Gorka
*/
/**
* Example integration in server.ts executeWithOpenAI method
*/
export declare class SimplifiedServerIntegration {
private mcpClientManager;
private openaiExecutor;
constructor(mcpClientManager: any);
/**
* Enhanced executeWithOpenAI method using OpenAI function calling
*/
executeWithOpenAI(instructions: string, chatmodeDefinition: {
name: string;
}, sessionId: string): Promise<any>;
/**
* Legacy implementation (existing regex-based approach)
* Keep this as fallback during transition
*/
private executeWithOpenAILegacy;
}
/**
* Environment Configuration Guide
*
* To use OpenAI function calling, set this environment variable:
*
* # Required: OpenAI API key
* OPENAI_API_KEY=your-openai-api-key
*
* # Optional: Specify which chatmodes to use it for (if not set, all chatmodes)
* SECONDBRAIN_FUNCTION_CALLING_CHATMODES=Software Engineer,Security Engineer,Database Architect
*/
/**
* Quick Setup Steps:
*
* 1. Set OPENAI_API_KEY in your .env file
* 2. Import OpenAIFunctionCallingExecutor and FunctionCallingConfig in server.ts
* 3. Replace the executeWithOpenAI method logic with the example above
* 4. Test with one chatmode first (e.g., Software Engineer)
* 5. Gradually expand to other chatmodes
*
* Benefits:
* - No more regex parsing errors
* - Built-in JSON validation
* - Better error handling
* - Automatic retry logic
* - Performance monitoring
* - No feature flags needed - just works with OpenAI SDK
*/