Skip to content

Conversation

@JoanBency
Copy link
Contributor

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

  • Added MCP tool registration service with SSE transport and bearer token authentication
  • Created observable MCP tool wrappers that integrate with CrewAI's BaseTool interface
  • Configured ToolingManifest.json with Mail, Calendar, and M365 Copilot MCP servers

Observability

  • Implemented complete Agent 365 observability with three scope levels:
    • InvokeAgentScope: Wraps entire agent invocation
    • InferenceScope: Wraps CrewAI crew execution (LLM calls)
    • ExecuteToolScope: Wraps each MCP tool execution
  • Added observability_config.py for module-level initialization
  • Added token_cache.py for bearer token management

Notifications

  • Added email and Teams @mention notification support in host_agent_server.py
  • Implemented handle_agent_notification_activity() in agent.py

Bug Fixes

  • Fixed duplicate email issue by updating tasks.yaml - only the Driving Safety Specialist agent sends emails now
  • Added Azure OpenAI support with LiteLLM azure/ model prefix

Documentation

  • Updated README.md with architecture diagrams, configuration guide, and troubleshooting section
  • Updated .env.template with detailed comments explaining each environment variable

Testing

Tested with Agents Playground:

  • ✅ Weather lookup via Tavily API
  • ✅ Email sending via MCP MailTools
  • ✅ Observable tool execution with ExecuteToolScope traces
  • ✅ Azure OpenAI integration with gpt-4.1 deployment

Related

  • Mirrors implementation from Claude Python sample
  • Uses Microsoft Agent 365 SDK patterns

@JoanBency JoanBency requested a review from a team as a code owner January 30, 2026 07:58
Copilot AI review requested due to automatic review settings January 30, 2026 07:58
Copy link
Contributor

Copilot AI left a 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

juliomenendez
juliomenendez previously approved these changes Jan 30, 2026
nikhilNava
nikhilNava previously approved these changes Jan 31, 2026
@JoanBency JoanBency enabled auto-merge (squash) February 2, 2026 15:33
@JoanBency JoanBency merged commit 1107d29 into main Feb 2, 2026
18 checks passed
@JoanBency JoanBency deleted the JoanBency/CrewAIPython-AddMCPTooling branch February 2, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants