Skip to content

Conversation

theharithsa
Copy link
Contributor

This pull request introduces a new email sending capability to the Dynatrace MCP server, allowing users and automated workflows to send emails via the Dynatrace Email API. It includes a new send_email tool with support for multiple recipients, formatted content, incident and security alert templates, and comprehensive integration tests. The documentation has been updated to reflect these changes, including required OAuth scopes, usage examples, and new rule file references.

New Email Sending Functionality:

  • Added send_email tool to the server, enabling email notifications via the Dynatrace Email API with support for TO, CC, BCC recipients, subject, body (plain text or HTML), and optional notification settings URL. The functionality is exposed as a tool with schema validation and is available for use in workflows and automations. [1] [2] [3]
  • Implemented the core email sending logic in src/capabilities/send-email.ts, including request/response types, error handling, and support for reporting invalid or rejected destinations.

Testing and Integration:

  • Added comprehensive integration tests in integration-tests/send-email.integration.test.ts covering plain text emails, formatted content, multiple recipients, incident and security alert templates, notification settings URL, and error handling for authentication and invalid addresses.
  • Updated integration-tests/README.md to document the new test suite, required OAuth scopes, and test execution instructions. [1] [2]

Documentation and Rule Files:

  • Updated README.md with the new email:emails:send OAuth scope, example usage for sending email notifications, and clarified scope requirements. [1] [2]
  • Added changelog entries for the new email tool and OAuth scope.
  • Updated agent rules documentation to reference the new email formatting rule file and increased the rule file count to 12. [1] [2] [3]

Developer Experience:

  • Improved the .husky/pre-commit script to be more robust and cross-platform, checking for Node.js project presence before running npm commands.

Copy link
Contributor

@Copilot 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 pull request introduces comprehensive email sending functionality to the Dynatrace MCP server, enabling users to send email notifications via the Dynatrace Email API. The feature includes support for multiple recipients, formatted content, and specialized templates for incident and security alerts.

  • Added send_email tool with validation, error handling, and support for TO/CC/BCC recipients
  • Created extensive integration tests covering various email scenarios and error conditions
  • Added comprehensive documentation including email formatting reference and usage examples

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/index.ts Adds send_email tool registration with schema validation and OAuth client configuration
src/capabilities/send-email.ts Implements core email sending logic with comprehensive error handling and response formatting
integration-tests/send-email.integration.test.ts Provides extensive test coverage for email functionality including incident/security templates
integration-tests/README.md Updates documentation with new test suite details and required OAuth scopes
dynatrace-agent-rules/rules/reference/DynatraceEmailFormatting.md Adds comprehensive email formatting reference with templates and best practices
dynatrace-agent-rules/rules/README.md Updates rule count and documentation references
README.md Adds email scope and usage examples
CHANGELOG.md Documents new email feature and OAuth scope
.husky/pre-commit Improves robustness and cross-platform compatibility

Copy link
Collaborator

@christian-kreuzberger-dtx christian-kreuzberger-dtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

I like the idea, but I do see some structural weaknesses in this PR:

  • Some generated documentation is common knowledge for JS/TS Devs, we don't need it
  • The husky/pre-commit script has changed, I don't quite understand why and what you are trying to achieve with this
  • The notificationSettingsUrl parameter for the send-email tool and API endpoint is not needed for this use-case, please remove it
  • The integration-test for send-email, while having good intentions, is not ideal. I'm clarifying with our team internally on whether we can/should do that.

@theharithsa
Copy link
Contributor Author

Changes Pushed:

  1. Removed notificationSettingsUrl parameter - Cleaned up the email API interface
  2. Converted to structured responses - sendEmail now returns EmailSendResult objects instead of formatted strings
  3. Added recipient validation - 10 recipient limit with clear error messages
  4. Made test emails configurable - Prevents spam to unintended recipients
  5. Removed HTML support - Simplified to plain text only
  6. Simplified documentation - Cleaned up integration test README
  7. Restored husky pre-commit script - Back to standard format
  8. Fixed platform-specific tests - Dynamic User-Agent matching

Introduces the send_email capability for sending emails via the Dynatrace Email API, supporting multiple recipients (TO, CC, BCC), subject, body content, and notification settings URL. Adds OAuth scope documentation, a comprehensive email formatting reference, integration tests for email functionality, and updates relevant documentation and rule references.
This commit refines markdown formatting and code examples in DynatraceEmailFormatting.md, clarifies integration test documentation, and makes minor whitespace and formatting adjustments in send-email integration tests and implementation. It also condenses the Zod schema definition for the send_email capability in src/index.ts for improved readability.
…igurable tests

- Remove notificationSettingsUrl parameter from email requests
- Convert sendEmail function to return structured EmailSendResult instead of formatted string
- Add 10 recipient limit validation with clear error messages
- Make integration test email addresses configurable to prevent spam
- Remove HTML content type support, keep only plain text
- Simplify integration test documentation
- Restore husky pre-commit script to standard format
- Update email formatting reference docs to remove removed constraints
- Fix platform-specific User-Agent tests to use dynamic matchers
- Integrated all infrastructure changes from main branch
- Added Grail budget tracking with reset_grail_budget tool
- Added telemetry via Dynatrace OpenKit
- Added server.json for MCP registry
- Preserved send_email tool functionality with proper integration
- Resolved merge conflicts in CHANGELOG.md and src/index.ts
- Both send_email and reset_grail_budget tools now available
Resolves all merge conflicts and addresses PR reviewer feedback:
- Integrated latest main branch infrastructure (grail budget tracker, telemetry, server.json)
- Resolved CHANGELOG.md merge conflict with proper email tool documentation
- Resolved src/index.ts merge conflict preserving both send_email and reset_grail_budget tools
- Removed git update-index --again from .husky/pre-commit as requested by reviewer
- All tests passing, build successful
@theharithsa
Copy link
Contributor Author

Resolved the comments that were mentioned.

@christian-kreuzberger-dtx - Please review this and let me know if any changes are required.

- Integrated Davis CoPilot SDK refactor from upstream (#153)
- Fixed README.md architecture link from upstream (#155)
- Resolved CHANGELOG.md conflict preserving both email and copilot changes
- Updated package.json with new @dynatrace-sdk/client-davis-copilot dependency
- Add send_email tool for Dynatrace Email API integration
- Support multiple recipients (TO, CC, BCC) with 10 recipient limit
- Add comprehensive email formatting documentation and AI agent rules
- Update OAuth scopes documentation for email:emails:send requirement
- Add integration tests for email functionality
- Update README with email examples and usage instructions
- Maintain full compatibility with parent repository structure
- All existing functionality preserved unchanged
@theharithsa
Copy link
Contributor Author

Pushed the changes and fixed the affected index.ts file with only send_email related changes.

Copy link
Collaborator

@christian-kreuzberger-dtx christian-kreuzberger-dtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@christian-kreuzberger-dtx christian-kreuzberger-dtx merged commit 04fbe19 into dynatrace-oss:main Sep 18, 2025
4 checks passed
@theharithsa theharithsa deleted the feature/send-email branch September 18, 2025 17:24
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.

4 participants