Skip to content

Commit 07ff712

Browse files
committed
fix: using proper json escaping for MCP tool descriptions (ref PR#63)
1 parent 48aa2ca commit 07ff712

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

nerve/tools/mcp/compiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import pathlib
44
import typing as t
5+
import json
56

67
import jinja2
78
from mcp import Tool
@@ -94,7 +95,7 @@ async def create_function_body(client: Client, mcp_tool: Tool) -> tuple[str, dic
9495
arg = {
9596
"name": name,
9697
"type": _stringify_type(arg_type),
97-
"description": arg_props.get("description", "").replace('\\', '\\\\').replace('"', '\\"'),
98+
"description": json.dumps(arg_props.get("description", "")).strip('"'),
9899
}
99100

100101
if args_def:

0 commit comments

Comments
 (0)