File size: 1,070 Bytes
58234a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import uuid
import time
from typing import Dict, Any, Optional
from pydantic import BaseModel, Field
class MCPEnvelope(BaseModel):
"""
Standardized Model Context Protocol (MCP) Envelope for Agent communication.
Reflects the 2025/2026 industry standard for agentic interoperability.
"""
jsonrpc: str = "2.0"
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
method: str
params: Dict[str, Any]
timestamp: float = Field(default_factory=time.time)
trace_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
class AegisAgentResponse(BaseModel):
"""Encapsulates the response from an Aegis Agent with reasoning metadata."""
result: Any
reasoning_chain: Optional[str] = None
confidence_score: float = 1.0
def mcp_call(method: str, params: Dict[str, Any]) -> MCPEnvelope:
"""Helper to wrap calls into MCP envelopes for logging and telemetry."""
envelope = MCPEnvelope(method=method, params=params)
print(f"[MCP] >> CALL {envelope.method} (Trace: {envelope.trace_id[:8]})")
return envelope
|