Skip to content

Commit 0d6141e

Browse files
author
Chojan Shang
committed
fix: make everything happy
Signed-off-by: Chojan Shang <chojan.shang@vesoft.com>
1 parent 508b822 commit 0d6141e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

scripts/gen_schema.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
re.DOTALL,
2626
)
2727

28+
STDIO_TYPE_LITERAL = 'Literal["2#-datamodel-code-generator-#-object-#-special-#"]'
29+
STDIO_TYPE_PATTERN = re.compile(
30+
r"^ type:\s*Literal\[['\"]2#-datamodel-code-generator-#-object-#-special-#['\"]\]"
31+
r"(?:\s*=\s*['\"][^'\"]+['\"])?\s*$",
32+
re.MULTILINE,
33+
)
34+
2835
# Map of numbered classes produced by datamodel-code-generator to descriptive names.
2936
# Keep this in sync with the Rust/TypeScript SDK nomenclature.
3037
RENAME_MAP: dict[str, str] = {
@@ -198,6 +205,7 @@ def rename_types(output_path: Path) -> list[str]:
198205
header_block = "\n".join(header_lines) + "\n\n"
199206
content = _apply_field_overrides(content)
200207
content = _apply_default_overrides(content)
208+
content = _normalize_stdio_model(content)
201209
content = _add_description_comments(content)
202210
content = _ensure_custom_base_model(content)
203211

@@ -323,6 +331,19 @@ def replace_block(
323331
return content
324332

325333

334+
def _normalize_stdio_model(content: str) -> str:
335+
replacement_line = ' type: Literal["stdio"] = "stdio"'
336+
new_content, count = STDIO_TYPE_PATTERN.subn(replacement_line, content)
337+
if count == 0:
338+
return content
339+
if count > 1:
340+
print(
341+
"Warning: multiple stdio type placeholders detected; manual review required.",
342+
file=sys.stderr,
343+
)
344+
return new_content
345+
346+
326347
def _add_description_comments(content: str) -> str:
327348
lines = content.splitlines()
328349
new_lines: list[str] = []

src/acp/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class StdioMcpServer(BaseModel):
244244
]
245245
# Human-readable name identifying this MCP server.
246246
name: Annotated[str, Field(description="Human-readable name identifying this MCP server.")]
247-
type: Literal["2#-datamodel-code-generator-#-object-#-special-#"]
247+
type: Literal["stdio"] = "stdio"
248248

249249

250250
class ModelInfo(BaseModel):

0 commit comments

Comments
 (0)