Skip to content

feat: Add DON ID type validation and Rev Orgs service (CUSS-396, CUSS-397)#207

Draft
mgmonteleone wants to merge 1 commit intomainfrom
feature/cuss-396-397-don-id-validation-rev-orgs
Draft

feat: Add DON ID type validation and Rev Orgs service (CUSS-396, CUSS-397)#207
mgmonteleone wants to merge 1 commit intomainfrom
feature/cuss-396-397-don-id-validation-rev-orgs

Conversation

@mgmonteleone
Copy link
Copy Markdown
Owner

Overview

This PR implements two related enhancements to improve the DevRev MCP tools and SDK:

  1. CUSS-396: DON ID type validation with helpful error messages
  2. CUSS-397: Rev Orgs (revenue organizations) service

Problem

Users were getting generic "Validation error: Bad Request" when passing the wrong type of DON ID to MCP tools (e.g., passing a rev_org ID revo/... to devrev_accounts_get which expects an account ID account/...). Additionally, there was no way to look up rev_orgs directly.

What Changed

CUSS-396: DON ID Type Validation

New file: src/devrev_mcp/utils/don_id.py

  • parse_don_type(don_id) — extracts the object type segment from a DON ID
  • validate_don_id(don_id, expected_types, tool_name) — soft-validates DON IDs with clear error messages
  • DON_TYPE_MAP — maps DON type segments to human-friendly names
  • TOOL_SUGGESTIONS — maps DON types to the correct MCP tool for helpful suggestions

Modified: 14 MCP tool files — added validate_don_id() calls to all _get, _update, _delete operations:

  • accounts.py, articles.py, conversations.py, engagements.py, groups.py, incidents.py, links.py, parts.py, question_answers.py, slas.py, tags.py, timeline.py, users.py, works.py

Example error message:

The provided ID 'don:identity:dvrv-us-1:devo/11Ca9baGrM:revo/CHjPMe8K' appears to be a rev_org ID,
but devrev_accounts_get expects an account ID. Try using devrev_rev_orgs_get instead.

CUSS-397: Rev Orgs Service

New files:

  • src/devrev/models/rev_orgs.py — Pydantic v2 models (RevOrg, RevOrgSummary, request/response models)
  • src/devrev/services/rev_orgs.py — Sync RevOrgsService and async AsyncRevOrgsService
  • src/devrev_mcp/tools/rev_orgs.py — MCP tools (list, get, create, update, delete)

Modified:

  • src/devrev/client.py — Added rev_orgs property to both clients
  • src/devrev/models/__init__.py — Exported rev_orgs models
  • src/devrev/services/__init__.py — Exported rev_orgs services
  • src/devrev_mcp/server.py — Registered rev_orgs tools

Testing

  • 22 new tests for DON ID validation (tests/unit/test_don_id_validation.py)
  • 19 new tests for Rev Orgs models and services (tests/unit/test_rev_orgs.py)
  • All 1091 tests pass — zero regressions
  • Ruff linting clean

Deployment Notes

  • No breaking changes — validation is soft (non-DON IDs pass through silently)
  • New MCP tools are automatically registered
  • Destructive rev_orgs tools (create/update/delete) are behind the enable_destructive_tools config flag

Related Issues

  • Implements: CUSS-396
  • Implements: CUSS-397

Pull Request opened by Augment Code with guidance from the PR author

CUSS-396: Add DON ID type validation with helpful error messages
- Create src/devrev_mcp/utils/don_id.py with parse_don_type and validate_don_id
- Integrate validation into all 14 MCP tool files (_get, _update, _delete ops)
- Provides clear error messages when wrong ID type is used (e.g. rev_org ID
  passed to accounts_get) with tool suggestions

CUSS-397: Add Rev Orgs (revenue organizations) service
- Create Rev Orgs Pydantic v2 models (RevOrg, RevOrgSummary, request/response)
- Implement sync RevOrgsService and async AsyncRevOrgsService
- Register services in DevRevClient and AsyncDevRevClient
- Create MCP tools: list, get, create, update, delete
- 41 new unit tests (22 for DON ID validation, 19 for Rev Orgs)
- All 1091 tests pass
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.

1 participant