Skip to content

feat: add workspace tools for list, get, and create operations#131

Merged
mathislucka merged 5 commits into
mainfrom
fix-issue-130
Jul 2, 2025
Merged

feat: add workspace tools for list, get, and create operations#131
mathislucka merged 5 commits into
mainfrom
fix-issue-130

Conversation

@mathislucka
Copy link
Copy Markdown
Contributor

This PR adds three new workspace tools to interact with the deepset workspace resource following the existing project patterns.

Changes Made

1. Created workspace tools (src/deepset_mcp/tools/workspace.py)

Added three new tool functions:

  • list_workspaces: Retrieves all workspaces available to the user
  • get_workspace: Fetches detailed information for a specific workspace by name
  • create_workspace: Creates a new workspace with the specified name

All tools follow the established patterns:

  • Use proper exception handling for API errors (BadRequestError, ResourceNotFoundError, UnexpectedAPIError)
  • Return structured data models or descriptive error strings
  • Include comprehensive docstrings with reStructuredText formatting
  • Use keyword-only parameters with client dependency injection

2. Registered tools in tool factory (src/deepset_mcp/tool_factory.py)

  • Imported the three workspace tool functions
  • Added all tools to TOOL_REGISTRY with MemoryType.EXPLORABLE as requested
  • Configured tools with needs_client=True since they don't require workspace parameters

3. Added comprehensive unit tests (test/unit/tools/test_workspace.py)

Created a full test suite with:

  • FakeWorkspaceResource: Mock resource implementation for testing
  • FakeClient: Test client that overrides the workspaces() method
  • Success scenarios: Tests for all three tools returning expected responses
  • Error handling: Tests for all exception types (ResourceNotFoundError, BadRequestError, UnexpectedAPIError)
  • Edge cases: Empty workspace lists, various error messages
  • Full type annotations and pytest async support

Implementation Details

The implementation leverages the existing workspace resource that was already available in the API SDK:

  • Uses src/deepset_mcp/api/workspace/resource.py
  • Imports models from src/deepset_mcp/api/workspace/models.py
  • Follows the same error handling patterns as other tools

All tools are registered with "explorable" memory type as requested, allowing their outputs to be stored and referenced by the memory system.

Testing

The test suite provides comprehensive coverage:

  • 15 test cases covering all tools and error scenarios
  • Uses fake resources following the established testing patterns
  • Tests both successful operations and error conditions
  • Validates proper error message formatting

All tests follow the project's testing guidelines and use the existing BaseFakeClient infrastructure.

Closes #130

@mathislucka mathislucka merged commit 58e8f52 into main Jul 2, 2025
3 checks passed
@mathislucka mathislucka deleted the fix-issue-130 branch July 2, 2025 08:03
mathislucka added a commit that referenced this pull request Jul 2, 2025
* feat: add workspace tools with list, get, and create functionality

* feat: import workspace tools

* feat: register workspace tools in tool registry

* feat: add comprehensive unit tests for workspace tools

* fix: types, format
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.

Add tools for workspace resource

1 participant