Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion packages/toolbox-core/src/toolbox_core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,32 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from enum import Enum
from inspect import Parameter
from typing import Any, Optional, Type, Union

from pydantic import BaseModel


class Protocol(str, Enum):
"""Defines how the client should choose between communication protocols."""

TOOLBOX = "toolbox"
MCP_v20250618 = "2025-06-18"
MCP_v20250326 = "2025-03-26"
MCP_v20241105 = "2024-11-05"
MCP_LATEST = MCP_v20250618
MCP = MCP_LATEST
Comment on lines +28 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we want both?


@classmethod
def get_supported_mcp_versions(cls):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need this for?

"""Returns a list of supported MCP versions, sorted from newest to oldest."""
versions = [member for member in cls if member.name.startswith("MCP_v")]
# Sort by the version date in descending order
versions.sort(key=lambda x: x.value, reverse=True)
return [v.value for v in versions]


__TYPE_MAP = {
"string": str,
"integer": int,
Expand Down
15 changes: 14 additions & 1 deletion packages/toolbox-core/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@

import pytest

from toolbox_core.protocol import AdditionalPropertiesSchema, ParameterSchema
from toolbox_core.protocol import AdditionalPropertiesSchema, ParameterSchema, Protocol


def test_get_supported_mcp_versions():
"""
Tests that get_supported_mcp_versions returns the correct list of versions,
sorted from newest to oldest.
"""
expected_versions = ["2025-06-18", "2025-03-26", "2024-11-05"]
supported_versions = Protocol.get_supported_mcp_versions()

assert supported_versions == expected_versions
# Also verify that the non-MCP members are not included
assert "toolbox" not in supported_versions


def test_parameter_schema_float():
Expand Down