Skip to content

Commit 3691ec9

Browse files
committed
Revert "feat: add redis backend"
This reverts commit 3dd8e47.
1 parent 3dd8e47 commit 3691ec9

12 files changed

Lines changed: 751 additions & 567 deletions

src/deepset_mcp/implementation_plan.md

Lines changed: 516 additions & 0 deletions
Large diffs are not rendered by default.

src/deepset_mcp/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def main(
155155
# ObjectStore configuration
156156
backend = object_store_backend or os.getenv("DEEPSET_OBJECT_STORE_BACKEND", "memory")
157157
redis_url = redis_url or os.getenv("DEEPSET_REDIS_URL")
158-
ttl = int(os.getenv("DEEPSET_OBJECT_STORE_TTL", str(object_store_ttl)))
158+
ttl = float(os.getenv("DEEPSET_OBJECT_STORE_TTL", str(object_store_ttl)))
159159

160160
if tools:
161161
tool_names = set(tools)

src/deepset_mcp/tool_factory.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import functools
88
import inspect
9+
import os
910
import re
1011
from collections.abc import Awaitable, Callable
1112
from typing import Any
@@ -25,6 +26,23 @@
2526
)
2627

2728

29+
def are_docs_available() -> bool:
30+
"""Checks if documentation search is available."""
31+
return bool(
32+
os.environ.get("DEEPSET_DOCS_WORKSPACE", False)
33+
and os.environ.get("DEEPSET_DOCS_PIPELINE_NAME", False)
34+
and os.environ.get("DEEPSET_DOCS_API_KEY", False)
35+
)
36+
37+
38+
def get_workspace_from_env() -> str:
39+
"""Gets the workspace configured from environment variable."""
40+
workspace = os.environ.get("DEEPSET_WORKSPACE")
41+
if not workspace:
42+
raise ValueError("DEEPSET_WORKSPACE environment variable not set")
43+
return workspace
44+
45+
2846
def apply_custom_args(base_func: Callable[..., Any], config: ToolConfig) -> Callable[..., Any]:
2947
"""
3048
Applies custom keyword arguments defined in the ToolConfig to a function.
@@ -99,7 +117,8 @@ def apply_workspace(
99117

100118
@functools.wraps(base_func)
101119
async def workspace_wrapper(*args: Any, **kwargs: Any) -> Any:
102-
return await base_func(*args, workspace=workspace, **kwargs)
120+
ws = workspace or get_workspace_from_env()
121+
return await base_func(*args, workspace=ws, **kwargs)
103122

104123
# Remove workspace from signature
105124
original_sig = inspect.signature(base_func)
@@ -146,11 +165,7 @@ def apply_memory(
146165

147166

148167
def apply_client(
149-
base_func: Callable[..., Any],
150-
config: ToolConfig,
151-
use_request_context: bool = True,
152-
base_url: str | None = None,
153-
api_key: str | None = None,
168+
base_func: Callable[..., Any], config: ToolConfig, use_request_context: bool = True, base_url: str | None = None
154169
) -> Callable[..., Any]:
155170
"""
156171
Applies the deepset API client to a function.
@@ -163,7 +178,6 @@ def apply_client(
163178
:param config: The ToolConfig for the function.
164179
:param use_request_context: Whether to collect the API key from the request context.
165180
:param base_url: Base URL for the deepset API.
166-
:param api_key: The API key to use.
167181
:returns: Function with client injection applied and updated signature/docstring.
168182
:raises ValueError: If API key cannot be extracted from request context.
169183
"""
@@ -199,14 +213,26 @@ async def client_wrapper_with_context(*args: Any, **kwargs: Any) -> Any:
199213
ctx_param = inspect.Parameter(name="ctx", kind=inspect.Parameter.KEYWORD_ONLY, annotation=Context)
200214
new_params.append(ctx_param)
201215
client_wrapper_with_context.__signature__ = original_sig.replace(parameters=new_params) # type: ignore
202-
client_wrapper_with_context.__doc__ = remove_params_from_docstring(base_func.__doc__, {"client"})
216+
217+
# Remove client from docstring
218+
if base_func.__doc__:
219+
import re
220+
221+
doc = base_func.__doc__
222+
doc = re.sub(
223+
r"^\s*:param\s+client.*?(?=^\s*:|^\s*$|\Z)",
224+
"",
225+
doc,
226+
flags=re.MULTILINE | re.DOTALL,
227+
)
228+
client_wrapper_with_context.__doc__ = "\n".join([line.rstrip() for line in doc.strip().split("\n")])
203229

204230
return client_wrapper_with_context
205231
else:
206232

207233
@functools.wraps(base_func)
208234
async def client_wrapper_without_context(*args: Any, **kwargs: Any) -> Any:
209-
client_kwargs: dict[str, Any] = {"transport_config": DEFAULT_CLIENT_HEADER, "api_key": api_key}
235+
client_kwargs: dict[str, Any] = {"transport_config": DEFAULT_CLIENT_HEADER}
210236
if base_url:
211237
client_kwargs["base_url"] = base_url
212238
async with AsyncDeepsetClient(**client_kwargs) as client:

src/deepset_mcp/tools/tokonomics/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@
6060

6161
from .decorators import explorable, explorable_and_referenceable, referenceable
6262
from .explorer import RichExplorer
63-
from .object_store import Explorable, InMemoryBackend, ObjectRef, ObjectStore
63+
from .object_store import Explorable, ObjectRef, ObjectStore
6464

6565
__all__ = [
6666
# Core classes
6767
"Explorable",
68-
"InMemoryBackend",
6968
"ObjectRef",
7069
"ObjectStore",
7170
"RichExplorer",

src/deepset_mcp/tools/tokonomics/object_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def __init__(self, redis_url: str) -> None:
154154
"Redis package not installed. Install with: pip install deepset-mcp[redis] to use the RedisBackend."
155155
) from e
156156

157-
self._client = redis.from_url(redis_url, decode_responses=False) # type: ignore[no-untyped-call]
157+
self._client = redis.from_url(redis_url, decode_responses=False)
158158
# Test connection immediately
159159
self._client.ping()
160160

@@ -172,7 +172,7 @@ def set(self, key: str, value: bytes, ttl_seconds: int | None) -> None:
172172

173173
def get(self, key: str) -> bytes | None:
174174
"""Get a value at key."""
175-
return self._client.get(key) # type: ignore[no-any-return]
175+
return self._client.get(key)
176176

177177
def delete(self, key: str) -> bool:
178178
"""Delete a value at key."""

test/unit/test_store.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)