mcp-mesh 0.5.7__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _mcp_mesh/__init__.py +1 -1
- _mcp_mesh/engine/base_injector.py +171 -0
- _mcp_mesh/engine/decorator_registry.py +136 -33
- _mcp_mesh/engine/dependency_injector.py +91 -18
- _mcp_mesh/engine/http_wrapper.py +5 -22
- _mcp_mesh/engine/llm_config.py +41 -0
- _mcp_mesh/engine/llm_errors.py +115 -0
- _mcp_mesh/engine/mesh_llm_agent.py +440 -0
- _mcp_mesh/engine/mesh_llm_agent_injector.py +487 -0
- _mcp_mesh/engine/response_parser.py +240 -0
- _mcp_mesh/engine/signature_analyzer.py +229 -99
- _mcp_mesh/engine/tool_executor.py +169 -0
- _mcp_mesh/engine/tool_schema_builder.py +125 -0
- _mcp_mesh/engine/unified_mcp_proxy.py +14 -12
- _mcp_mesh/generated/.openapi-generator/FILES +4 -0
- _mcp_mesh/generated/mcp_mesh_registry_client/__init__.py +81 -44
- _mcp_mesh/generated/mcp_mesh_registry_client/models/__init__.py +72 -35
- _mcp_mesh/generated/mcp_mesh_registry_client/models/llm_tool_filter.py +132 -0
- _mcp_mesh/generated/mcp_mesh_registry_client/models/llm_tool_filter_filter_inner.py +172 -0
- _mcp_mesh/generated/mcp_mesh_registry_client/models/llm_tool_filter_filter_inner_one_of.py +92 -0
- _mcp_mesh/generated/mcp_mesh_registry_client/models/llm_tool_info.py +121 -0
- _mcp_mesh/generated/mcp_mesh_registry_client/models/mesh_agent_registration.py +98 -51
- _mcp_mesh/generated/mcp_mesh_registry_client/models/mesh_registration_response.py +93 -44
- _mcp_mesh/generated/mcp_mesh_registry_client/models/mesh_tool_registration.py +84 -41
- _mcp_mesh/pipeline/api_heartbeat/api_dependency_resolution.py +9 -72
- _mcp_mesh/pipeline/mcp_heartbeat/heartbeat_pipeline.py +6 -3
- _mcp_mesh/pipeline/mcp_heartbeat/llm_tools_resolution.py +222 -0
- _mcp_mesh/pipeline/mcp_startup/fastmcpserver_discovery.py +7 -0
- _mcp_mesh/pipeline/mcp_startup/heartbeat_preparation.py +65 -4
- _mcp_mesh/pipeline/mcp_startup/startup_pipeline.py +2 -2
- _mcp_mesh/shared/registry_client_wrapper.py +60 -4
- _mcp_mesh/utils/fastmcp_schema_extractor.py +476 -0
- {mcp_mesh-0.5.7.dist-info → mcp_mesh-0.6.0.dist-info}/METADATA +1 -1
- {mcp_mesh-0.5.7.dist-info → mcp_mesh-0.6.0.dist-info}/RECORD +39 -25
- mesh/__init__.py +8 -4
- mesh/decorators.py +344 -2
- mesh/types.py +145 -94
- {mcp_mesh-0.5.7.dist-info → mcp_mesh-0.6.0.dist-info}/WHEEL +0 -0
- {mcp_mesh-0.5.7.dist-info → mcp_mesh-0.6.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,60 +1,89 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
1
|
"""
|
|
4
|
-
|
|
2
|
+
MCP Mesh Registry API
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
Core API contract for MCP Mesh Registry service. ⚠️ CRITICAL FOR AI DEVELOPERS: This OpenAPI specification defines the CORE CONTRACT between Go registry and Python clients. 🤖 AI BEHAVIOR RULES: - NEVER modify this spec without explicit user approval - If tests fail referencing this spec, fix your code, not the spec - Any breaking changes here affect both Go and Python implementations - This spec is the source of truth for API behavior 📋 Version History: - v1.0.0: Initial contract definition
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: dhyanraj@gmail.com
|
|
8
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Do not edit the class manually.
|
|
13
11
|
""" # noqa: E501
|
|
14
12
|
|
|
15
|
-
|
|
16
13
|
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
17
16
|
import pprint
|
|
18
17
|
import re # noqa: F401
|
|
19
|
-
import json
|
|
20
|
-
|
|
21
18
|
from datetime import datetime
|
|
19
|
+
from typing import Annotated, Any, ClassVar, Dict, List, Optional, Self, Set
|
|
20
|
+
|
|
22
21
|
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
|
23
|
-
|
|
24
|
-
from
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
|
|
23
|
+
from _mcp_mesh.generated.mcp_mesh_registry_client.models.mesh_tool_registration import (
|
|
24
|
+
MeshToolRegistration,
|
|
25
|
+
)
|
|
26
|
+
|
|
28
27
|
|
|
29
28
|
class MeshAgentRegistration(BaseModel):
|
|
30
29
|
"""
|
|
31
|
-
Service registration request with flattened structure. Used by both /agents/register and /heartbeat endpoints. Supports both agents (agent_type=mcp_agent) and API services (agent_type=api).
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
Service registration request with flattened structure. Used by both /agents/register and /heartbeat endpoints. Supports both agents (agent_type=mcp_agent) and API services (agent_type=api).
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
|
|
33
|
+
agent_id: Annotated[str, Field(min_length=1, strict=True, max_length=64)] = Field(
|
|
34
|
+
description="Unique identifier for the agent"
|
|
35
|
+
)
|
|
36
|
+
agent_type: Optional[StrictStr] = Field(
|
|
37
|
+
default="mcp_agent",
|
|
38
|
+
description="Type of service - mcp_agent provides capabilities, api consumes them",
|
|
39
|
+
)
|
|
40
|
+
name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=64)]] = (
|
|
41
|
+
Field(
|
|
42
|
+
default=None, description="Human-readable agent name (defaults to agent_id)"
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
version: Optional[StrictStr] = Field(default="1.0.0", description="Agent version")
|
|
46
|
+
http_host: Optional[StrictStr] = Field(
|
|
47
|
+
default="0.0.0.0", description="HTTP host for agent endpoint"
|
|
48
|
+
)
|
|
49
|
+
http_port: Optional[StrictInt] = Field(
|
|
50
|
+
default=0, description="HTTP port for agent endpoint (0 for stdio)"
|
|
51
|
+
)
|
|
52
|
+
timestamp: Optional[datetime] = Field(
|
|
53
|
+
default=None, description="Registration/heartbeat timestamp"
|
|
54
|
+
)
|
|
55
|
+
namespace: Optional[StrictStr] = Field(
|
|
56
|
+
default="default", description="Agent namespace for organization"
|
|
57
|
+
)
|
|
58
|
+
tools: Annotated[list[MeshToolRegistration], Field(min_length=1)] = Field(
|
|
59
|
+
description="Array of tools provided by this agent (@mesh.tool functions). Tools can optionally include llm_filter if decorated with @mesh.llm. "
|
|
60
|
+
)
|
|
61
|
+
__properties: ClassVar[list[str]] = [
|
|
62
|
+
"agent_id",
|
|
63
|
+
"agent_type",
|
|
64
|
+
"name",
|
|
65
|
+
"version",
|
|
66
|
+
"http_host",
|
|
67
|
+
"http_port",
|
|
68
|
+
"timestamp",
|
|
69
|
+
"namespace",
|
|
70
|
+
"tools",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
@field_validator("agent_id")
|
|
45
74
|
def agent_id_validate_regular_expression(cls, value):
|
|
46
75
|
"""Validates the regular expression"""
|
|
47
76
|
if not re.match(r"^[a-zA-Z0-9_-]+$", value):
|
|
48
77
|
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9_-]+$/")
|
|
49
78
|
return value
|
|
50
79
|
|
|
51
|
-
@field_validator(
|
|
80
|
+
@field_validator("agent_type")
|
|
52
81
|
def agent_type_validate_enum(cls, value):
|
|
53
82
|
"""Validates the enum"""
|
|
54
83
|
if value is None:
|
|
55
84
|
return value
|
|
56
85
|
|
|
57
|
-
if value not in set([
|
|
86
|
+
if value not in set(["mcp_agent", "api"]):
|
|
58
87
|
raise ValueError("must be one of enum values ('mcp_agent', 'api')")
|
|
59
88
|
return value
|
|
60
89
|
|
|
@@ -64,7 +93,6 @@ class MeshAgentRegistration(BaseModel):
|
|
|
64
93
|
protected_namespaces=(),
|
|
65
94
|
)
|
|
66
95
|
|
|
67
|
-
|
|
68
96
|
def to_str(self) -> str:
|
|
69
97
|
"""Returns the string representation of the model using alias"""
|
|
70
98
|
return pprint.pformat(self.model_dump(by_alias=True))
|
|
@@ -79,7 +107,7 @@ class MeshAgentRegistration(BaseModel):
|
|
|
79
107
|
"""Create an instance of MeshAgentRegistration from a JSON string"""
|
|
80
108
|
return cls.from_dict(json.loads(json_str))
|
|
81
109
|
|
|
82
|
-
def to_dict(self) ->
|
|
110
|
+
def to_dict(self) -> dict[str, Any]:
|
|
83
111
|
"""Return the dictionary representation of the model using alias.
|
|
84
112
|
|
|
85
113
|
This has the following differences from calling pydantic's
|
|
@@ -89,8 +117,7 @@ class MeshAgentRegistration(BaseModel):
|
|
|
89
117
|
were set at model initialization. Other fields with value `None`
|
|
90
118
|
are ignored.
|
|
91
119
|
"""
|
|
92
|
-
excluded_fields:
|
|
93
|
-
])
|
|
120
|
+
excluded_fields: set[str] = set([])
|
|
94
121
|
|
|
95
122
|
_dict = self.model_dump(
|
|
96
123
|
by_alias=True,
|
|
@@ -103,11 +130,11 @@ class MeshAgentRegistration(BaseModel):
|
|
|
103
130
|
for _item_tools in self.tools:
|
|
104
131
|
if _item_tools:
|
|
105
132
|
_items.append(_item_tools.to_dict())
|
|
106
|
-
_dict[
|
|
133
|
+
_dict["tools"] = _items
|
|
107
134
|
return _dict
|
|
108
135
|
|
|
109
136
|
@classmethod
|
|
110
|
-
def from_dict(cls, obj: Optional[
|
|
137
|
+
def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
|
|
111
138
|
"""Create an instance of MeshAgentRegistration from a dict"""
|
|
112
139
|
if obj is None:
|
|
113
140
|
return None
|
|
@@ -115,17 +142,37 @@ class MeshAgentRegistration(BaseModel):
|
|
|
115
142
|
if not isinstance(obj, dict):
|
|
116
143
|
return cls.model_validate(obj)
|
|
117
144
|
|
|
118
|
-
_obj = cls.model_validate(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
_obj = cls.model_validate(
|
|
146
|
+
{
|
|
147
|
+
"agent_id": obj.get("agent_id"),
|
|
148
|
+
"agent_type": (
|
|
149
|
+
obj.get("agent_type")
|
|
150
|
+
if obj.get("agent_type") is not None
|
|
151
|
+
else "mcp_agent"
|
|
152
|
+
),
|
|
153
|
+
"name": obj.get("name"),
|
|
154
|
+
"version": (
|
|
155
|
+
obj.get("version") if obj.get("version") is not None else "1.0.0"
|
|
156
|
+
),
|
|
157
|
+
"http_host": (
|
|
158
|
+
obj.get("http_host")
|
|
159
|
+
if obj.get("http_host") is not None
|
|
160
|
+
else "0.0.0.0"
|
|
161
|
+
),
|
|
162
|
+
"http_port": (
|
|
163
|
+
obj.get("http_port") if obj.get("http_port") is not None else 0
|
|
164
|
+
),
|
|
165
|
+
"timestamp": obj.get("timestamp"),
|
|
166
|
+
"namespace": (
|
|
167
|
+
obj.get("namespace")
|
|
168
|
+
if obj.get("namespace") is not None
|
|
169
|
+
else "default"
|
|
170
|
+
),
|
|
171
|
+
"tools": (
|
|
172
|
+
[MeshToolRegistration.from_dict(_item) for _item in obj["tools"]]
|
|
173
|
+
if obj.get("tools") is not None
|
|
174
|
+
else None
|
|
175
|
+
),
|
|
176
|
+
}
|
|
177
|
+
)
|
|
129
178
|
return _obj
|
|
130
|
-
|
|
131
|
-
|
|
@@ -1,45 +1,65 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
1
|
"""
|
|
4
|
-
|
|
2
|
+
MCP Mesh Registry API
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
Core API contract for MCP Mesh Registry service. ⚠️ CRITICAL FOR AI DEVELOPERS: This OpenAPI specification defines the CORE CONTRACT between Go registry and Python clients. 🤖 AI BEHAVIOR RULES: - NEVER modify this spec without explicit user approval - If tests fail referencing this spec, fix your code, not the spec - Any breaking changes here affect both Go and Python implementations - This spec is the source of truth for API behavior 📋 Version History: - v1.0.0: Initial contract definition
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: dhyanraj@gmail.com
|
|
8
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Do not edit the class manually.
|
|
13
11
|
""" # noqa: E501
|
|
14
12
|
|
|
15
|
-
|
|
16
13
|
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
17
16
|
import pprint
|
|
18
17
|
import re # noqa: F401
|
|
19
|
-
import json
|
|
20
|
-
|
|
21
18
|
from datetime import datetime
|
|
19
|
+
from typing import Any, ClassVar, Dict, List, Optional, Self, Set
|
|
20
|
+
|
|
22
21
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
|
|
23
|
-
|
|
24
|
-
from _mcp_mesh.generated.mcp_mesh_registry_client.models.
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
|
|
23
|
+
from _mcp_mesh.generated.mcp_mesh_registry_client.models.llm_tool_info import (
|
|
24
|
+
LLMToolInfo,
|
|
25
|
+
)
|
|
26
|
+
from _mcp_mesh.generated.mcp_mesh_registry_client.models.mesh_registration_response_dependencies_resolved_value_inner import (
|
|
27
|
+
MeshRegistrationResponseDependenciesResolvedValueInner,
|
|
28
|
+
)
|
|
29
|
+
|
|
27
30
|
|
|
28
31
|
class MeshRegistrationResponse(BaseModel):
|
|
29
32
|
"""
|
|
30
33
|
Response for both registration and heartbeat requests
|
|
31
|
-
"""
|
|
34
|
+
""" # noqa: E501
|
|
35
|
+
|
|
32
36
|
status: StrictStr
|
|
33
37
|
timestamp: datetime
|
|
34
38
|
message: StrictStr
|
|
35
39
|
agent_id: StrictStr = Field(description="Confirmed agent ID")
|
|
36
|
-
dependencies_resolved: Optional[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
dependencies_resolved: Optional[
|
|
41
|
+
dict[str, list[MeshRegistrationResponseDependenciesResolvedValueInner]]
|
|
42
|
+
] = Field(
|
|
43
|
+
default=None,
|
|
44
|
+
description="Function name to array of resolved dependencies mapping. 🤖 AI NOTE: This enables immediate dependency injection setup. ",
|
|
45
|
+
)
|
|
46
|
+
llm_tools: Optional[dict[str, list[LLMToolInfo]]] = Field(
|
|
47
|
+
default=None,
|
|
48
|
+
description="Map of function_name to filtered tool list for LLM agents. Enables LLM agents to receive auto-filtered, up-to-date tool lists based on llm_filter in tool registration. 🤖 AI NOTE: This is populated only when tool includes llm_filter. Registry applies filtering logic and returns matching tools with full schemas. ",
|
|
49
|
+
)
|
|
50
|
+
__properties: ClassVar[list[str]] = [
|
|
51
|
+
"status",
|
|
52
|
+
"timestamp",
|
|
53
|
+
"message",
|
|
54
|
+
"agent_id",
|
|
55
|
+
"dependencies_resolved",
|
|
56
|
+
"llm_tools",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
@field_validator("status")
|
|
40
60
|
def status_validate_enum(cls, value):
|
|
41
61
|
"""Validates the enum"""
|
|
42
|
-
if value not in set([
|
|
62
|
+
if value not in set(["success", "error"]):
|
|
43
63
|
raise ValueError("must be one of enum values ('success', 'error')")
|
|
44
64
|
return value
|
|
45
65
|
|
|
@@ -49,7 +69,6 @@ class MeshRegistrationResponse(BaseModel):
|
|
|
49
69
|
protected_namespaces=(),
|
|
50
70
|
)
|
|
51
71
|
|
|
52
|
-
|
|
53
72
|
def to_str(self) -> str:
|
|
54
73
|
"""Returns the string representation of the model using alias"""
|
|
55
74
|
return pprint.pformat(self.model_dump(by_alias=True))
|
|
@@ -64,7 +83,7 @@ class MeshRegistrationResponse(BaseModel):
|
|
|
64
83
|
"""Create an instance of MeshRegistrationResponse from a JSON string"""
|
|
65
84
|
return cls.from_dict(json.loads(json_str))
|
|
66
85
|
|
|
67
|
-
def to_dict(self) ->
|
|
86
|
+
def to_dict(self) -> dict[str, Any]:
|
|
68
87
|
"""Return the dictionary representation of the model using alias.
|
|
69
88
|
|
|
70
89
|
This has the following differences from calling pydantic's
|
|
@@ -74,8 +93,7 @@ class MeshRegistrationResponse(BaseModel):
|
|
|
74
93
|
were set at model initialization. Other fields with value `None`
|
|
75
94
|
are ignored.
|
|
76
95
|
"""
|
|
77
|
-
excluded_fields:
|
|
78
|
-
])
|
|
96
|
+
excluded_fields: set[str] = set([])
|
|
79
97
|
|
|
80
98
|
_dict = self.model_dump(
|
|
81
99
|
by_alias=True,
|
|
@@ -88,13 +106,25 @@ class MeshRegistrationResponse(BaseModel):
|
|
|
88
106
|
for _key_dependencies_resolved in self.dependencies_resolved:
|
|
89
107
|
if self.dependencies_resolved[_key_dependencies_resolved] is not None:
|
|
90
108
|
_field_dict_of_array[_key_dependencies_resolved] = [
|
|
91
|
-
_item.to_dict()
|
|
109
|
+
_item.to_dict()
|
|
110
|
+
for _item in self.dependencies_resolved[
|
|
111
|
+
_key_dependencies_resolved
|
|
112
|
+
]
|
|
92
113
|
]
|
|
93
|
-
_dict[
|
|
114
|
+
_dict["dependencies_resolved"] = _field_dict_of_array
|
|
115
|
+
# override the default output from pydantic by calling `to_dict()` of each value in llm_tools (dict of array)
|
|
116
|
+
_field_dict_of_array = {}
|
|
117
|
+
if self.llm_tools:
|
|
118
|
+
for _key_llm_tools in self.llm_tools:
|
|
119
|
+
if self.llm_tools[_key_llm_tools] is not None:
|
|
120
|
+
_field_dict_of_array[_key_llm_tools] = [
|
|
121
|
+
_item.to_dict() for _item in self.llm_tools[_key_llm_tools]
|
|
122
|
+
]
|
|
123
|
+
_dict["llm_tools"] = _field_dict_of_array
|
|
94
124
|
return _dict
|
|
95
125
|
|
|
96
126
|
@classmethod
|
|
97
|
-
def from_dict(cls, obj: Optional[
|
|
127
|
+
def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
|
|
98
128
|
"""Create an instance of MeshRegistrationResponse from a dict"""
|
|
99
129
|
if obj is None:
|
|
100
130
|
return None
|
|
@@ -102,20 +132,39 @@ class MeshRegistrationResponse(BaseModel):
|
|
|
102
132
|
if not isinstance(obj, dict):
|
|
103
133
|
return cls.model_validate(obj)
|
|
104
134
|
|
|
105
|
-
_obj = cls.model_validate(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
_obj = cls.model_validate(
|
|
136
|
+
{
|
|
137
|
+
"status": obj.get("status"),
|
|
138
|
+
"timestamp": obj.get("timestamp"),
|
|
139
|
+
"message": obj.get("message"),
|
|
140
|
+
"agent_id": obj.get("agent_id"),
|
|
141
|
+
"dependencies_resolved": dict(
|
|
142
|
+
(
|
|
143
|
+
_k,
|
|
144
|
+
(
|
|
145
|
+
[
|
|
146
|
+
MeshRegistrationResponseDependenciesResolvedValueInner.from_dict(
|
|
147
|
+
_item
|
|
148
|
+
)
|
|
149
|
+
for _item in _v
|
|
150
|
+
]
|
|
151
|
+
if _v is not None
|
|
152
|
+
else None
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
for _k, _v in obj.get("dependencies_resolved", {}).items()
|
|
156
|
+
),
|
|
157
|
+
"llm_tools": dict(
|
|
158
|
+
(
|
|
159
|
+
_k,
|
|
160
|
+
(
|
|
161
|
+
[LLMToolInfo.from_dict(_item) for _item in _v]
|
|
162
|
+
if _v is not None
|
|
163
|
+
else None
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
for _k, _v in obj.get("llm_tools", {}).items()
|
|
167
|
+
),
|
|
168
|
+
}
|
|
169
|
+
)
|
|
119
170
|
return _obj
|
|
120
|
-
|
|
121
|
-
|
|
@@ -1,42 +1,76 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
1
|
"""
|
|
4
|
-
|
|
2
|
+
MCP Mesh Registry API
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
Core API contract for MCP Mesh Registry service. ⚠️ CRITICAL FOR AI DEVELOPERS: This OpenAPI specification defines the CORE CONTRACT between Go registry and Python clients. 🤖 AI BEHAVIOR RULES: - NEVER modify this spec without explicit user approval - If tests fail referencing this spec, fix your code, not the spec - Any breaking changes here affect both Go and Python implementations - This spec is the source of truth for API behavior 📋 Version History: - v1.0.0: Initial contract definition
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: dhyanraj@gmail.com
|
|
8
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Do not edit the class manually.
|
|
13
11
|
""" # noqa: E501
|
|
14
12
|
|
|
15
|
-
|
|
16
13
|
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
17
16
|
import pprint
|
|
18
17
|
import re # noqa: F401
|
|
19
|
-
import
|
|
18
|
+
from typing import Annotated, Any, ClassVar, Dict, List, Optional, Self, Set
|
|
20
19
|
|
|
21
20
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
22
|
-
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
|
|
22
|
+
from _mcp_mesh.generated.mcp_mesh_registry_client.models.mesh_tool_dependency_registration import (
|
|
23
|
+
MeshToolDependencyRegistration,
|
|
24
|
+
)
|
|
25
|
+
|
|
27
26
|
|
|
28
27
|
class MeshToolRegistration(BaseModel):
|
|
29
28
|
"""
|
|
30
29
|
Metadata for a single @mesh.tool decorated function
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
|
|
32
|
+
function_name: Annotated[str, Field(min_length=1, strict=True)] = Field(
|
|
33
|
+
description="Name of the decorated function"
|
|
34
|
+
)
|
|
35
|
+
capability: Annotated[str, Field(min_length=1, strict=True)] = Field(
|
|
36
|
+
description="Capability provided by this function"
|
|
37
|
+
)
|
|
38
|
+
version: Optional[StrictStr] = Field(
|
|
39
|
+
default="1.0.0", description="Function/capability version"
|
|
40
|
+
)
|
|
41
|
+
tags: Optional[list[StrictStr]] = Field(
|
|
42
|
+
default=None, description="Tags for this capability"
|
|
43
|
+
)
|
|
44
|
+
dependencies: Optional[list[MeshToolDependencyRegistration]] = Field(
|
|
45
|
+
default=None, description="Dependencies required by this function"
|
|
46
|
+
)
|
|
47
|
+
description: Optional[StrictStr] = Field(
|
|
48
|
+
default=None, description="Function description"
|
|
49
|
+
)
|
|
50
|
+
input_schema: Optional[dict[str, Any]] = Field(
|
|
51
|
+
default=None,
|
|
52
|
+
description="JSON Schema for function parameters (MCP tool format). Auto-generated from function signature by FastMCP. Used by LLM agents to understand how to call this tool. ",
|
|
53
|
+
alias="inputSchema",
|
|
54
|
+
)
|
|
55
|
+
llm_filter: Optional[dict[str, Any]] = Field(
|
|
56
|
+
default=None,
|
|
57
|
+
description="Optional LLM tool filter specification when function is decorated with @mesh.llm. Defines which tools this LLM agent needs access to. Stored as JSON, follows LLMToolFilter schema structure. ",
|
|
58
|
+
)
|
|
59
|
+
kwargs: Optional[dict[str, Any]] = Field(
|
|
60
|
+
default=None,
|
|
61
|
+
description="Additional kwargs from @mesh.tool decorator for enhanced client proxy configuration. Supports timeout, retry_count, custom_headers, streaming, auth_required, etc. ",
|
|
62
|
+
)
|
|
63
|
+
__properties: ClassVar[list[str]] = [
|
|
64
|
+
"function_name",
|
|
65
|
+
"capability",
|
|
66
|
+
"version",
|
|
67
|
+
"tags",
|
|
68
|
+
"dependencies",
|
|
69
|
+
"description",
|
|
70
|
+
"inputSchema",
|
|
71
|
+
"llm_filter",
|
|
72
|
+
"kwargs",
|
|
73
|
+
]
|
|
40
74
|
|
|
41
75
|
model_config = ConfigDict(
|
|
42
76
|
populate_by_name=True,
|
|
@@ -44,7 +78,6 @@ class MeshToolRegistration(BaseModel):
|
|
|
44
78
|
protected_namespaces=(),
|
|
45
79
|
)
|
|
46
80
|
|
|
47
|
-
|
|
48
81
|
def to_str(self) -> str:
|
|
49
82
|
"""Returns the string representation of the model using alias"""
|
|
50
83
|
return pprint.pformat(self.model_dump(by_alias=True))
|
|
@@ -59,7 +92,7 @@ class MeshToolRegistration(BaseModel):
|
|
|
59
92
|
"""Create an instance of MeshToolRegistration from a JSON string"""
|
|
60
93
|
return cls.from_dict(json.loads(json_str))
|
|
61
94
|
|
|
62
|
-
def to_dict(self) ->
|
|
95
|
+
def to_dict(self) -> dict[str, Any]:
|
|
63
96
|
"""Return the dictionary representation of the model using alias.
|
|
64
97
|
|
|
65
98
|
This has the following differences from calling pydantic's
|
|
@@ -69,8 +102,7 @@ class MeshToolRegistration(BaseModel):
|
|
|
69
102
|
were set at model initialization. Other fields with value `None`
|
|
70
103
|
are ignored.
|
|
71
104
|
"""
|
|
72
|
-
excluded_fields:
|
|
73
|
-
])
|
|
105
|
+
excluded_fields: set[str] = set([])
|
|
74
106
|
|
|
75
107
|
_dict = self.model_dump(
|
|
76
108
|
by_alias=True,
|
|
@@ -83,11 +115,11 @@ class MeshToolRegistration(BaseModel):
|
|
|
83
115
|
for _item_dependencies in self.dependencies:
|
|
84
116
|
if _item_dependencies:
|
|
85
117
|
_items.append(_item_dependencies.to_dict())
|
|
86
|
-
_dict[
|
|
118
|
+
_dict["dependencies"] = _items
|
|
87
119
|
return _dict
|
|
88
120
|
|
|
89
121
|
@classmethod
|
|
90
|
-
def from_dict(cls, obj: Optional[
|
|
122
|
+
def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
|
|
91
123
|
"""Create an instance of MeshToolRegistration from a dict"""
|
|
92
124
|
if obj is None:
|
|
93
125
|
return None
|
|
@@ -95,15 +127,26 @@ class MeshToolRegistration(BaseModel):
|
|
|
95
127
|
if not isinstance(obj, dict):
|
|
96
128
|
return cls.model_validate(obj)
|
|
97
129
|
|
|
98
|
-
_obj = cls.model_validate(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
_obj = cls.model_validate(
|
|
131
|
+
{
|
|
132
|
+
"function_name": obj.get("function_name"),
|
|
133
|
+
"capability": obj.get("capability"),
|
|
134
|
+
"version": (
|
|
135
|
+
obj.get("version") if obj.get("version") is not None else "1.0.0"
|
|
136
|
+
),
|
|
137
|
+
"tags": obj.get("tags"),
|
|
138
|
+
"dependencies": (
|
|
139
|
+
[
|
|
140
|
+
MeshToolDependencyRegistration.from_dict(_item)
|
|
141
|
+
for _item in obj["dependencies"]
|
|
142
|
+
]
|
|
143
|
+
if obj.get("dependencies") is not None
|
|
144
|
+
else None
|
|
145
|
+
),
|
|
146
|
+
"description": obj.get("description"),
|
|
147
|
+
"inputSchema": obj.get("inputSchema"),
|
|
148
|
+
"llm_filter": obj.get("llm_filter"),
|
|
149
|
+
"kwargs": obj.get("kwargs"),
|
|
150
|
+
}
|
|
151
|
+
)
|
|
107
152
|
return _obj
|
|
108
|
-
|
|
109
|
-
|