Skip to content

Commit 2ab5472

Browse files
strip whitespace in mcp tool
1 parent 9652f62 commit 2ab5472

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

mp_api/mcp/tools.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def search(self, query: str) -> SearchOutput:
7272
7373
Args:
7474
query (str) : A natural language query of either:
75-
- comma-delimited keywords, example: "polyhedra, orthorhombic, superconductor"
75+
- comma-delimited keywords, example: "polyhedra,orthorhombic,superconductor".
76+
This should contain no whitespace; all whitespace will be removed.
7677
- chemical formula, example: "TiO2"
7778
- dash-delimited elements for more general chemical system, example: "Li-P-S"
7879
To query by formula or chemical system, no commas should be present in the query.
@@ -94,11 +95,16 @@ def search(self, query: str) -> SearchOutput:
9495
material_ids=material_ids, fields=["description", "material_id"]
9596
)
9697
else:
97-
robo_docs += self.client.materials.robocrys.search(query)
98+
robo_docs += self.client.materials.robocrys.search(
99+
query.replace(" ", "").split(",")
100+
)
98101

99102
return SearchOutput(
100103
results=[
101-
FetchResult(id=doc["material_id"], text=doc["description"])
104+
FetchResult(
105+
id=doc["material_id"],
106+
text=doc["description"],
107+
)
102108
for doc in robo_docs
103109
]
104110
)

0 commit comments

Comments
 (0)