Skip to content

Commit d96c8ff

Browse files
committed
refactor: remove workspace mode entirely
1 parent d42ccad commit d96c8ff

8 files changed

Lines changed: 19 additions & 67 deletions

File tree

src/deepset_mcp/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from deepset_mcp.config import DEEPSET_DOCS_DEFAULT_SHARE_URL
66
from deepset_mcp.mcp.server import configure_mcp_server
7-
from deepset_mcp.mcp.tool_models import WorkspaceMode
87
from deepset_mcp.mcp.tool_registry import ALL_DEEPSET_TOOLS
98

10-
__all__ = ["configure_mcp_server", "WorkspaceMode", "ALL_DEEPSET_TOOLS", "DEEPSET_DOCS_DEFAULT_SHARE_URL"]
9+
__all__ = ["configure_mcp_server", "ALL_DEEPSET_TOOLS", "DEEPSET_DOCS_DEFAULT_SHARE_URL"]

src/deepset_mcp/main.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from deepset_mcp.config import DEEPSET_DOCS_DEFAULT_SHARE_URL, DOCS_SEARCH_TOOL_NAME
1414
from deepset_mcp.mcp.server import configure_mcp_server
15-
from deepset_mcp.mcp.tool_models import WorkspaceMode
1615
from deepset_mcp.mcp.tool_registry import TOOL_REGISTRY
1716

1817

