-
Notifications
You must be signed in to change notification settings - Fork 19
Add MCP tooling, observability support for CrewAI Python #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements complete MCP (Model Context Protocol) tooling and Agent 365 observability for the CrewAI Python sample, enabling integration with Microsoft 365 services (Mail, Calendar, Copilot) with full distributed tracing support.
Changes:
- Added MCP tool registration service with SSE transport, bearer token authentication, and connection management with fallback to ToolingManifest.json for local development
- Implemented three-level observability architecture with InvokeAgentScope, InferenceScope, and ExecuteToolScope for comprehensive tracing
- Added notification handlers for email and Teams @mentions with proper routing for both 'agents' and 'msteams' channels
- Created observable MCP tool wrappers that integrate with CrewAI's BaseTool interface, replacing direct mcps parameter usage
- Enhanced configuration with comprehensive .env.template documentation and Azure OpenAI support via LiteLLM
- Fixed duplicate email issue by updating tasks.yaml to designate only the Driving Safety Specialist for sending emails
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| turn_context_utils.py | Added build_baggage_builder utility and improved context extraction with fallback values for agent_id and tenant_id |
| token_cache.py | Enhanced with clear_token_cache function and improved documentation for agentic token caching |
| src/crew_agent/crew.py | Changed from mcps parameter to observable mcp_tools list for better observability integration |
| src/crew_agent/config/tasks.yaml | Added explicit instructions to prevent duplicate emails - only Driving Safety Specialist sends emails |
| pyproject.toml | Added azure-ai-inference, observability-hosting, and notifications package dependencies |
| observability_config.py | Refactored to module-level initialization with _initialize_observability_once pattern |
| mcp_tool_registration_service.py | Major expansion with full MCP server discovery, SSE parsing, tool listing, execution with retry logic, and fallback to ToolingManifest.json |
| host_agent_server.py | Added comprehensive notification handling for email and Word mentions with proper token setup |
| driving_safety_report.md | Sample output file showing weather report and driving safety assessment (appears to be test artifact) |
| agent.py | Major refactor with observable MCP tool wrappers, ExecuteToolScope integration, notification handling, and enhanced error handling |
| ToolingManifest.json | Added mcp_M365Copilot and mcp_CalendarTools server configurations |
| README.md | Comprehensive documentation update with architecture diagrams, MCP tools table, configuration guide, and troubleshooting section |
| .env.template | Extensive documentation with clear sections for OpenAI/Azure OpenAI, MCP auth, Tavily API, observability, and server configuration |
Summary
This PR has the complete MCP tooling implementation and observability features of the CrewAI sample agent, enabling full Microsoft 365 integration with proper tracing.
Changes
MCP Tooling
BaseToolinterfaceToolingManifest.jsonwith Mail, Calendar, and M365 Copilot MCP serversObservability
InvokeAgentScope: Wraps entire agent invocationInferenceScope: Wraps CrewAI crew execution (LLM calls)ExecuteToolScope: Wraps each MCP tool executionobservability_config.pyfor module-level initializationtoken_cache.pyfor bearer token managementNotifications
host_agent_server.pyhandle_agent_notification_activity()inagent.pyBug Fixes
tasks.yaml- only the Driving Safety Specialist agent sends emails nowazure/model prefixDocumentation
README.mdwith architecture diagrams, configuration guide, and troubleshooting section.env.templatewith detailed comments explaining each environment variableTesting
Tested with Agents Playground:
Related