import { Agent, run, MCPServerStreamableHttp } from '@openai/agents';
async function main() {
// Instantiate the MCP server connection to Observee
// Replace {your_client_id} with your actual client ID from the Observee dashboard
const mcpServer = new MCPServerStreamableHttp({
url: 'https://mcp.observee.ai/mcp?client_id={your_client_id}',
name: 'Observee MCP Server',
requestInit: {
headers: {
'Authorization': 'Bearer {observee_api_key}' // Replace with your API key
}
}
});
// Create the Agent and register the MCP server
// The Agent will automatically discover and use all available tools from Observee
const agent = new Agent({
name: 'Observee Agent',
instructions: 'Use all available tools and knowledge to help users with their requests.',
mcpServers: [mcpServer],
});
try {
await mcpServer.connect();
// Example query - the Agent will use appropriate Observee tools to answer
const result = await run(agent, 'Help me analyze the latest data from our monitoring system');
console.log(result.finalOutput);
} catch (error) {
console.error('Connection failed:', error);
// Check your client ID, API key, and network connection
} finally {
await mcpServer.close();
}
}
main().catch(console.error);