/ examples / mcp_server / http_stream_server.py
http_stream_server.py
 1  #!/usr/bin/env python3
 2  """
 3  HTTP Stream MCP Server Example
 4  
 5  Run PraisonAI as an MCP server using HTTP Stream transport.
 6  This transport is useful for web-based integrations.
 7  
 8  Usage:
 9      python http_stream_server.py
10  
11  Or via CLI:
12      praisonai mcp serve --transport http-stream --port 8080
13  """
14  
15  
16  def main():
17      """Run MCP server with HTTP Stream transport."""
18      from praisonai.mcp_server.server import MCPServer
19      from praisonai.mcp_server.adapters import register_all
20      
21      # Register all tools, resources, and prompts
22      register_all()
23      
24      # Create server
25      server = MCPServer(
26          name="praisonai",
27          version="1.0.0",
28          instructions="PraisonAI MCP Server - AI agent capabilities via MCP protocol.",
29      )
30      
31      # Run with HTTP Stream transport
32      server.run(
33          transport="http-stream",
34          host="127.0.0.1",
35          port=8080,
36          endpoint="/mcp",
37      )
38  
39  
40  if __name__ == "__main__":
41      print("Starting PraisonAI MCP Server on http://127.0.0.1:8080/mcp")
42      print("Protocol Version: 2025-11-25")
43      print("Press Ctrl+C to stop")
44      main()