Skip to content

AI-207: Add test coverage and improve robustness for Suggestion Engine#307

Open
KAishwarya2429 wants to merge 9 commits intoopenMF:mainfrom
KAishwarya2429:feature/add-tests
Open

AI-207: Add test coverage and improve robustness for Suggestion Engine#307
KAishwarya2429 wants to merge 9 commits intoopenMF:mainfrom
KAishwarya2429:feature/add-tests

Conversation

@KAishwarya2429
Copy link
Copy Markdown

Hi @IOhacker and reviewers,

This PR enhances the Suggestion Engine module by improving its reliability, safety, and test coverage while maintaining clean separation from the MCP layer.

✅ Key Improvements

  • Added comprehensive test coverage for:

    • Overdue loan scenarios
    • Active and pending loan states
    • Edge cases (empty inputs, invalid data types, unknown intents)
  • Improved robustness of suggestion logic:

    • Input validation for both list and dictionary data
    • Safe handling of missing or malformed fields
    • Consistent and deterministic output
  • Maintained clean architecture:

    • Suggestion engine remains external to MCP tool responses
    • Ensures MCP layer stays focused on data execution only

🧪 Test Coverage

The following scenarios are covered:

  • Valid overdue loan data
  • Active loan actions (repayment suggestions)
  • Pending/submitted loan actions (approval/rejection)
  • Empty and invalid inputs
  • Unknown intent fallback

🎯 Why this matters

This improves:

  • Reliability of suggestion generation
  • Safety against malformed inputs
  • Readiness for future integration with AI agents

All changes are additive and do not affect existing MCP tool behavior.


Please let me know if any further improvements or refinements are needed.

Thanks!

@KAishwarya2429
Copy link
Copy Markdown
Author

Hi @IOhacker and reviewers,

I have addressed all the requested changes:

  • Removed suggestion logic from MCP tools (clean separation of concerns)
  • Kept suggestion engine as external module
  • Cleaned unused references
  • Added validation and basic test coverage
  • Updated documentation accordingly

Please let me know if any further improvements are needed.
Happy to refine this further.

Thanks for your guidance!

@gyanLM10
Copy link
Copy Markdown
Contributor

Please review the comments in the earlier pr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The generate_suggestions() functionality seems more aligned with client-side orchestration or UI logic, so it would be better placed outside the MCP server repository. The MCP server’s main role is to expose raw API tools to the LLM, and adding hardcoded suggestions within tool responses mixes presentation logic with data, which can affect how the LLM interprets responses. As also mentioned in your docstring, it would be more appropriate to move this feature to a personal AI-agent repository, keeping this layer clean and focused on Fineract integration

@KAishwarya2429
Copy link
Copy Markdown
Author

Hi @IOhacker and reviewers,

I’ve implemented the suggested improvements:

  • Added structured suggestion output (suggestions_structured)
  • Implemented deduplication and max limit for safety
  • Added validation for edge cases (empty/invalid data)
  • Included comprehensive test coverage for all scenarios

All tests are passing successfully (87/87 ✅), and no existing functionality is affected.

This keeps the MCP layer clean while enabling extensible client-side intelligence.

Would love your feedback on extending this to other domains like savings and clients.

Thanks again!

@KAishwarya2429
Copy link
Copy Markdown
Author

Hi @IOhacker and reviewers,

I’ve completed the improvements based on feedback:

✅ Removed suggestion logic from MCP layer (clean separation maintained)
✅ Enhanced suggestion engine externally with structured + raw outputs
✅ Added savings domain support
✅ Implemented deduplication and max limits for safety
✅ Added comprehensive test coverage (all tests passing: 89/89)

The changes are fully backward-compatible and maintain MCP design principles.

Looking forward to your feedback!

Thanks!

@KAishwarya2429
Copy link
Copy Markdown
Author

Hi @IOhacker and reviewers,

I’ve completed the final improvements for this PR:

✅ Maintained clean separation — no suggestion logic inside MCP tools
✅ Extended suggestion engine to multiple domains:

  • Loans (overdue + details)
  • Savings accounts
  • Client details
    ✅ Added structured + raw suggestion outputs for better client integration
    ✅ Implemented validation, deduplication, and max limits
    ✅ Added comprehensive test coverage (91/91 tests passing)

The design keeps MCP as a pure execution layer while enabling extensible AI-driven suggestions externally.

Would love your feedback on this direction and any further improvements.

Thanks!

@gyanLM10
Copy link
Copy Markdown
Contributor

Hi , @KAishwarya2429 , could you please review the comments or we might have to close this pr . I asked to put the suggestion engine in a personal repo as this repo is strictly a mcp server

@KAishwarya2429
Copy link
Copy Markdown
Author

Hi @gyanLM10,

Thank you for the clarification!

I understand that this repository is intended to remain strictly focused on the MCP server. I’ll update the PR accordingly by removing the suggestion engine-related logic and keeping only the changes that align with the project scope.

I’ll move the suggestion engine into a separate repository as suggested.

Appreciate your guidance!

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.

3 participants