Skip to main content
Glama
hqn21

protocols-io-mcp-server

update_protocol_title

Modify the title of an existing protocol on protocols.io by specifying its unique ID and providing a new plain text title.

Instructions

Update the title of an existing protocol by its protocol ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protocol_idYesUnique identifier for the protocol
titleYesNew title for the protocol (plain text only)

Implementation Reference

  • The core handler function for the 'update_protocol_title' tool, decorated with @mcp.tool() for registration. It performs a PUT request to update the protocol title and fetches the updated protocol.
    @mcp.tool()
    async def update_protocol_title(
        protocol_id: Annotated[int, Field(description="Unique identifier for the protocol")],
        title: Annotated[str, Field(description="New title for the protocol (plain text only)")]
    ) -> Protocol | ErrorMessage:
        """
        Update the title of an existing protocol by its protocol ID.
        """
        data = {"title": title}
        response_update_protocol = await helpers.access_protocols_io_resource("PUT", f"/v4/protocols/{protocol_id}", data)
        if response_update_protocol["status_code"] != 0:
            return ErrorMessage.from_string(response_update_protocol["status_text"])
        response_get_protocol = await helpers.access_protocols_io_resource("GET", f"/v4/protocols/{protocol_id}")
        if response_get_protocol["status_code"] != 0:
            return ErrorMessage.from_string(response_get_protocol["status_text"])
        protocol = await Protocol.from_protocol_id(response_get_protocol["payload"]["id"])
        return protocol
  • Imports the tools module, which triggers the loading and registration of all MCP tools via their @mcp.tool() decorators.
    importlib.import_module('protocols_io_mcp.tools')
  • Helper class method Protocol.from_protocol_id used by the tool to construct the Protocol object from API response.
    async def from_protocol_id(cls, protocol_id: int) -> "Protocol":
        response = await helpers.access_protocols_io_resource("GET", f"/v4/protocols/{protocol_id}?content_format=markdown")
        protocol = response["payload"]
        return cls(
            id=protocol_id,
            title=protocol["title"],
            description=protocol.get("description") or "",
            doi=protocol.get("doi") or None,
            url=protocol.get("url"),
            created_on=datetime.fromtimestamp(protocol.get("created_on"), tz=timezone.utc),
            published_on=datetime.fromtimestamp(protocol.get("published_on"), tz=timezone.utc) if protocol.get("published_on") else None
        )
  • Utility function to make authenticated API requests to protocols.io, heavily used in the tool implementation.
    async def access_protocols_io_resource(method: Literal["GET", "POST", "PUT", "DELETE"], path: str, data: dict = None) -> dict[str, Any]:
        """Access protocols.io API with specified method and path."""
        headers = {
            "Authorization": f"Bearer {PROTOCOLS_IO_CLIENT_ACCESS_TOKEN}"
        }
        async with httpx.AsyncClient(timeout=30.0) as client:
            response = await client.request(method, f"{PROTOCOLS_IO_API_URL}{path}", json=data, headers=headers)
            return response.json()
  • Pydantic model for error output from the tool.
    class ErrorMessage(BaseModel):
        error_message: Annotated[str, Field(description="Error message describing the issue encountered")]
    
        @classmethod
        def from_string(cls, message: str) -> "ErrorMessage":
            return cls(error_message=message)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hqn21/protocols-io-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server