structurize 3.4.3__tar.gz → 3.5.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.
- {structurize-3.4.3/structurize.egg-info → structurize-3.5.0}/PKG-INFO +1 -1
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/_version.py +3 -3
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotojava.py +4 -3
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/constants.py +17 -12
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/dependencies/typescript/node22/package.json +1 -1
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/mcp_server.py +210 -2
- {structurize-3.4.3 → structurize-3.5.0/structurize.egg-info}/PKG-INFO +1 -1
- {structurize-3.4.3 → structurize-3.5.0}/structurize.egg-info/SOURCES.txt +1 -0
- {structurize-3.4.3 → structurize-3.5.0}/.gitignore +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/LICENSE +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/MANIFEST.in +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/README.md +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/__init__.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/__main__.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/asn1toavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotize.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotocpp.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotocsharp.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotocsv.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotodatapackage.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotodb.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotogo.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotographql.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotoiceberg.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotojs.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotojsons.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotojstruct.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotokusto.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotomd.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotools.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotoparquet.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotoproto.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotopython.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotorust.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotots.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrotoxsd.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/avrovalidator.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/cddltostructure.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/choice_inference.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/commands.json +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/common.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/csvtoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/datapackagetoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/dependencies/cpp/vcpkg/vcpkg.json +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/dependency_resolver.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/dependency_version.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/jsonstoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/jsonstostructure.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/jsontoschema.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/jstructtoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/kstructtoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/kustotoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/kustotojstruct.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/openapitostructure.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/parquettoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/proto2parser.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/proto3parser.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/prototoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/schema_inference.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/sqltoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretocddl.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretocpp.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretocsharp.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretocsv.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretodatapackage.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretodb.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretogo.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretographql.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretoiceberg.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretojava.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretojs.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretojsons.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretokusto.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretomd.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretoproto.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretopython.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretorust.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretots.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/structuretoxsd.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/validate.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/xmltoschema.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/avrotize/xsdtoavro.py +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/build.ps1 +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/build.sh +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/pyproject.toml +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/setup.cfg +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/structurize.egg-info/dependency_links.txt +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/structurize.egg-info/entry_points.txt +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/structurize.egg-info/requires.txt +0 -0
- {structurize-3.4.3 → structurize-3.5.0}/structurize.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: structurize
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5.0
|
|
4
4
|
Summary: Tools to convert from and to JSON Structure from various other schema languages.
|
|
5
5
|
Author-email: Clemens Vasters <clemensv@microsoft.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '3.
|
|
32
|
-
__version_tuple__ = version_tuple = (3,
|
|
31
|
+
__version__ = version = '3.5.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (3, 5, 0)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g95f637e11'
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
6
|
from typing import Dict, List, Tuple, Union
|
|
7
|
-
from avrotize.constants import (AVRO_VERSION,
|
|
8
|
-
|
|
7
|
+
from avrotize.constants import (AVRO_VERSION, JACKSON_ANNOTATIONS_VERSION, JACKSON_VERSION,
|
|
8
|
+
JDK_VERSION, JUNIT_VERSION, MAVEN_COMPILER_VERSION, MAVEN_SUREFIRE_VERSION)
|
|
9
9
|
|
|
10
10
|
from avrotize.common import pascal, camel, is_generic_avro_type, inline_avro_references, build_flat_type_dict
|
|
11
11
|
|
|
@@ -42,7 +42,7 @@ POM_CONTENT = """<?xml version="1.0" encoding="UTF-8"?>
|
|
|
42
42
|
<dependency>
|
|
43
43
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
44
44
|
<artifactId>jackson-annotations</artifactId>
|
|
45
|
-
<version>{
|
|
45
|
+
<version>{JACKSON_ANNOTATIONS_VERSION}</version>
|
|
46
46
|
</dependency>
|
|
47
47
|
<dependency>
|
|
48
48
|
<groupId>org.junit.jupiter</groupId>
|
|
@@ -2160,6 +2160,7 @@ class AvroToJava:
|
|
|
2160
2160
|
artifactid=artifactid,
|
|
2161
2161
|
AVRO_VERSION=AVRO_VERSION,
|
|
2162
2162
|
JACKSON_VERSION=JACKSON_VERSION,
|
|
2163
|
+
JACKSON_ANNOTATIONS_VERSION=JACKSON_ANNOTATIONS_VERSION,
|
|
2163
2164
|
JDK_VERSION=JDK_VERSION,
|
|
2164
2165
|
JUNIT_VERSION=JUNIT_VERSION,
|
|
2165
2166
|
MAVEN_COMPILER_VERSION=MAVEN_COMPILER_VERSION,
|
|
@@ -17,61 +17,66 @@ try:
|
|
|
17
17
|
except ValueError:
|
|
18
18
|
JACKSON_VERSION = '2.18.2' # Fallback
|
|
19
19
|
|
|
20
|
+
try:
|
|
21
|
+
JACKSON_ANNOTATIONS_VERSION = get_dependency_version('java', 'jdk21', 'com.fasterxml.jackson.core:jackson-annotations')
|
|
22
|
+
except ValueError:
|
|
23
|
+
JACKSON_ANNOTATIONS_VERSION = '2.18.2' # Fallback
|
|
24
|
+
|
|
20
25
|
JDK_VERSION = '21'
|
|
21
26
|
|
|
22
27
|
# C# dependencies
|
|
23
28
|
try:
|
|
24
|
-
CSHARP_AVRO_VERSION = get_dependency_version('cs', '
|
|
29
|
+
CSHARP_AVRO_VERSION = get_dependency_version('cs', 'net100', 'Apache.Avro')
|
|
25
30
|
except ValueError:
|
|
26
31
|
CSHARP_AVRO_VERSION = '1.12.0'
|
|
27
32
|
|
|
28
33
|
try:
|
|
29
|
-
NEWTONSOFT_JSON_VERSION = get_dependency_version('cs', '
|
|
34
|
+
NEWTONSOFT_JSON_VERSION = get_dependency_version('cs', 'net100', 'Newtonsoft.Json')
|
|
30
35
|
except ValueError:
|
|
31
36
|
NEWTONSOFT_JSON_VERSION = '13.0.3'
|
|
32
37
|
|
|
33
38
|
try:
|
|
34
|
-
SYSTEM_TEXT_JSON_VERSION = get_dependency_version('cs', '
|
|
39
|
+
SYSTEM_TEXT_JSON_VERSION = get_dependency_version('cs', 'net100', 'System.Text.Json')
|
|
35
40
|
except ValueError:
|
|
36
41
|
SYSTEM_TEXT_JSON_VERSION = '9.0.3'
|
|
37
42
|
|
|
38
43
|
try:
|
|
39
|
-
SYSTEM_MEMORY_DATA_VERSION = get_dependency_version('cs', '
|
|
44
|
+
SYSTEM_MEMORY_DATA_VERSION = get_dependency_version('cs', 'net100', 'System.Memory.Data')
|
|
40
45
|
except ValueError:
|
|
41
46
|
SYSTEM_MEMORY_DATA_VERSION = '9.0.3'
|
|
42
47
|
|
|
43
48
|
try:
|
|
44
|
-
PROTOBUF_NET_VERSION = get_dependency_version('cs', '
|
|
49
|
+
PROTOBUF_NET_VERSION = get_dependency_version('cs', 'net100', 'protobuf-net')
|
|
45
50
|
except ValueError:
|
|
46
51
|
PROTOBUF_NET_VERSION = '3.2.30'
|
|
47
52
|
|
|
48
53
|
try:
|
|
49
|
-
NUNIT_VERSION = get_dependency_version('cs', '
|
|
54
|
+
NUNIT_VERSION = get_dependency_version('cs', 'net100', 'NUnit')
|
|
50
55
|
except ValueError:
|
|
51
56
|
NUNIT_VERSION = '4.3.2'
|
|
52
57
|
|
|
53
58
|
try:
|
|
54
|
-
NUNIT_ADAPTER_VERSION = get_dependency_version('cs', '
|
|
59
|
+
NUNIT_ADAPTER_VERSION = get_dependency_version('cs', 'net100', 'NUnit3TestAdapter')
|
|
55
60
|
except ValueError:
|
|
56
61
|
NUNIT_ADAPTER_VERSION = '5.0.0'
|
|
57
62
|
|
|
58
63
|
try:
|
|
59
|
-
MSTEST_SDK_VERSION = get_dependency_version('cs', '
|
|
64
|
+
MSTEST_SDK_VERSION = get_dependency_version('cs', 'net100', 'Microsoft.NET.Test.Sdk')
|
|
60
65
|
except ValueError:
|
|
61
66
|
MSTEST_SDK_VERSION = '17.13.0'
|
|
62
67
|
|
|
63
68
|
try:
|
|
64
|
-
COVERLET_VERSION = get_dependency_version('cs', '
|
|
69
|
+
COVERLET_VERSION = get_dependency_version('cs', 'net100', 'coverlet.collector')
|
|
65
70
|
except ValueError:
|
|
66
71
|
COVERLET_VERSION = '6.0.4'
|
|
67
72
|
|
|
68
73
|
try:
|
|
69
|
-
MSGPACK_VERSION = get_dependency_version('cs', '
|
|
74
|
+
MSGPACK_VERSION = get_dependency_version('cs', 'net100', 'MessagePack')
|
|
70
75
|
except ValueError:
|
|
71
76
|
MSGPACK_VERSION = '2.5.187'
|
|
72
77
|
|
|
73
78
|
try:
|
|
74
|
-
CBOR_VERSION = get_dependency_version('cs', '
|
|
79
|
+
CBOR_VERSION = get_dependency_version('cs', 'net100', 'Dahomey.Cbor')
|
|
75
80
|
except ValueError:
|
|
76
81
|
CBOR_VERSION = '1.25.1'
|
|
77
82
|
|
|
@@ -89,4 +94,4 @@ except ValueError:
|
|
|
89
94
|
try:
|
|
90
95
|
MAVEN_COMPILER_VERSION = get_dependency_version('java', 'jdk21', 'org.apache.maven.plugins:maven-compiler-plugin')
|
|
91
96
|
except ValueError:
|
|
92
|
-
MAVEN_COMPILER_VERSION = '3.13.0'
|
|
97
|
+
MAVEN_COMPILER_VERSION = '3.13.0'
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
"""MCP server integration for Avrotize conversions.
|
|
1
|
+
"""MCP server integration for Avrotize conversions.
|
|
2
|
+
|
|
3
|
+
Implements the MCP (Model Context Protocol) stdio transport directly via
|
|
4
|
+
JSON-RPC 2.0 over stdin/stdout to avoid the heavy ``mcp`` library import
|
|
5
|
+
(~2-3 s for uvicorn, starlette, httpx, pydantic). The ``mcp`` library
|
|
6
|
+
is used only as a fallback when *explicitly* requested.
|
|
7
|
+
"""
|
|
2
8
|
|
|
3
9
|
from __future__ import annotations
|
|
4
10
|
|
|
5
11
|
import argparse
|
|
12
|
+
import json as _json
|
|
6
13
|
import os
|
|
14
|
+
import sys
|
|
7
15
|
import tempfile
|
|
8
16
|
from typing import Any, Dict, List
|
|
9
17
|
|
|
10
18
|
from avrotize.avrotize import dynamic_import, load_commands
|
|
11
19
|
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
# MCP protocol version supported by this server
|
|
22
|
+
# ---------------------------------------------------------------------------
|
|
23
|
+
_MCP_PROTOCOL_VERSION = "2025-03-26"
|
|
24
|
+
|
|
12
25
|
|
|
13
26
|
def _command_dest(arg: Dict[str, Any]) -> str:
|
|
14
27
|
name = arg["name"]
|
|
@@ -227,10 +240,192 @@ def _execute_conversion(
|
|
|
227
240
|
os.remove(temp_output_path)
|
|
228
241
|
|
|
229
242
|
|
|
243
|
+
def _tool_schemas() -> List[Dict[str, Any]]:
|
|
244
|
+
"""Return MCP tool definitions for the four exposed tools."""
|
|
245
|
+
return [
|
|
246
|
+
{
|
|
247
|
+
"name": "describe_capabilities",
|
|
248
|
+
"description": "Describe when this server should be used and how to invoke it.",
|
|
249
|
+
"inputSchema": {"type": "object", "properties": {}},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"name": "list_conversions",
|
|
253
|
+
"description": "List available Avrotize conversion commands.",
|
|
254
|
+
"inputSchema": {"type": "object", "properties": {}},
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "get_conversion",
|
|
258
|
+
"description": "Get metadata for a specific conversion command.",
|
|
259
|
+
"inputSchema": {
|
|
260
|
+
"type": "object",
|
|
261
|
+
"properties": {
|
|
262
|
+
"command": {"type": "string", "description": "The conversion command name."},
|
|
263
|
+
},
|
|
264
|
+
"required": ["command"],
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "run_conversion",
|
|
269
|
+
"description": "Run a conversion command and return conversion output information.",
|
|
270
|
+
"inputSchema": {
|
|
271
|
+
"type": "object",
|
|
272
|
+
"properties": {
|
|
273
|
+
"command": {"type": "string", "description": "The conversion command name."},
|
|
274
|
+
"input_path": {"type": "string", "description": "Path to the input file.", "default": ""},
|
|
275
|
+
"input_content": {"type": "string", "description": "Inline input content.", "default": ""},
|
|
276
|
+
"output_path": {"type": "string", "description": "Path for the output file.", "default": ""},
|
|
277
|
+
"options": {
|
|
278
|
+
"type": "object",
|
|
279
|
+
"description": "Additional command options.",
|
|
280
|
+
"additionalProperties": True,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
"required": ["command"],
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def _dispatch_tool(name: str, arguments: Dict[str, Any]) -> Any:
|
|
290
|
+
"""Dispatch a tool call by *name* and return a Python object."""
|
|
291
|
+
if name == "describe_capabilities":
|
|
292
|
+
return _describe_capabilities()
|
|
293
|
+
if name == "list_conversions":
|
|
294
|
+
return _list_commands()
|
|
295
|
+
if name == "get_conversion":
|
|
296
|
+
return _get_conversion_handler(arguments)
|
|
297
|
+
if name == "run_conversion":
|
|
298
|
+
return _run_conversion_handler(arguments)
|
|
299
|
+
raise ValueError(f"Unknown tool '{name}'.")
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def _get_conversion_handler(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
303
|
+
command_name = args.get("command", "")
|
|
304
|
+
cmd = _find_command(command_name)
|
|
305
|
+
if not cmd:
|
|
306
|
+
raise ValueError(f"Unknown command '{command_name}'.")
|
|
307
|
+
return {
|
|
308
|
+
"command": cmd.get("command"),
|
|
309
|
+
"description": cmd.get("description"),
|
|
310
|
+
"group": cmd.get("group"),
|
|
311
|
+
"args": cmd.get("args", []),
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def _run_conversion_handler(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
316
|
+
return _execute_conversion(
|
|
317
|
+
command_name=args.get("command", ""),
|
|
318
|
+
input_path=args.get("input_path") or None,
|
|
319
|
+
input_content=args.get("input_content") or None,
|
|
320
|
+
output_path=args.get("output_path") or None,
|
|
321
|
+
options=args.get("options") or {},
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
# ---------------------------------------------------------------------------
|
|
326
|
+
# Lightweight JSON-RPC / MCP stdio transport
|
|
327
|
+
# ---------------------------------------------------------------------------
|
|
328
|
+
|
|
329
|
+
def _jsonrpc_error(req_id: Any, code: int, message: str) -> Dict[str, Any]:
|
|
330
|
+
return {"jsonrpc": "2.0", "id": req_id, "error": {"code": code, "message": message}}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def _jsonrpc_result(req_id: Any, result: Any) -> Dict[str, Any]:
|
|
334
|
+
return {"jsonrpc": "2.0", "id": req_id, "result": result}
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def _handle_message(msg: Dict[str, Any]) -> Dict[str, Any] | None:
|
|
338
|
+
"""Process one JSON-RPC message. Returns a response dict, or None for notifications."""
|
|
339
|
+
method = msg.get("method", "")
|
|
340
|
+
req_id = msg.get("id")
|
|
341
|
+
params = msg.get("params", {})
|
|
342
|
+
|
|
343
|
+
# --- Lifecycle ----------------------------------------------------------
|
|
344
|
+
if method == "initialize":
|
|
345
|
+
return _jsonrpc_result(req_id, {
|
|
346
|
+
"protocolVersion": _MCP_PROTOCOL_VERSION,
|
|
347
|
+
"capabilities": {"tools": {}},
|
|
348
|
+
"serverInfo": {"name": "avrotize", "version": _get_version()},
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
if method == "notifications/initialized":
|
|
352
|
+
return None # notification — no response
|
|
353
|
+
|
|
354
|
+
if method == "ping":
|
|
355
|
+
return _jsonrpc_result(req_id, {})
|
|
356
|
+
|
|
357
|
+
# --- Tool discovery -----------------------------------------------------
|
|
358
|
+
if method == "tools/list":
|
|
359
|
+
return _jsonrpc_result(req_id, {"tools": _tool_schemas()})
|
|
360
|
+
|
|
361
|
+
# --- Tool execution -----------------------------------------------------
|
|
362
|
+
if method == "tools/call":
|
|
363
|
+
tool_name = params.get("name", "")
|
|
364
|
+
arguments = params.get("arguments", {})
|
|
365
|
+
try:
|
|
366
|
+
result = _dispatch_tool(tool_name, arguments)
|
|
367
|
+
text = _json.dumps(result, default=str)
|
|
368
|
+
return _jsonrpc_result(req_id, {
|
|
369
|
+
"content": [{"type": "text", "text": text}],
|
|
370
|
+
})
|
|
371
|
+
except Exception as exc:
|
|
372
|
+
return _jsonrpc_result(req_id, {
|
|
373
|
+
"content": [{"type": "text", "text": str(exc)}],
|
|
374
|
+
"isError": True,
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
# Notifications we don't handle — silently ignore
|
|
378
|
+
if req_id is None:
|
|
379
|
+
return None
|
|
380
|
+
|
|
381
|
+
return _jsonrpc_error(req_id, -32601, f"Method not found: {method}")
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def _get_version() -> str:
|
|
385
|
+
try:
|
|
386
|
+
from avrotize._version import version
|
|
387
|
+
return version
|
|
388
|
+
except Exception:
|
|
389
|
+
return "dev"
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _run_stdio_loop() -> None:
|
|
393
|
+
"""Read JSON-RPC messages from stdin, write responses to stdout."""
|
|
394
|
+
reader = sys.stdin
|
|
395
|
+
writer = sys.stdout
|
|
396
|
+
for line in reader:
|
|
397
|
+
line = line.strip()
|
|
398
|
+
if not line:
|
|
399
|
+
continue
|
|
400
|
+
try:
|
|
401
|
+
msg = _json.loads(line)
|
|
402
|
+
except _json.JSONDecodeError:
|
|
403
|
+
resp = _jsonrpc_error(None, -32700, "Parse error")
|
|
404
|
+
writer.write(_json.dumps(resp) + "\n")
|
|
405
|
+
writer.flush()
|
|
406
|
+
continue
|
|
407
|
+
|
|
408
|
+
resp = _handle_message(msg)
|
|
409
|
+
if resp is not None:
|
|
410
|
+
writer.write(_json.dumps(resp) + "\n")
|
|
411
|
+
writer.flush()
|
|
412
|
+
|
|
413
|
+
|
|
230
414
|
def run_mcp_server(transport: str = "stdio"):
|
|
231
415
|
"""Run avrotize as a local MCP server.
|
|
232
416
|
|
|
233
|
-
|
|
417
|
+
Uses a lightweight built-in JSON-RPC stdio implementation by default.
|
|
418
|
+
"""
|
|
419
|
+
if transport != "stdio":
|
|
420
|
+
raise ValueError("Only 'stdio' transport is currently supported.")
|
|
421
|
+
_run_stdio_loop()
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def run_mcp_server_fastmcp(transport: str = "stdio"):
|
|
425
|
+
"""Run avrotize as a local MCP server using the ``mcp`` library.
|
|
426
|
+
|
|
427
|
+
This is slower to start (~2-3 s) because the ``mcp`` library eagerly
|
|
428
|
+
imports uvicorn, starlette, and httpx. Kept as a compatibility fallback.
|
|
234
429
|
"""
|
|
235
430
|
try:
|
|
236
431
|
from mcp.server.fastmcp import FastMCP
|
|
@@ -288,3 +483,16 @@ def run_mcp_server(transport: str = "stdio"):
|
|
|
288
483
|
mcp.run(transport="stdio")
|
|
289
484
|
except TypeError:
|
|
290
485
|
mcp.run()
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
# ---------------------------------------------------------------------------
|
|
489
|
+
# Direct entry point — bypasses the avrotize CLI argparse overhead.
|
|
490
|
+
# ---------------------------------------------------------------------------
|
|
491
|
+
|
|
492
|
+
def main() -> None:
|
|
493
|
+
"""Entry point for the ``avrotize-mcp`` console script."""
|
|
494
|
+
run_mcp_server("stdio")
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
if __name__ == "__main__":
|
|
498
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: structurize
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5.0
|
|
4
4
|
Summary: Tools to convert from and to JSON Structure from various other schema languages.
|
|
5
5
|
Author-email: Clemens Vasters <clemensv@microsoft.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -120,6 +120,7 @@ pyproject.toml
|
|
|
120
120
|
../avrotize/avrotots/package.json.jinja
|
|
121
121
|
../avrotize/avrotots/tsconfig.json.jinja
|
|
122
122
|
../avrotize/dependencies/cpp/vcpkg/vcpkg.json
|
|
123
|
+
../avrotize/dependencies/cs/net100/dependencies.csproj
|
|
123
124
|
../avrotize/dependencies/cs/net90/dependencies.csproj
|
|
124
125
|
../avrotize/dependencies/go/go121/go.mod
|
|
125
126
|
../avrotize/dependencies/java/jdk21/pom.xml
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|