@@ -60,13 +59,6 @@ def main(
6059
help="Deepset docs search share URL. Can also be set via DEEPSET_DOCS_SHARE_URL environment variable.",
6160
),
6261
] = None,
63-
workspace_mode: Annotated[
64-
WorkspaceMode,
65-
typer.Option(
66-
"--workspace-mode",
67-
help="Whether workspace should be set statically or dynamically provided during a tool call.",
68-
),
69-
] = WorkspaceMode.STATIC,
7062
tools: Annotated[
7163
list[str] | None,
7264
typer.Option(
@@ -126,11 +118,10 @@ def main(
126118
The Deepset MCP server provides tools to interact with the deepset AI platform,
127119
allowing you to create, debug, and learn about pipelines on the platform.
128120
129-
:param workspace: Deepset workspace name
121+
:param workspace: Deepset workspace name. Pass if you only want to run the tools on a specific workspace.
130122
:param api_key: Deepset API key for authentication
131123
:param api_url: Deepset API base URL
132124
:param docs_share_url: Deepset docs search share URL
133-
:param workspace_mode: Whether workspace should be set statically or dynamically
134125
:param tools: List of tools to register
135126
:param list_tools: List all available tools and exit
136127
:param api_key_from_auth_header: Get API key from authorization header
@@ -171,13 +162,8 @@ def main(
171162
)
172163
raise typer.Exit(1)
173164

174-
if workspace_mode == WorkspaceMode.STATIC and not workspace:
175-
typer.echo(
176-
"Error: Workspace is required when using static workspace mode. "
177-
"Set --workspace or DEEPSET_WORKSPACE environment variable.",
178-
err=True,
179-
)
180-
raise typer.Exit(1)
165+
if not workspace:
166+
logging.info("No workspace specified. Workspace needs to be provided during tool calling.")
181167

182168
if DOCS_SEARCH_TOOL_NAME in tool_names and docs_share_url is None:
183169
typer.echo(
@@ -190,7 +176,6 @@ def main(
190176
mcp = FastMCP("deepset AI platform MCP server")
191177
configure_mcp_server(
192178
mcp_server_instance=mcp,
193-
workspace_mode=workspace_mode,
194179
deepset_api_key=api_key,
195180
deepset_api_url=api_url,
196181
deepset_workspace=workspace,

src/deepset_mcp/mcp/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
from .server import configure_mcp_server
66
from .store import initialize_or_get_initialized_store
77
from .tool_factory import build_tool
8-
from .tool_models import ToolConfig, WorkspaceMode
8+
from .tool_models import ToolConfig
99

10-
__all__ = ["configure_mcp_server", "build_tool", "ToolConfig", "WorkspaceMode", "initialize_or_get_initialized_store"]
10+
__all__ = ["configure_mcp_server", "build_tool", "ToolConfig", "initialize_or_get_initialized_store"]

src/deepset_mcp/mcp/server.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
from deepset_mcp.config import DEEPSET_DOCS_DEFAULT_SHARE_URL
1313
from deepset_mcp.mcp.store import initialize_or_get_initialized_store
1414
from deepset_mcp.mcp.tool_factory import register_tools
15-
from deepset_mcp.mcp.tool_models import DeepsetDocsConfig, WorkspaceMode
15+
from deepset_mcp.mcp.tool_models import DeepsetDocsConfig
1616
from deepset_mcp.mcp.tool_registry import TOOL_REGISTRY
1717

1818

1919
def configure_mcp_server(
2020
mcp_server_instance: FastMCP,
21-
workspace_mode: WorkspaceMode | str,
2221
tools_to_register: set[str] | None = None,
2322
deepset_api_key: str | None = None,
2423
deepset_api_url: str | None = None,
@@ -32,12 +31,11 @@ def configure_mcp_server(
3231
"""Configure the MCP server with the specified tools and settings.
3332
3433
:param mcp_server_instance: The FastMCP server instance to configure
35-
:param workspace_mode: The workspace mode ("static" or "dynamic")
3634
:param tools_to_register: Set of tool names to register with the server.
3735
Will register all tools if set to None.
3836
:param deepset_api_key: Optional Deepset API key for authentication
3937
:param deepset_api_url: Optional Deepset API base URL
40-
:param deepset_workspace: Optional workspace name for static mode
38+
:param deepset_workspace: Pass a deepset workspace name if you only want to run the tools on a specific workspace.
4139
:param deepset_docs_shareable_prototype_url: Shareable prototype URL that allows access to a docs search pipeline.
4240
Will fall back to the default shareable prototype URL if set to None.
4341
:param get_api_key_from_authorization_header: Whether to extract API key from authorization header
@@ -52,15 +50,6 @@ def configure_mcp_server(
5250
if deepset_docs_shareable_prototype_url is None:
5351
deepset_docs_shareable_prototype_url = DEEPSET_DOCS_DEFAULT_SHARE_URL
5452

55-
if isinstance(workspace_mode, str):
56-
workspace_mode = WorkspaceMode(workspace_mode)
57-
58-
if workspace_mode == WorkspaceMode.STATIC and deepset_workspace is None:
59-
raise ValueError(
60-
"Static workspace mode requires a workspace name. "
61-
"Please provide 'deepset_workspace' when using WorkspaceMode.STATIC."
62-
)
63-
6453
if deepset_api_key is None and not get_api_key_from_authorization_header:
6554
raise ValueError(
6655
"API key is required for authentication. "
@@ -79,7 +68,6 @@ def configure_mcp_server(
7968

8069
register_tools(
8170
mcp_server_instance=mcp_server_instance,
82-
workspace_mode=workspace_mode,
8371
workspace=deepset_workspace,
8472
tool_names=tools_to_register,
8573
docs_config=docs_config,

src/deepset_mcp/mcp/tool_factory.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from deepset_mcp.api.client import AsyncDeepsetClient
1616
from deepset_mcp.config import DEFAULT_CLIENT_HEADER, DOCS_SEARCH_TOOL_NAME
17-
from deepset_mcp.mcp.tool_models import DeepsetDocsConfig, MemoryType, ToolConfig, WorkspaceMode
17+
from deepset_mcp.mcp.tool_models import DeepsetDocsConfig, MemoryType, ToolConfig
1818
from deepset_mcp.mcp.tool_registry import TOOL_REGISTRY
1919
from deepset_mcp.tokonomics import (
2020
ObjectStore,
@@ -274,7 +274,6 @@ async def async_wrapper(**kwargs: Any) -> Any:
274274

275275
def register_tools(
276276
mcp_server_instance: FastMCP,
277-
workspace_mode: WorkspaceMode,
278277
api_key: str | None = None,
279278
workspace: str | None = None,
280279
tool_names: set[str] | None = None,
@@ -287,9 +286,8 @@ def register_tools(
287286
288287
Args:
289288
mcp_server_instance: FastMCP server instance
290-
workspace_mode: How workspace should be handled
291289
api_key: An api key for the deepset AI platform; only needs to be provided when not read from request context.
292-
workspace: Workspace to use; only needs to be provided if using a static workspace.
290+
workspace: Pass a deepset workspace name if you only want to run the tools on a specific workspace.
293291
tool_names: Set of tool names to register (if None, registers all tools)
294292
get_api_key_from_authorization_header: Whether to use request context to retrieve an API key for tool execution.
295293
docs_config: Configuration for the deepset documentation search tool.
@@ -302,12 +300,6 @@ def register_tools(
302300
"Either pass 'api_key' or 'use_request_context'."
303301
)
304302

305-
if workspace_mode == WorkspaceMode.STATIC and workspace is None:
306-
raise ValueError(
307-
"'workspace_mode' set to 'static' but no workspace provided. "
308-
"You need to set a deepset workspace name as 'workspace'."
309-
)
310-
311303
if docs_config is None and tool_names is None:
312304
raise ValueError(
313305
f"'docs_config' cannot be None when requesting to register all tools. "

src/deepset_mcp/mcp/tool_models.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ class ToolConfig:
4848
"""Any other arguments that should be passed to the tool at registration time instead of being passed by the LLM."""
4949

5050

51-
class WorkspaceMode(StrEnum):
52-
"""Configuration for how workspace is provided to tools."""
53-
54-
STATIC = "static" # workspace from env, no parameter in tool signature
55-
DYNAMIC = "dynamic" # workspace as required parameter in tool signature
56-
57-
5851
@dataclass
5952
class DeepsetDocsConfig:
6053
"""Configuration for deepset documentation search tool."""

test/unit/test_server_base_url.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from unittest.mock import MagicMock, patch
88

99
from deepset_mcp.mcp.server import configure_mcp_server
10-
from deepset_mcp.mcp.tool_models import WorkspaceMode
1110

1211

1312
class TestConfigureMcpServerBaseUrl:
@@ -22,7 +21,6 @@ def test_configure_mcp_server_passes_base_url(self, mock_register_tools: MagicMo
2221
configure_mcp_server(
2322
mcp_server_instance=mock_server,
2423
tools_to_register={"list_pipelines"},
25-
workspace_mode=WorkspaceMode.STATIC,
2624
deepset_api_key="test-key",
2725
deepset_api_url=custom_url,
2826
deepset_workspace="test-workspace",
@@ -41,7 +39,6 @@ def test_configure_mcp_server_without_base_url(self, mock_register_tools: MagicM
4139
configure_mcp_server(
4240
mcp_server_instance=mock_server,
4341
tools_to_register={"list_pipelines"},
44-
workspace_mode=WorkspaceMode.STATIC,
4542
deepset_api_key="test-key",
4643
deepset_workspace="test-workspace",
4744
)

test/unit/test_tool_factory.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
apply_workspace,
1919
build_tool,
2020
)
21-
from deepset_mcp.mcp.tool_models import MemoryType, ToolConfig, WorkspaceMode
21+
from deepset_mcp.mcp.tool_models import MemoryType, ToolConfig
2222
from deepset_mcp.tokonomics import InMemoryBackend, ObjectStore
2323
from test.unit.conftest import BaseFakeClient
2424

@@ -501,7 +501,7 @@ async def sample_func(a: int) -> str:
501501
return str(a)
502502

503503
config = ToolConfig()
504-
result = build_tool(sample_func, config, WorkspaceMode.STATIC)
504+
result = build_tool(sample_func, config)
505505

506506
# Should return async function
507507
assert inspect.iscoroutinefunction(result)
@@ -518,7 +518,7 @@ def sample_func(a: int) -> str:
518518
return str(a)
519519

520520
config = ToolConfig()
521-
result = build_tool(sample_func, config, WorkspaceMode.STATIC)
521+
result = build_tool(sample_func, config)
522522

523523
# Should return async function
524524
assert inspect.iscoroutinefunction(result)
@@ -549,7 +549,7 @@ async def sample_func(client: AsyncClientProtocol, workspace: str, a: int, custo
549549
custom_args={"custom_arg": "injected"},
550550
)
551551

552-
result = build_tool(sample_func, config, WorkspaceMode.STATIC, workspace="test-workspace")
552+
result = build_tool(sample_func, config, workspace="test-workspace")
553553

554554
# Check final signature
555555
sig = inspect.signature(result)
@@ -578,9 +578,7 @@ async def sample_func(client: AsyncClientProtocol, workspace: str, a: int) -> st
578578
needs_workspace=True,
579579
)
580580

581-
result = build_tool(
582-
sample_func, config, WorkspaceMode.STATIC, workspace="test-workspace", use_request_context=True
583-
)
581+
result = build_tool(sample_func, config, workspace="test-workspace", use_request_context=True)
584582

585583
# Mock the context and use FakeClient
586584
mock_ctx = MagicMock()
@@ -611,7 +609,7 @@ async def sample_func(a: int, b: str) -> str:
611609
needs_workspace=False,
612610
)
613611

614-
result = build_tool(sample_func, config, WorkspaceMode.STATIC)
612+
result = build_tool(sample_func, config)
615613

616614
# Should work without ctx
617615
output = await result(a=42, b="test")
@@ -633,7 +631,7 @@ async def sample_func(a: int) -> str:
633631
mock_explorable.return_value = mock_decorator
634632
mock_decorator.return_value = sample_func
635633

636-
build_tool(sample_func, config, WorkspaceMode.STATIC, object_store=object_store)
634+
build_tool(sample_func, config, object_store=object_store)
637635

638636
# Should have applied the decorator
639637
mock_explorable.assert_called_once()
@@ -647,7 +645,7 @@ async def sample_func(client: AsyncClientProtocol, a: int) -> str:
647645
return str(a)
648646

649647
config = ToolConfig(needs_client=True)
650-
result = build_tool(sample_func, config, WorkspaceMode.STATIC)
648+
result = build_tool(sample_func, config)
651649

652650
# Test missing context
653651
with pytest.raises(ValueError, match="Context is required"):
@@ -675,7 +673,7 @@ async def sample_func(client: AsyncClientProtocol, a: int) -> str:
675673

676674
config = ToolConfig(needs_client=True)
677675
custom_url = "https://custom.api.example.com"
678-
result = build_tool(sample_func, config, WorkspaceMode.STATIC, base_url=custom_url)
676+
result = build_tool(sample_func, config, base_url=custom_url)
679677

680678
# Mock the context
681679
mock_ctx = MagicMock()

0 commit comments

Comments
 (0)