Overview

The OpenAI SDK allows you to connect your Agent directly to an Observee MCP (Model Context Protocol) server. This enables your Agent to access Observee’s powerful tool ecosystem, integrate with internal or external APIs, and leverage custom knowledge sources—all through a unified, secure interface.

Prerequisites

Before getting started, ensure you have:
  • Node.js 18 or later installed
  • The OpenAI SDK installed: npm install @openai/agents
  • Your Observee customer ID (found in your Observee dashboard)
  • Proper authentication configured (see Authentication Guide)

What is MCPServerStreamableHttp?

MCPServerStreamableHttp is a class provided by the OpenAI SDK for connecting to any HTTP MCP server. It manages the connection, streaming, and communication between your Agent and the server, supporting real-time, tool-augmented LLM responses. Once connected, your Agent automatically discovers and can use all available tools from the MCP server.

Example: Connecting an Agent to your deployed Observee’s MCP Server

Below is a complete example of how to set up an Agent that communicates with your Observee MCP server:
import { Agent, run, MCPServerStreamableHttp } from '@openai/agents';

async function main() {
 // Instantiate the MCP server connection to Observee
 // Replace {customer_id} with your actual customer ID from the Observee dashboard
 const mcpServer = new MCPServerStreamableHttp({
   url: 'https://mcp.observee.ai/customer/{customer_id}',
   name: 'Observee',   // Friendly name for logging/debugging
 });

 // 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 customer ID, network connection, and authentication
 } finally {
   await mcpServer.close();
 }
}

main().catch(console.error);

Learn More