dutchmate-mcp-server 0.1.0__tar.gz
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.
- dutchmate_mcp_server-0.1.0/LICENSE +73 -0
- dutchmate_mcp_server-0.1.0/PKG-INFO +14 -0
- dutchmate_mcp_server-0.1.0/pyproject.toml +24 -0
- dutchmate_mcp_server-0.1.0/pyproject.toml.orig +22 -0
- dutchmate_mcp_server-0.1.0/src/dutchmate_mcp_server/__init__.py +1 -0
- dutchmate_mcp_server-0.1.0/src/dutchmate_mcp_server/main.py +48 -0
- dutchmate_mcp_server-0.1.0/src/dutchmate_mcp_server/server.py +307 -0
- dutchmate_mcp_server-0.1.0/src/dutchmate_mcp_server/service_client.py +313 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright [yyyy] [name of copyright owner]
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dutchmate-mcp-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DUTchMate MCP server adapter.
|
|
5
|
+
Author: Nahit Pawar
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: dutchmate-core==0.1.0
|
|
9
|
+
Requires-Dist: httpx>=0.27
|
|
10
|
+
Requires-Dist: mcp>=2.0,<3
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Project-URL: Homepage, https://github.com/leonahi/DUTchMate
|
|
13
|
+
Project-URL: Repository, https://github.com/leonahi/DUTchMate
|
|
14
|
+
Project-URL: Issues, https://github.com/leonahi/DUTchMate/issues
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dutchmate-mcp-server"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "DUTchMate MCP server adapter."
|
|
5
|
+
requires-python = ">=3.10"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"dutchmate-core==0.1.0",
|
|
10
|
+
"httpx>=0.27",
|
|
11
|
+
"mcp>=2.0,<3",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[project.authors]]
|
|
15
|
+
name = "Nahit Pawar"
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/leonahi/DUTchMate"
|
|
19
|
+
Repository = "https://github.com/leonahi/DUTchMate"
|
|
20
|
+
Issues = "https://github.com/leonahi/DUTchMate/issues"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["uv_build>=0.11.26,<0.12"]
|
|
24
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dutchmate-mcp-server"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "DUTchMate MCP server adapter."
|
|
5
|
+
requires-python = ">=3.10"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Nahit Pawar" }]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"dutchmate-core==0.1.0",
|
|
11
|
+
"httpx>=0.27",
|
|
12
|
+
"mcp>=2.0,<3",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://github.com/leonahi/DUTchMate"
|
|
17
|
+
Repository = "https://github.com/leonahi/DUTchMate"
|
|
18
|
+
Issues = "https://github.com/leonahi/DUTchMate/issues"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["uv_build>=0.11.26,<0.12"]
|
|
22
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""DUTchMate MCP server package."""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""MCP server entrypoint for DUTchMate."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
from collections.abc import Sequence
|
|
8
|
+
from typing import Final, cast
|
|
9
|
+
|
|
10
|
+
from dutchmate_mcp_server.server import LogLevel, run_stdio
|
|
11
|
+
from dutchmate_mcp_server.service_client import DEFAULT_SERVICE_URL
|
|
12
|
+
|
|
13
|
+
SERVICE_URL_ENV: Final = "DUTCHMATE_SERVICE_URL"
|
|
14
|
+
LOG_LEVELS: Final = ("debug", "info", "warning", "error", "critical")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main(argv: Sequence[str] | None = None) -> None:
|
|
18
|
+
"""Start the DUTchMate MCP server over stdio."""
|
|
19
|
+
|
|
20
|
+
arguments = _parser().parse_args(argv)
|
|
21
|
+
run_stdio(
|
|
22
|
+
service_url=arguments.service_url,
|
|
23
|
+
log_level=cast(LogLevel, arguments.log_level.upper()),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _parser() -> argparse.ArgumentParser:
|
|
28
|
+
parser = argparse.ArgumentParser(description="Run the DUTchMate MCP stdio server.")
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--service-url",
|
|
31
|
+
default=os.environ.get(SERVICE_URL_ENV, DEFAULT_SERVICE_URL),
|
|
32
|
+
help=(
|
|
33
|
+
"Base URL for the Device Core Service "
|
|
34
|
+
f"(default: ${SERVICE_URL_ENV} or {DEFAULT_SERVICE_URL})."
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"--log-level",
|
|
39
|
+
choices=LOG_LEVELS,
|
|
40
|
+
default="info",
|
|
41
|
+
type=str.lower,
|
|
42
|
+
help="Process log level (default: info).",
|
|
43
|
+
)
|
|
44
|
+
return parser
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
main()
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"""Stateless MCP server composition for the stdio delivery adapter."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from collections.abc import Awaitable, Callable
|
|
7
|
+
from typing import Annotated, Final, Literal, TypeAlias, cast
|
|
8
|
+
|
|
9
|
+
from mcp.server import CacheHint, MCPServer
|
|
10
|
+
from mcp.server.caching import CacheableMethod
|
|
11
|
+
from mcp.server.context import ServerRequestContext
|
|
12
|
+
from mcp.types import (
|
|
13
|
+
LATEST_PROTOCOL_VERSION,
|
|
14
|
+
CallToolResult,
|
|
15
|
+
DiscoverResult,
|
|
16
|
+
RequestParams,
|
|
17
|
+
ServerCapabilities,
|
|
18
|
+
TextContent,
|
|
19
|
+
ToolsCapability,
|
|
20
|
+
)
|
|
21
|
+
from pydantic import WithJsonSchema
|
|
22
|
+
|
|
23
|
+
from dutchmate_core.validation import UartSendValidationError
|
|
24
|
+
from dutchmate_mcp_server.service_client import (
|
|
25
|
+
DEFAULT_SERVICE_URL,
|
|
26
|
+
DeviceCoreClient,
|
|
27
|
+
DeviceCoreProtocolError,
|
|
28
|
+
DeviceCoreServiceError,
|
|
29
|
+
DeviceCoreUnavailableError,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
SERVER_NAME: Final = "dutchmate"
|
|
33
|
+
SERVER_TITLE: Final = "DUTchMate Device Debug Tools"
|
|
34
|
+
SERVER_DESCRIPTION: Final = (
|
|
35
|
+
"Deterministic device-control and debug-evidence tools backed by the "
|
|
36
|
+
"DUTchMate Device Core Service."
|
|
37
|
+
)
|
|
38
|
+
SERVER_INSTRUCTIONS: Final = (
|
|
39
|
+
"Use DUTchMate tools to control the configured device and inspect bounded "
|
|
40
|
+
"session evidence. The Device Core Service must already be running. Treat "
|
|
41
|
+
"session IDs and pagination cursors as explicit tool data."
|
|
42
|
+
)
|
|
43
|
+
SERVER_VERSION: Final = "0.1.0"
|
|
44
|
+
CACHE_TTL_MS: Final = 300_000
|
|
45
|
+
|
|
46
|
+
ClientFactory: TypeAlias = Callable[[], DeviceCoreClient]
|
|
47
|
+
ClientOperation: TypeAlias = Callable[[DeviceCoreClient], Awaitable[dict[str, object]]]
|
|
48
|
+
LogLevel: TypeAlias = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
|
|
49
|
+
|
|
50
|
+
PulseMsArgument: TypeAlias = Annotated[
|
|
51
|
+
object,
|
|
52
|
+
WithJsonSchema({"type": "integer", "minimum": 1, "maximum": 10_000}),
|
|
53
|
+
]
|
|
54
|
+
BootModeArgument: TypeAlias = Annotated[
|
|
55
|
+
object,
|
|
56
|
+
WithJsonSchema({"type": "string", "enum": ["normal", "bootloader"]}),
|
|
57
|
+
]
|
|
58
|
+
DurationArgument: TypeAlias = Annotated[
|
|
59
|
+
object,
|
|
60
|
+
WithJsonSchema({"type": "number", "exclusiveMinimum": 0, "maximum": 300}),
|
|
61
|
+
]
|
|
62
|
+
LogLinesArgument: TypeAlias = Annotated[
|
|
63
|
+
object,
|
|
64
|
+
WithJsonSchema({"type": "integer", "minimum": 1, "maximum": 1000}),
|
|
65
|
+
]
|
|
66
|
+
SessionLimitArgument: TypeAlias = Annotated[
|
|
67
|
+
object,
|
|
68
|
+
WithJsonSchema({"type": "integer", "minimum": 1, "maximum": 100}),
|
|
69
|
+
]
|
|
70
|
+
RequiredStringArgument: TypeAlias = Annotated[
|
|
71
|
+
object,
|
|
72
|
+
WithJsonSchema({"type": "string"}),
|
|
73
|
+
]
|
|
74
|
+
OptionalStringArgument: TypeAlias = Annotated[
|
|
75
|
+
object,
|
|
76
|
+
WithJsonSchema({"anyOf": [{"type": "string"}, {"type": "null"}]}),
|
|
77
|
+
]
|
|
78
|
+
BooleanArgument: TypeAlias = Annotated[
|
|
79
|
+
object,
|
|
80
|
+
WithJsonSchema({"type": "boolean"}),
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def create_server(
|
|
85
|
+
service_url: str = DEFAULT_SERVICE_URL,
|
|
86
|
+
*,
|
|
87
|
+
log_level: LogLevel = "INFO",
|
|
88
|
+
client_factory: ClientFactory | None = None,
|
|
89
|
+
) -> MCPServer[object]:
|
|
90
|
+
"""Create one stateless MCP server with fixed protocol-facing metadata."""
|
|
91
|
+
|
|
92
|
+
cache_hints: dict[CacheableMethod, CacheHint] = {
|
|
93
|
+
"server/discover": CacheHint(ttl_ms=CACHE_TTL_MS, scope="private"),
|
|
94
|
+
"tools/list": CacheHint(ttl_ms=CACHE_TTL_MS, scope="private"),
|
|
95
|
+
}
|
|
96
|
+
server = MCPServer[object](
|
|
97
|
+
name=SERVER_NAME,
|
|
98
|
+
title=SERVER_TITLE,
|
|
99
|
+
description=SERVER_DESCRIPTION,
|
|
100
|
+
instructions=SERVER_INSTRUCTIONS,
|
|
101
|
+
version=SERVER_VERSION,
|
|
102
|
+
tools=[],
|
|
103
|
+
log_level=log_level,
|
|
104
|
+
cache_hints=cache_hints,
|
|
105
|
+
)
|
|
106
|
+
# SDK 2 registers these handlers even for empty catalogs. Remove them so
|
|
107
|
+
# the served methods agree with our tools-only discovery capabilities.
|
|
108
|
+
for method in (
|
|
109
|
+
"prompts/list",
|
|
110
|
+
"prompts/get",
|
|
111
|
+
"resources/list",
|
|
112
|
+
"resources/templates/list",
|
|
113
|
+
"resources/read",
|
|
114
|
+
"subscriptions/listen",
|
|
115
|
+
):
|
|
116
|
+
server._lowlevel_server._request_handlers.pop(method, None)
|
|
117
|
+
factory = client_factory or (lambda: DeviceCoreClient(service_url))
|
|
118
|
+
|
|
119
|
+
async def discover(
|
|
120
|
+
ctx: ServerRequestContext[object, object],
|
|
121
|
+
params: RequestParams | None,
|
|
122
|
+
) -> DiscoverResult:
|
|
123
|
+
del ctx, params
|
|
124
|
+
return DiscoverResult(
|
|
125
|
+
supported_versions=[LATEST_PROTOCOL_VERSION],
|
|
126
|
+
capabilities=ServerCapabilities(tools=ToolsCapability(list_changed=False)),
|
|
127
|
+
instructions=SERVER_INSTRUCTIONS,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
server._lowlevel_server.add_request_handler(
|
|
131
|
+
"server/discover",
|
|
132
|
+
RequestParams,
|
|
133
|
+
discover,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
@server.tool()
|
|
137
|
+
async def reset_dut(pulse_ms: PulseMsArgument = 100) -> CallToolResult:
|
|
138
|
+
"""Pulse the configured DUT reset control for 1..10000 milliseconds."""
|
|
139
|
+
|
|
140
|
+
return await _execute(
|
|
141
|
+
factory,
|
|
142
|
+
lambda client: client.reset_dut(pulse_ms=cast(int, pulse_ms)),
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
@server.tool()
|
|
146
|
+
async def set_boot_mode(mode: BootModeArgument) -> CallToolResult:
|
|
147
|
+
"""Command the configured DUT boot role to normal or bootloader mode."""
|
|
148
|
+
|
|
149
|
+
return await _execute(
|
|
150
|
+
factory,
|
|
151
|
+
lambda client: client.set_boot_mode(mode=cast(str, mode)),
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
@server.tool()
|
|
155
|
+
async def capture_uart(duration_s: DurationArgument) -> CallToolResult:
|
|
156
|
+
"""Capture bounded UART evidence for the requested duration in seconds."""
|
|
157
|
+
|
|
158
|
+
return await _execute(
|
|
159
|
+
factory,
|
|
160
|
+
lambda client: client.capture_uart(duration_s=cast(float, duration_s)),
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
@server.tool()
|
|
164
|
+
async def get_recent_uart_log(
|
|
165
|
+
lines: LogLinesArgument = 300,
|
|
166
|
+
session_id: OptionalStringArgument = None,
|
|
167
|
+
) -> CallToolResult:
|
|
168
|
+
"""Read bounded recent UART lines from an explicit or selected session."""
|
|
169
|
+
|
|
170
|
+
return await _execute(
|
|
171
|
+
factory,
|
|
172
|
+
lambda client: client.get_recent_uart_log(
|
|
173
|
+
lines=cast(int, lines),
|
|
174
|
+
session_id=cast(str | None, session_id),
|
|
175
|
+
),
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
@server.tool()
|
|
179
|
+
async def wait_for_uart_pattern(
|
|
180
|
+
pattern: RequiredStringArgument,
|
|
181
|
+
timeout_s: DurationArgument,
|
|
182
|
+
) -> CallToolResult:
|
|
183
|
+
"""Wait for a case-sensitive literal in new complete UART lines."""
|
|
184
|
+
|
|
185
|
+
return await _execute(
|
|
186
|
+
factory,
|
|
187
|
+
lambda client: client.wait_for_uart_pattern(
|
|
188
|
+
pattern=cast(str, pattern),
|
|
189
|
+
timeout_s=cast(float, timeout_s),
|
|
190
|
+
),
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
@server.tool()
|
|
194
|
+
async def run_boot_test(duration_s: DurationArgument) -> CallToolResult:
|
|
195
|
+
"""Reset the DUT and capture bounded boot evidence in its current boot mode."""
|
|
196
|
+
|
|
197
|
+
return await _execute(
|
|
198
|
+
factory,
|
|
199
|
+
lambda client: client.run_boot_test(duration_s=cast(float, duration_s)),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
@server.tool()
|
|
203
|
+
async def send_uart_command(
|
|
204
|
+
cmd: RequiredStringArgument,
|
|
205
|
+
append_newline: BooleanArgument = True,
|
|
206
|
+
force: BooleanArgument = False,
|
|
207
|
+
) -> CallToolResult:
|
|
208
|
+
"""Send one bounded UTF-8 command through the configured UART backend."""
|
|
209
|
+
|
|
210
|
+
return await _execute(
|
|
211
|
+
factory,
|
|
212
|
+
lambda client: client.send_uart_command(
|
|
213
|
+
cmd=cast(str, cmd),
|
|
214
|
+
append_newline=cast(bool, append_newline),
|
|
215
|
+
force=cast(bool, force),
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
@server.tool()
|
|
220
|
+
async def get_debug_session(session_id: RequiredStringArgument) -> CallToolResult:
|
|
221
|
+
"""Get bounded lifecycle metadata for one explicit debug session."""
|
|
222
|
+
|
|
223
|
+
return await _execute(
|
|
224
|
+
factory,
|
|
225
|
+
lambda client: client.get_debug_session(cast(str, session_id)),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
@server.tool()
|
|
229
|
+
async def list_debug_sessions(
|
|
230
|
+
limit: SessionLimitArgument = 50,
|
|
231
|
+
cursor: OptionalStringArgument = None,
|
|
232
|
+
) -> CallToolResult:
|
|
233
|
+
"""List a bounded page of debug-session summaries."""
|
|
234
|
+
|
|
235
|
+
return await _execute(
|
|
236
|
+
factory,
|
|
237
|
+
lambda client: client.list_debug_sessions(
|
|
238
|
+
limit=cast(int, limit),
|
|
239
|
+
cursor=cast(str | None, cursor),
|
|
240
|
+
),
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
return server
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
async def _execute(factory: ClientFactory, operation: ClientOperation) -> CallToolResult:
|
|
247
|
+
try:
|
|
248
|
+
async with factory() as client:
|
|
249
|
+
payload = await operation(client)
|
|
250
|
+
except UartSendValidationError as exc:
|
|
251
|
+
context: dict[str, object] | None = None
|
|
252
|
+
if exc.actual_bytes is not None:
|
|
253
|
+
context = {
|
|
254
|
+
"actual_bytes": exc.actual_bytes,
|
|
255
|
+
"max_bytes": exc.max_bytes,
|
|
256
|
+
}
|
|
257
|
+
return _tool_result(_validation_error_payload(exc, context=context), is_error=True)
|
|
258
|
+
except ValueError as exc:
|
|
259
|
+
return _tool_result(_validation_error_payload(exc), is_error=True)
|
|
260
|
+
except (DeviceCoreServiceError, DeviceCoreUnavailableError) as exc:
|
|
261
|
+
return _tool_result(exc.payload(), is_error=True)
|
|
262
|
+
except DeviceCoreProtocolError as exc:
|
|
263
|
+
return _tool_result(
|
|
264
|
+
{
|
|
265
|
+
"ok": False,
|
|
266
|
+
"error": "service_protocol_error",
|
|
267
|
+
"detail": str(exc),
|
|
268
|
+
"detail_truncated": False,
|
|
269
|
+
},
|
|
270
|
+
is_error=True,
|
|
271
|
+
)
|
|
272
|
+
return _tool_result(payload)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _validation_error_payload(
|
|
276
|
+
exc: ValueError,
|
|
277
|
+
*,
|
|
278
|
+
context: dict[str, object] | None = None,
|
|
279
|
+
) -> dict[str, object]:
|
|
280
|
+
payload: dict[str, object] = {
|
|
281
|
+
"ok": False,
|
|
282
|
+
"error": "invalid_argument",
|
|
283
|
+
"detail": str(exc),
|
|
284
|
+
"detail_truncated": False,
|
|
285
|
+
}
|
|
286
|
+
if context is not None:
|
|
287
|
+
payload["context"] = context
|
|
288
|
+
return payload
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def _tool_result(payload: dict[str, object], *, is_error: bool = False) -> CallToolResult:
|
|
292
|
+
text = json.dumps(payload, ensure_ascii=False, separators=(",", ":"), sort_keys=True)
|
|
293
|
+
return CallToolResult(
|
|
294
|
+
content=[TextContent(type="text", text=text)],
|
|
295
|
+
structured_content=payload,
|
|
296
|
+
is_error=is_error,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def run_stdio(
|
|
301
|
+
*,
|
|
302
|
+
service_url: str = DEFAULT_SERVICE_URL,
|
|
303
|
+
log_level: LogLevel = "INFO",
|
|
304
|
+
) -> None:
|
|
305
|
+
"""Run the server over stdio; no other MCP transport is exposed."""
|
|
306
|
+
|
|
307
|
+
create_server(service_url, log_level=log_level).run("stdio")
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"""Async HTTP port from the MCP adapter to the Device Core Service."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from typing import Final, NoReturn, cast
|
|
8
|
+
from urllib.parse import quote
|
|
9
|
+
|
|
10
|
+
import httpx
|
|
11
|
+
|
|
12
|
+
from dutchmate_core.validation import (
|
|
13
|
+
prepare_uart_send_payload,
|
|
14
|
+
validate_boot_mode,
|
|
15
|
+
validate_capture_duration,
|
|
16
|
+
validate_reset_pulse,
|
|
17
|
+
validate_session_id,
|
|
18
|
+
validate_wait_pattern,
|
|
19
|
+
validate_wait_timeout,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
DEFAULT_SERVICE_URL: Final = "http://127.0.0.1:2040"
|
|
23
|
+
DEFAULT_REQUEST_TIMEOUT_S: Final = 2.0
|
|
24
|
+
WORKFLOW_TIMEOUT_GRACE_S: Final = 2.0
|
|
25
|
+
SERVICE_NOT_RUNNING_DETAIL: Final = (
|
|
26
|
+
"Device Core Service is not running. Start it with an explicit Basic or "
|
|
27
|
+
"Enhanced backend before calling DUTchMate tools."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DeviceCoreClientError(RuntimeError):
|
|
32
|
+
"""Base error raised by the MCP Device Core HTTP port."""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DeviceCoreUnavailableError(DeviceCoreClientError):
|
|
36
|
+
"""Raised when the configured Device Core Service cannot be reached."""
|
|
37
|
+
|
|
38
|
+
error = "service_unavailable"
|
|
39
|
+
|
|
40
|
+
def __init__(self, detail: str = SERVICE_NOT_RUNNING_DETAIL) -> None:
|
|
41
|
+
self.detail = detail
|
|
42
|
+
super().__init__(detail)
|
|
43
|
+
|
|
44
|
+
def payload(self) -> dict[str, object]:
|
|
45
|
+
"""Return a canonical structured error for a future MCP tool result."""
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
"ok": False,
|
|
49
|
+
"error": self.error,
|
|
50
|
+
"detail": self.detail,
|
|
51
|
+
"detail_truncated": False,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class DeviceCoreProtocolError(DeviceCoreClientError):
|
|
56
|
+
"""Raised when the HTTP peer does not honor the Device Core JSON contract."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class DeviceCoreServiceError(DeviceCoreClientError):
|
|
60
|
+
"""Preserve one canonical structured Device Core Service error response."""
|
|
61
|
+
|
|
62
|
+
def __init__(self, *, status_code: int, response_payload: dict[str, object]) -> None:
|
|
63
|
+
self.status_code = status_code
|
|
64
|
+
self.response_payload = response_payload.copy()
|
|
65
|
+
self.error = cast(str, response_payload["error"])
|
|
66
|
+
self.detail = cast(str, response_payload["detail"])
|
|
67
|
+
self.detail_truncated = cast(bool, response_payload["detail_truncated"])
|
|
68
|
+
context = response_payload.get("context")
|
|
69
|
+
self.context = cast(dict[str, object] | None, context)
|
|
70
|
+
super().__init__(self.detail)
|
|
71
|
+
|
|
72
|
+
def payload(self) -> dict[str, object]:
|
|
73
|
+
"""Return the service payload without recasting its error or context."""
|
|
74
|
+
|
|
75
|
+
return self.response_payload.copy()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class DeviceCoreClient:
|
|
79
|
+
"""Call bounded Device Core endpoints without owning hardware or sessions."""
|
|
80
|
+
|
|
81
|
+
def __init__(
|
|
82
|
+
self,
|
|
83
|
+
service_url: str = DEFAULT_SERVICE_URL,
|
|
84
|
+
*,
|
|
85
|
+
transport: httpx.AsyncBaseTransport | None = None,
|
|
86
|
+
) -> None:
|
|
87
|
+
self.service_url = _validated_service_url(service_url)
|
|
88
|
+
self._client = httpx.AsyncClient(
|
|
89
|
+
base_url=self.service_url,
|
|
90
|
+
timeout=DEFAULT_REQUEST_TIMEOUT_S,
|
|
91
|
+
transport=transport,
|
|
92
|
+
follow_redirects=False,
|
|
93
|
+
trust_env=False,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
async def __aenter__(self) -> DeviceCoreClient:
|
|
97
|
+
return self
|
|
98
|
+
|
|
99
|
+
async def __aexit__(
|
|
100
|
+
self,
|
|
101
|
+
exc_type: type[BaseException] | None,
|
|
102
|
+
exc_value: BaseException | None,
|
|
103
|
+
traceback: TracebackType | None,
|
|
104
|
+
) -> None:
|
|
105
|
+
await self.aclose()
|
|
106
|
+
|
|
107
|
+
async def aclose(self) -> None:
|
|
108
|
+
"""Close the owned HTTP connection pool."""
|
|
109
|
+
|
|
110
|
+
await self._client.aclose()
|
|
111
|
+
|
|
112
|
+
async def reset_dut(self, *, pulse_ms: int = 100) -> dict[str, object]:
|
|
113
|
+
validated_pulse = validate_reset_pulse(pulse_ms)
|
|
114
|
+
return await self._request(
|
|
115
|
+
"POST",
|
|
116
|
+
"/dut/reset",
|
|
117
|
+
json={"pulse_ms": validated_pulse},
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
async def set_boot_mode(self, *, mode: str) -> dict[str, object]:
|
|
121
|
+
validated_mode = validate_boot_mode(mode)
|
|
122
|
+
return await self._request(
|
|
123
|
+
"POST",
|
|
124
|
+
"/dut/boot-mode",
|
|
125
|
+
json={"mode": validated_mode},
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
async def capture_uart(self, *, duration_s: float) -> dict[str, object]:
|
|
129
|
+
return await self._timed_workflow(
|
|
130
|
+
"/dut/capture",
|
|
131
|
+
duration_s=validate_capture_duration(duration_s),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
async def run_boot_test(self, *, duration_s: float) -> dict[str, object]:
|
|
135
|
+
return await self._timed_workflow(
|
|
136
|
+
"/dut/boot-test",
|
|
137
|
+
duration_s=validate_capture_duration(duration_s),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
async def wait_for_uart_pattern(
|
|
141
|
+
self,
|
|
142
|
+
*,
|
|
143
|
+
pattern: str,
|
|
144
|
+
timeout_s: float,
|
|
145
|
+
) -> dict[str, object]:
|
|
146
|
+
validated_pattern = validate_wait_pattern(pattern)
|
|
147
|
+
validated_timeout = validate_wait_timeout(timeout_s)
|
|
148
|
+
return await self._request(
|
|
149
|
+
"POST",
|
|
150
|
+
"/dut/wait-pattern",
|
|
151
|
+
json={"pattern": validated_pattern, "timeout_s": validated_timeout},
|
|
152
|
+
timeout_s=max(
|
|
153
|
+
DEFAULT_REQUEST_TIMEOUT_S,
|
|
154
|
+
validated_timeout + WORKFLOW_TIMEOUT_GRACE_S,
|
|
155
|
+
),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
async def send_uart_command(
|
|
159
|
+
self,
|
|
160
|
+
*,
|
|
161
|
+
cmd: str,
|
|
162
|
+
append_newline: bool = True,
|
|
163
|
+
force: bool = False,
|
|
164
|
+
) -> dict[str, object]:
|
|
165
|
+
prepare_uart_send_payload(cmd, append_newline=append_newline)
|
|
166
|
+
if not isinstance(force, bool):
|
|
167
|
+
raise ValueError("UART send force must be a boolean")
|
|
168
|
+
return await self._request(
|
|
169
|
+
"POST",
|
|
170
|
+
"/dut/uart/send",
|
|
171
|
+
json={
|
|
172
|
+
"cmd": cmd,
|
|
173
|
+
"append_newline": append_newline,
|
|
174
|
+
"force": force,
|
|
175
|
+
},
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
async def get_recent_uart_log(
|
|
179
|
+
self,
|
|
180
|
+
*,
|
|
181
|
+
lines: int = 300,
|
|
182
|
+
session_id: str | None = None,
|
|
183
|
+
) -> dict[str, object]:
|
|
184
|
+
if isinstance(lines, bool) or not isinstance(lines, int) or not 1 <= lines <= 1000:
|
|
185
|
+
raise ValueError("log lines must be an integer from 1 to 1000")
|
|
186
|
+
params: dict[str, str | int] = {"lines": lines}
|
|
187
|
+
if session_id is not None:
|
|
188
|
+
params["session_id"] = validate_session_id(session_id)
|
|
189
|
+
return await self._request("GET", "/dut/logs", params=params)
|
|
190
|
+
|
|
191
|
+
async def get_debug_session(self, session_id: str) -> dict[str, object]:
|
|
192
|
+
session_name = validate_session_id(session_id)
|
|
193
|
+
return await self._request(
|
|
194
|
+
"GET",
|
|
195
|
+
f"/sessions/{quote(session_name, safe='')}",
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
async def list_debug_sessions(
|
|
199
|
+
self,
|
|
200
|
+
*,
|
|
201
|
+
limit: int = 50,
|
|
202
|
+
cursor: str | None = None,
|
|
203
|
+
) -> dict[str, object]:
|
|
204
|
+
if isinstance(limit, bool) or not isinstance(limit, int) or not 1 <= limit <= 100:
|
|
205
|
+
raise ValueError("session limit must be an integer from 1 to 100")
|
|
206
|
+
if cursor is not None and (not isinstance(cursor, str) or not cursor):
|
|
207
|
+
raise ValueError("session cursor must be a non-empty string")
|
|
208
|
+
params: dict[str, str | int] = {"limit": limit}
|
|
209
|
+
if cursor is not None:
|
|
210
|
+
params["cursor"] = cursor
|
|
211
|
+
return await self._request("GET", "/sessions", params=params)
|
|
212
|
+
|
|
213
|
+
async def _timed_workflow(
|
|
214
|
+
self,
|
|
215
|
+
path: str,
|
|
216
|
+
*,
|
|
217
|
+
duration_s: float,
|
|
218
|
+
) -> dict[str, object]:
|
|
219
|
+
return await self._request(
|
|
220
|
+
"POST",
|
|
221
|
+
path,
|
|
222
|
+
json={"duration_s": duration_s},
|
|
223
|
+
timeout_s=max(
|
|
224
|
+
DEFAULT_REQUEST_TIMEOUT_S,
|
|
225
|
+
duration_s + WORKFLOW_TIMEOUT_GRACE_S,
|
|
226
|
+
),
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
async def _request(
|
|
230
|
+
self,
|
|
231
|
+
method: str,
|
|
232
|
+
path: str,
|
|
233
|
+
*,
|
|
234
|
+
json: Mapping[str, object] | None = None,
|
|
235
|
+
params: Mapping[str, str | int] | None = None,
|
|
236
|
+
timeout_s: float = DEFAULT_REQUEST_TIMEOUT_S,
|
|
237
|
+
) -> dict[str, object]:
|
|
238
|
+
try:
|
|
239
|
+
response = await self._client.request(
|
|
240
|
+
method,
|
|
241
|
+
path,
|
|
242
|
+
json=json,
|
|
243
|
+
params=params,
|
|
244
|
+
timeout=timeout_s,
|
|
245
|
+
)
|
|
246
|
+
except (httpx.ConnectError, httpx.ConnectTimeout) as exc:
|
|
247
|
+
raise DeviceCoreUnavailableError() from exc
|
|
248
|
+
except httpx.TimeoutException as exc:
|
|
249
|
+
raise DeviceCoreUnavailableError(
|
|
250
|
+
"Device Core Service request timed out. The service state is unknown."
|
|
251
|
+
) from exc
|
|
252
|
+
except httpx.RequestError as exc:
|
|
253
|
+
raise DeviceCoreUnavailableError(
|
|
254
|
+
"Device Core Service request failed before a valid response was received."
|
|
255
|
+
) from exc
|
|
256
|
+
|
|
257
|
+
payload = _json_object(response)
|
|
258
|
+
if 200 <= response.status_code < 300:
|
|
259
|
+
return payload
|
|
260
|
+
_raise_service_error(response.status_code, payload)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def _validated_service_url(value: str) -> str:
|
|
264
|
+
if not isinstance(value, str) or not value.strip():
|
|
265
|
+
raise ValueError("Device Core service URL must be a non-empty string")
|
|
266
|
+
try:
|
|
267
|
+
url = httpx.URL(value.strip())
|
|
268
|
+
except httpx.InvalidURL as exc:
|
|
269
|
+
raise ValueError("Device Core service URL is invalid") from exc
|
|
270
|
+
if url.scheme not in {"http", "https"} or not url.host:
|
|
271
|
+
raise ValueError("Device Core service URL must be an absolute HTTP(S) URL")
|
|
272
|
+
if url.username or url.password:
|
|
273
|
+
raise ValueError("Device Core service URL must not contain credentials")
|
|
274
|
+
if url.query or url.fragment:
|
|
275
|
+
raise ValueError("Device Core service URL must not contain a query or fragment")
|
|
276
|
+
if url.path not in {"", "/"}:
|
|
277
|
+
raise ValueError("Device Core service URL must not contain a path")
|
|
278
|
+
return str(url).rstrip("/")
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def _json_object(response: httpx.Response) -> dict[str, object]:
|
|
282
|
+
try:
|
|
283
|
+
payload = response.json()
|
|
284
|
+
except ValueError as exc:
|
|
285
|
+
raise DeviceCoreProtocolError(
|
|
286
|
+
f"Device Core Service returned invalid JSON with HTTP {response.status_code}"
|
|
287
|
+
) from exc
|
|
288
|
+
if not isinstance(payload, Mapping):
|
|
289
|
+
raise DeviceCoreProtocolError(
|
|
290
|
+
f"Device Core Service returned a non-object JSON response with HTTP "
|
|
291
|
+
f"{response.status_code}"
|
|
292
|
+
)
|
|
293
|
+
return dict(payload)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _raise_service_error(status_code: int, payload: dict[str, object]) -> NoReturn:
|
|
297
|
+
error = payload.get("error")
|
|
298
|
+
detail = payload.get("detail")
|
|
299
|
+
detail_truncated = payload.get("detail_truncated")
|
|
300
|
+
context = payload.get("context")
|
|
301
|
+
if (
|
|
302
|
+
payload.get("ok") is not False
|
|
303
|
+
or not isinstance(error, str)
|
|
304
|
+
or not error
|
|
305
|
+
or not isinstance(detail, str)
|
|
306
|
+
or not detail
|
|
307
|
+
or not isinstance(detail_truncated, bool)
|
|
308
|
+
or (context is not None and not isinstance(context, dict))
|
|
309
|
+
):
|
|
310
|
+
raise DeviceCoreProtocolError(
|
|
311
|
+
f"Device Core Service returned an invalid error contract with HTTP {status_code}"
|
|
312
|
+
)
|
|
313
|
+
raise DeviceCoreServiceError(status_code=status_code, response_payload=payload)
|