modmex-lambda 0.7.0__py3-none-any.whl → 0.7.1__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.
- modmex_lambda/mcp/transport.py +39 -0
- {modmex_lambda-0.7.0.dist-info → modmex_lambda-0.7.1.dist-info}/METADATA +1 -1
- {modmex_lambda-0.7.0.dist-info → modmex_lambda-0.7.1.dist-info}/RECORD +5 -5
- {modmex_lambda-0.7.0.dist-info → modmex_lambda-0.7.1.dist-info}/WHEEL +0 -0
- {modmex_lambda-0.7.0.dist-info → modmex_lambda-0.7.1.dist-info}/licenses/LICENSE +0 -0
modmex_lambda/mcp/transport.py
CHANGED
|
@@ -120,6 +120,45 @@ class MCPHttpTransport:
|
|
|
120
120
|
if "io.modelcontextprotocol/clientCapabilities" not in metadata:
|
|
121
121
|
response = JSONRPCResponse.failure(payload.get("id"), JSONRPCErrorCode.INVALID_PARAMS, "Missing clientCapabilities")
|
|
122
122
|
return Response(body=self._model_dict(response), status_code=HTTPStatus.BAD_REQUEST, content_type=content_types.APPLICATION_JSON)
|
|
123
|
+
if method == "tools/call":
|
|
124
|
+
mismatch = self._validate_tool_parameter_headers(payload, headers)
|
|
125
|
+
if mismatch is not None:
|
|
126
|
+
return self._header_mismatch(payload, mismatch)
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
def _validate_tool_parameter_headers(self, payload: dict[str, Any], headers: Any) -> str | None:
|
|
130
|
+
params = payload.get("params") or {}
|
|
131
|
+
tool = self.server.tools.get(params.get("name")) if isinstance(params.get("name"), str) else None
|
|
132
|
+
if tool is None:
|
|
133
|
+
return None
|
|
134
|
+
schema = tool.definition().get("inputSchema")
|
|
135
|
+
arguments = params.get("arguments") or {}
|
|
136
|
+
expected: dict[str, str] = {}
|
|
137
|
+
|
|
138
|
+
def visit(node: Any, value: Any) -> None:
|
|
139
|
+
if not isinstance(node, dict) or not isinstance(value, dict):
|
|
140
|
+
return
|
|
141
|
+
for name, property_schema in (node.get("properties") or {}).items():
|
|
142
|
+
if not isinstance(property_schema, dict):
|
|
143
|
+
continue
|
|
144
|
+
header_name = property_schema.get("x-mcp-header")
|
|
145
|
+
if isinstance(header_name, str) and name in value:
|
|
146
|
+
item = value[name]
|
|
147
|
+
serialized = str(item).lower() if isinstance(item, bool) else str(item)
|
|
148
|
+
expected[f"mcp-param-{header_name}".lower()] = serialized
|
|
149
|
+
if property_schema.get("type") == "object":
|
|
150
|
+
visit(property_schema, value.get(name))
|
|
151
|
+
|
|
152
|
+
visit(schema, arguments)
|
|
153
|
+
actual = {str(key).lower(): value for key, value in headers.items()}
|
|
154
|
+
for header_name, expected_value in expected.items():
|
|
155
|
+
if header_name not in actual:
|
|
156
|
+
return f"Missing {header_name} header"
|
|
157
|
+
if self._decode_header(actual[header_name]) != expected_value:
|
|
158
|
+
return f"{header_name} does not match tool argument"
|
|
159
|
+
for header_name in actual:
|
|
160
|
+
if header_name.startswith("mcp-param-") and header_name not in expected:
|
|
161
|
+
return f"Unexpected {header_name} header"
|
|
123
162
|
return None
|
|
124
163
|
|
|
125
164
|
def _header_mismatch(self, payload: dict[str, Any], message: str) -> Any:
|
|
@@ -67,7 +67,7 @@ modmex_lambda/mcp/resource.py,sha256=X_U0om1-nsuv8WwJ_ydUrFQL3k4aRqwp502aAs7KP3o
|
|
|
67
67
|
modmex_lambda/mcp/schema.py,sha256=TjHBV4rlavJxIrGA2g3g_PS00gXxEIw-t2uxOJtBn9Q,3300
|
|
68
68
|
modmex_lambda/mcp/server.py,sha256=Wsm9G_rVzMUOurbn_VuATqKlnQnAWoKmKQ7JqTWoTb0,18342
|
|
69
69
|
modmex_lambda/mcp/tool.py,sha256=rYeTFo9kVDm6VyYNzzO0SWEu9WtGSpXZuX3Cvhev6yw,7546
|
|
70
|
-
modmex_lambda/mcp/transport.py,sha256=
|
|
70
|
+
modmex_lambda/mcp/transport.py,sha256=SOMwUv2hXEn6ZUuuCj39cZqk6SC8RR2qCTF7XHA7gwk,10181
|
|
71
71
|
modmex_lambda/persistence/__init__.py,sha256=oa4FHCvitEkoagJ059jGATj6GSm-maazzf_QNi4WdQs,74
|
|
72
72
|
modmex_lambda/persistence/dynamodb/__init__.py,sha256=f_R3NHWfHvTWkCYfBHqY-z75r7pESsUv5FmFf05Glgg,1026
|
|
73
73
|
modmex_lambda/persistence/dynamodb/expressions.py,sha256=E_FDebLgROv63DBRQXKuO1hXjTt9g1kGzbgH2YBNu-Y,1694
|
|
@@ -154,7 +154,7 @@ modmex_lambda/stream/utils/time.py,sha256=dnsL2xeWpa1FXm2p8y9rWXtICMBlCBkgLaJ_en
|
|
|
154
154
|
modmex_lambda/stream/utils/uow.py,sha256=8WSPVE7AiHInkFDfBEeKOvdirY6GAgBoS7qkF1f1JVM,3207
|
|
155
155
|
modmex_lambda/stream/utils/data_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
156
156
|
modmex_lambda/stream/utils/data_classes/dynamodb.py,sha256=h_7MtUyRkvvV1r2QECrRDu7RR4Hh94SwSjc_8K2_XGM,363
|
|
157
|
-
modmex_lambda-0.7.
|
|
158
|
-
modmex_lambda-0.7.
|
|
159
|
-
modmex_lambda-0.7.
|
|
160
|
-
modmex_lambda-0.7.
|
|
157
|
+
modmex_lambda-0.7.1.dist-info/METADATA,sha256=f6HaOnWQm-pLWAY79LlGjPa9kjBlUUUA5FBrT1hwDfc,38565
|
|
158
|
+
modmex_lambda-0.7.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
159
|
+
modmex_lambda-0.7.1.dist-info/licenses/LICENSE,sha256=_C2TDTOsYeJvE4vn9VB51laKvleBKbdNnn96wJVtXhQ,1063
|
|
160
|
+
modmex_lambda-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|