activando agent con mcp
This commit is contained in:
@@ -12,7 +12,7 @@ console.log(`Using Gemini API key: ${API_KEY}`);
|
||||
|
||||
const genAI = API_KEY ? new GoogleGenAI({ apiKey: API_KEY }) : null;
|
||||
|
||||
const MCP_URL = process.env.MCP_URL || 'http://planilla.interno.mcp';
|
||||
const MCP_URL = process.env.MCP_URL || 'http://planilla.interno.com/mcp';
|
||||
let mcpClient: Client | undefined;
|
||||
let mcpTransport: StreamableHTTPClientTransport | undefined;
|
||||
|
||||
@@ -45,6 +45,7 @@ app.post('/', async (req, res) => {
|
||||
const contents = `Repo information: ${repoInfo}\nUser message: ${message}`;
|
||||
const config: any = {};
|
||||
if (message.toLowerCase().includes('/planilla')) {
|
||||
console.log('Using Model Context Protocol tools ', MCP_URL);
|
||||
const client = await getMcpClient();
|
||||
config.tools = [mcpToTool(client)];
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { helloWorldAgent } from './helloAgent';
|
||||
import { WhatsAppMessage } from './types';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
export type Handler = string | ((msg: WhatsAppMessage | string) => Promise<string>);
|
||||
|
||||
export const chatHandlers: Record<string, Handler> = {
|
||||
'50498554225@c.us': 'http://conversation-layer-agent:8001',
|
||||
'repo-helper@c.us': 'http://conversation-layer-agent:8001',
|
||||
'50498554225@c.us': process.env.CONVERSATION_AGENT_URL || 'http://conversation-layer-agent:8001',
|
||||
// Add other mappings like:
|
||||
// '50496210031@c.us': 'http://llm-agent:8000'
|
||||
};
|
||||
|
||||
@@ -156,7 +156,7 @@ app.post('/webhook', async (req: express.Request, res: express.Response) => {
|
||||
if (!handler) throw new Error('No handler configured');
|
||||
let reply: string;
|
||||
if (typeof handler === 'string') {
|
||||
const agentRes = await axios.post(handler, {message});
|
||||
const agentRes = await axios.post(handler, {message: message.text});
|
||||
reply = agentRes.data.reply || agentRes.data;
|
||||
} else {
|
||||
reply = await handler(message);
|
||||
|
||||
Reference in New Issue
Block a user