-
Notifications
You must be signed in to change notification settings - Fork 129
feat(mcp): support task management capabilities in MCP client wrappers #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit adds a comprehensive task management system to the MCP client wrappers, enabling asynchronous handling of long-running operations. Key changes include: - Implementation of `TaskManager` interface for managing tasks, including methods for retrieving task status, results, listing tasks, and cancelling tasks. - Introduction of `DefaultTaskManager` as the default implementation, which caches task statuses and notifies listeners of status changes. - New classes for task representation (`Task`, `ListTasksResult`, `TaskParameters`, and `TaskStatus`) to encapsulate task data and status. - Updates to `McpAsyncClientWrapper` and `McpSyncClientWrapper` to integrate task management functionality. - Comprehensive unit tests for the new task management features to ensure reliability and correctness. These enhancements improve the MCP client’s ability to manage and monitor tasks effectively, supporting more complex workflows in agent applications.
There was a problem hiding this 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 adds comprehensive task management capabilities to the MCP client wrappers, enabling asynchronous handling of long-running operations through the Model Context Protocol. The implementation introduces a complete task management framework including domain models, interfaces, and integration with both synchronous and asynchronous client wrappers. The MCP SDK dependency is also upgraded from version 0.14.1 to 0.17.0 to support these features.
Key changes:
- Introduction of task management domain model classes (Task, TaskStatus, TaskParameters, ListTasksResult) with comprehensive builder patterns and validation
- Implementation of TaskManager interface and DefaultTaskManager with caching, listener notification, and reactive programming support
- Integration of task management into McpAsyncClientWrapper and McpSyncClientWrapper with placeholder implementations for future SDK support
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| agentscope-dependencies-bom/pom.xml | Updates MCP SDK dependency from version 0.14.1 to 0.17.0 |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/TaskStatus.java | Adds enum for task execution states with terminal state detection |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/TaskParameters.java | Adds parameters class for task creation with TTL configuration |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/Task.java | Adds task domain model with builder pattern and comprehensive metadata |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/ListTasksResult.java | Adds pagination result wrapper for task listing operations |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/TaskManager.java | Defines interface for task lifecycle management operations |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/DefaultTaskManager.java | Implements task manager with caching, listener notification, and type conversion |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpClientWrapper.java | Adds abstract getTaskManager() method to base wrapper class |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpAsyncClientWrapper.java | Integrates task manager with placeholder implementation for async client |
| agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpSyncClientWrapper.java | Integrates task manager with placeholder implementation for sync client |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/McpClientWrapperTest.java | Updates test wrapper to implement new getTaskManager() method |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/task/TaskTest.java | Adds comprehensive unit tests for Task class |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/task/TaskStatusTest.java | Adds comprehensive unit tests for TaskStatus enum |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/task/TaskParametersTest.java | Adds comprehensive unit tests for TaskParameters class |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/task/ListTasksResultTest.java | Adds comprehensive unit tests for ListTasksResult class |
| agentscope-core/src/test/java/io/agentscope/core/tool/mcp/task/DefaultTaskManagerTest.java | Adds comprehensive unit tests for DefaultTaskManager implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpAsyncClientWrapper.java
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/mcp/task/ListTasksResult.java
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpSyncClientWrapper.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ure ListTasksResult returns unmodifiable task lists.
…ntWrapper, verifying instance retrieval and unsupported task operations.
|
The official Java SDK does not yet support task. We'll add support for it after the new version is released. |
AgentScope-Java Version
[The version of AgentScope-Java you are working on, e.g. 1.0.2, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]Description
This commit adds a comprehensive task management system to the MCP client wrappers, enabling asynchronous handling of long-running operations. Key changes include:
TaskManagerinterface for managing tasks, including methods for retrieving task status, results, listing tasks, and cancelling tasks.DefaultTaskManageras the default implementation, which caches task statuses and notifies listeners of status changes.Task,ListTasksResult,TaskParameters, andTaskStatus) to encapsulate task data and status.McpAsyncClientWrapperandMcpSyncClientWrapperto integrate task management functionality.These enhancements improve the MCP client’s ability to manage and monitor tasks effectively, supporting more complex workflows in agent applications.
fixes #217
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)