Skip to content

Commit de5e448

Browse files
committed
docs: enhance protocol tool descriptions for clarity
1 parent c84cf88 commit de5e448

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

src/protocols_io_mcp/tools/protocol.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ async def search_public_protocols(
157157
keyword: Annotated[str, Field(description="Keyword to search for protocols")],
158158
page: Annotated[int, Field(description="Page number for pagination, starting from 1")] = 1,
159159
) -> ProtocolSearchResult | ErrorMessage:
160-
"""Search for public protocols on protocols.io using a keyword."""
160+
"""
161+
Search for public protocols on protocols.io using a keyword. Results are sorted by protocol popularity and paginated with 3 protocols per page (use the page parameter to navigate, default is 1).
162+
163+
When searching for reference protocols to create a new protocol:
164+
- Avoid referencing protocols from before 2015 as they may be outdated.
165+
- If the found protocols have topics that are not closely related to your needs, ask the user for clearer direction before proceeding.
166+
- If the found protocols are highly relevant, use get_protocol_steps to examine at least 2 protocols' detailed steps and integrate insights from different approaches to ensure more reliable protocol development.
167+
"""
161168
page = page - 1 # weird bug in protocols.io API where it returns page 2 if page 1 is requested
162169
response = await helpers.access_protocols_io_resource("GET", f"/v3/protocols?filter=public&key={keyword}&page_size=3&page_id={page}")
163170
if response["status_code"] != 0:
@@ -167,7 +174,9 @@ async def search_public_protocols(
167174

168175
@mcp.tool()
169176
async def get_my_protocols() -> list[Protocol] | ErrorMessage:
170-
"""Retrieve all protocols owned by the current user."""
177+
"""
178+
Retrieve basic information for all protocols belonging to the current user. To get detailed protocol steps, use get_protocol_steps.
179+
"""
171180
response_profile = await helpers.access_protocols_io_resource("GET", f"/v3/session/profile", {})
172181
if response_profile["status_code"] != 0:
173182
return ErrorMessage.from_string(response_profile["error_message"])
@@ -182,7 +191,9 @@ async def get_my_protocols() -> list[Protocol] | ErrorMessage:
182191
async def get_protocol(
183192
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")]
184193
) -> Protocol | ErrorMessage:
185-
"""Retrieve a specific protocol by its ID."""
194+
"""
195+
Retrieve basic information for a specific protocol by its protocol ID. To get detailed protocol steps, use get_protocol_steps.
196+
"""
186197
response = await helpers.access_protocols_io_resource("GET", f"/v4/protocols/{protocol_id}")
187198
if response["status_code"] != 0:
188199
return ErrorMessage.from_string(response["status_text"])
@@ -193,7 +204,9 @@ async def get_protocol(
193204
async def get_protocol_steps(
194205
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")]
195206
) -> list[ProtocolStep] | ErrorMessage:
196-
"""Retrieve all steps of a specific protocol by its ID."""
207+
"""
208+
Retrieve the steps for a specific protocol by its protocol ID.
209+
"""
197210
response = await helpers.access_protocols_io_resource("GET", f"/v4/protocols/{protocol_id}/steps?content_format=markdown")
198211
if response["status_code"] != 0:
199212
return ErrorMessage.from_string(response["status_text"])
@@ -205,7 +218,11 @@ async def create_protocol(
205218
title: Annotated[str, Field(description="Title of the new protocol")],
206219
description: Annotated[str, Field(description="Description of the new protocol")],
207220
) -> Protocol | ErrorMessage:
208-
"""Create a new protocol with the given title and description."""
221+
"""
222+
Create a new protocol with the given title and description.
223+
224+
Before creating a new protocol, ensure you have searched for at least 2 relevant public protocols using search_public_protocols and reviewed their detailed steps with get_protocol_steps for reference when adding steps.
225+
"""
209226
response_create_blank_protocol = await helpers.access_protocols_io_resource("POST", f"/v3/protocols/{uuid.uuid4().hex}", {"type_id": 1})
210227
if response_create_blank_protocol["status_code"] != 0:
211228
return ErrorMessage.from_string(response_create_blank_protocol["status_text"])
@@ -225,7 +242,9 @@ async def update_protocol_title(
225242
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
226243
title: Annotated[str, Field(description="New title for the protocol")]
227244
) -> Protocol | ErrorMessage:
228-
"""Update the title of an existing protocol."""
245+
"""
246+
Update the title of an existing protocol by its protocol ID.
247+
"""
229248
data = {"title": title}
230249
response_update_protocol = await helpers.access_protocols_io_resource("PUT", f"/v4/protocols/{protocol_id}", data)
231250
if response_update_protocol["status_code"] != 0:
@@ -241,7 +260,9 @@ async def update_protocol_description(
241260
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
242261
description: Annotated[str, Field(description="New description for the protocol")]
243262
) -> Protocol | ErrorMessage:
244-
"""Update the description of an existing protocol."""
263+
"""
264+
Update the description of an existing protocol by its protocol ID.
265+
"""
245266
data = {"description": description}
246267
response_update_protocol = await helpers.access_protocols_io_resource("PUT", f"/v4/protocols/{protocol_id}", data)
247268
if response_update_protocol["status_code"] != 0:
@@ -257,7 +278,9 @@ async def set_protocol_steps(
257278
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
258279
steps: Annotated[list[ProtocolStepInput], Field(description="List of steps to set for the protocol")]
259280
) -> list[ProtocolStep] | ErrorMessage:
260-
"""Set the steps for a protocol."""
281+
"""
282+
Replace the entire steps list of a specific protocol by its protocol ID with a new steps list. The existing steps will be completely overwritten.
283+
"""
261284
if not steps:
262285
return ErrorMessage.from_string("At least one step is required to set the protocol steps.")
263286
# get all existing steps
@@ -296,7 +319,9 @@ async def add_protocol_step(
296319
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
297320
step: Annotated[ProtocolStepInput, Field(description="Step to be added to the protocol")]
298321
) -> list[ProtocolStep] | ErrorMessage:
299-
"""Add a new step to a protocol."""
322+
"""
323+
Add a step to the end of the steps list for a specific protocol by its protocol ID.
324+
"""
300325
# get all existing steps
301326
response_get_steps = await helpers.access_protocols_io_resource("GET", f"/v4/protocols/{protocol_id}/steps?content_format=markdown")
302327
if response_get_steps["status_code"] != 0:
@@ -326,7 +351,9 @@ async def delete_protocol_step(
326351
protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
327352
step_id: Annotated[str, Field(description="Unique identifier for the step to be deleted")]
328353
) -> list[ProtocolStep] | ErrorMessage:
329-
"""Delete a specific step from a protocol."""
354+
"""
355+
Delete a specific step from a protocol by providing both the protocol ID and step ID.
356+
"""
330357
response_delete_protocol_step = await helpers.access_protocols_io_resource("DELETE", f"/v4/protocols/{protocol_id}/steps", {"steps": [step_id]})
331358
if response_delete_protocol_step["status_code"] != 0:
332359
return ErrorMessage.from_string(response_delete_protocol_step["status_text"])

0 commit comments

Comments
 (0)