Add MCP tooling, observability support for CrewAI Python#201
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 |
nikhilNava
requested changes
Jan 30, 2026
juliomenendez
previously approved these changes
Jan 30, 2026
nikhilNava
previously approved these changes
Jan 31, 2026
nikhilNava
approved these changes
Feb 2, 2026
juliomenendez
approved these changes
Feb 2, 2026
rahuldevikar761
approved these changes
Feb 2, 2026
mrunalhirve128
approved these changes
Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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