import { Agent } from "@mastra/core/agent";
async function handleUserRequest(userPrompt: string, userApiKey: string) {
// Create a client for the specific user's request
const userMcpClient = new MCPClient({
servers: {
observee: {
url: new URL("https://mcp.observee.ai/mcp?client_id={your_client_id}"),
requestInit: {
headers: {
Authorization: `Bearer ${userApiKey}`,
},
},
},
},
});
// Fetch toolsets dynamically
const toolsets = await userMcpClient.getToolsets();
const agent = new Agent({ /* ... */ });
const response = await agent.stream(userPrompt, { toolsets });
await userMcpClient.disconnect();
return response;
}