Skip to content

Commit 1f5db7a

Browse files
authored
feat: explorer should return full length string (#125)
1 parent 8576442 commit 1f5db7a

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

src/deepset_mcp/tools/tokonomics/explorer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ def explore(self, obj_id: str, path: str = "") -> str:
6565

6666
# Generate header and body
6767
header = self._make_header(obj_id, path, obj)
68-
body = self._get_pretty_repr(obj)
68+
69+
# We want the full length str if the (nested) object is a string
70+
if isinstance(obj, str):
71+
body = obj
72+
else:
73+
body = self._get_pretty_repr(obj)
6974

7075
return f"{header}\n\n{body}"
7176

test/unit/tools/tokonomics/test_explorer.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,36 @@ def test_max_search_matches(self, store: ObjectStore) -> None:
412412
assert "Match 2:" in result
413413
assert "Match 3:" not in result # Should be limited
414414
assert "and 2 more matches" in result
415+
416+
def test_explore_string_returns_full_string(self, store: ObjectStore, explorer: RichExplorer) -> None:
417+
"""Test that exploring a string object returns the full string without pretty formatting."""
418+
test_string = "This is a test string with special characters: \n\t quotes 'single' and double"
419+
obj_id = store.put(test_string)
420+
421+
result = explorer.explore(obj_id)
422+
423+
# Should contain the header
424+
assert f"@{obj_id} → str" in result
425+
# Should contain the full original string without quotes or escaping
426+
assert test_string in result
427+
# The body should be exactly the string (after the header)
428+
lines = result.split("\n\n", 1)
429+
body = lines[1] if len(lines) > 1 else ""
430+
assert body == test_string
431+
432+
def test_explore_nested_string_returns_full_string(self, store: ObjectStore, explorer: RichExplorer) -> None:
433+
"""Test that exploring a nested string object returns the full string without pretty formatting."""
434+
test_string = "Nested string with newlines\nand tabs\tand quotes 'test'"
435+
test_data = {"content": test_string}
436+
obj_id = store.put(test_data)
437+
438+
result = explorer.explore(obj_id, "content")
439+
440+
# Should contain the header for the nested path
441+
assert f"@{obj_id}.content → str" in result
442+
# Should contain the full original string
443+
assert test_string in result
444+
# Should not be wrapped in quotes like Rich Pretty would do
445+
lines = result.split("\n\n", 1)
446+
body = lines[1] if len(lines) > 1 else ""
447+
assert body == test_string

0 commit comments

Comments
 (0)