@@ -40,16 +40,15 @@ def add(a: int, b: int) -> int:
4040 "enabled" : True ,
4141 "parameters" : {
4242 "properties" : {
43- "a" : {"title" : "A" , " type" : "integer" },
44- "b" : {"title" : "B" , " type" : "integer" },
43+ "a" : {"type" : "integer" },
44+ "b" : {"type" : "integer" },
4545 },
4646 "required" : ["a" , "b" ],
4747 "type" : "object" ,
4848 },
4949 "output_schema" : {
50- "properties" : {"result" : {"title" : "Result" , " type" : "integer" }},
50+ "properties" : {"result" : {"type" : "integer" }},
5151 "required" : ["result" ],
52- "title" : "_WrappedResult" ,
5352 "type" : "object" ,
5453 "x-fastmcp-wrap-result" : True ,
5554 },
@@ -90,14 +89,13 @@ async def fetch_data(url: str) -> str:
9089 "tags" : set (),
9190 "enabled" : True ,
9291 "parameters" : {
93- "properties" : {"url" : {"title" : "Url" , " type" : "string" }},
92+ "properties" : {"url" : {"type" : "string" }},
9493 "required" : ["url" ],
9594 "type" : "object" ,
9695 },
9796 "output_schema" : {
98- "properties" : {"result" : {"title" : "Result" , " type" : "string" }},
97+ "properties" : {"result" : {"type" : "string" }},
9998 "required" : ["result" ],
100- "title" : "_WrappedResult" ,
10199 "type" : "object" ,
102100 "x-fastmcp-wrap-result" : True ,
103101 },
@@ -123,16 +121,15 @@ def __call__(self, x: int, y: int) -> int:
123121 "enabled" : True ,
124122 "parameters" : {
125123 "properties" : {
126- "x" : {"title" : "X" , " type" : "integer" },
127- "y" : {"title" : "Y" , " type" : "integer" },
124+ "x" : {"type" : "integer" },
125+ "y" : {"type" : "integer" },
128126 },
129127 "required" : ["x" , "y" ],
130128 "type" : "object" ,
131129 },
132130 "output_schema" : {
133- "properties" : {"result" : {"title" : "Result" , " type" : "integer" }},
131+ "properties" : {"result" : {"type" : "integer" }},
134132 "required" : ["result" ],
135- "title" : "_WrappedResult" ,
136133 "type" : "object" ,
137134 "x-fastmcp-wrap-result" : True ,
138135 },
@@ -157,16 +154,15 @@ async def __call__(self, x: int, y: int) -> int:
157154 "enabled" : True ,
158155 "parameters" : {
159156 "properties" : {
160- "x" : {"title" : "X" , " type" : "integer" },
161- "y" : {"title" : "Y" , " type" : "integer" },
157+ "x" : {"type" : "integer" },
158+ "y" : {"type" : "integer" },
162159 },
163160 "required" : ["x" , "y" ],
164161 "type" : "object" ,
165162 },
166163 "output_schema" : {
167- "properties" : {"result" : {"title" : "Result" , " type" : "integer" }},
164+ "properties" : {"result" : {"type" : "integer" }},
168165 "required" : ["result" ],
169- "title" : "_WrappedResult" ,
170166 "type" : "object" ,
171167 "x-fastmcp-wrap-result" : True ,
172168 },
@@ -196,17 +192,16 @@ def create_user(user: UserInput, flag: bool) -> dict:
196192 "$defs" : {
197193 "UserInput" : {
198194 "properties" : {
199- "name" : {"title" : "Name" , " type" : "string" },
200- "age" : {"title" : "Age" , " type" : "integer" },
195+ "name" : {"type" : "string" },
196+ "age" : {"type" : "integer" },
201197 },
202198 "required" : ["name" , "age" ],
203- "title" : "UserInput" ,
204199 "type" : "object" ,
205200 }
206201 },
207202 "properties" : {
208- "user" : {"$ref" : "#/$defs/UserInput" , "title" : "User" },
209- "flag" : {"title" : "Flag" , " type" : "boolean" },
203+ "user" : {"$ref" : "#/$defs/UserInput" },
204+ "flag" : {"type" : "boolean" },
210205 },
211206 "required" : ["user" , "flag" ],
212207 "type" : "object" ,
@@ -300,8 +295,8 @@ def add(_a: int, _b: int) -> int:
300295 "enabled" : True ,
301296 "parameters" : {
302297 "properties" : {
303- "_a" : {"title" : "A" , " type" : "integer" },
304- "_b" : {"title" : "B" , " type" : "integer" },
298+ "_a" : {"type" : "integer" },
299+ "_b" : {"type" : "integer" },
305300 },
306301 "required" : ["_a" , "_b" ],
307302 "type" : "object" ,
@@ -348,16 +343,15 @@ def add(self, x: int, y: int) -> int:
348343 "enabled" : True ,
349344 "parameters" : {
350345 "properties" : {
351- "x" : {"title" : "X" , " type" : "integer" },
352- "y" : {"title" : "Y" , " type" : "integer" },
346+ "x" : {"type" : "integer" },
347+ "y" : {"type" : "integer" },
353348 },
354349 "required" : ["x" , "y" ],
355350 "type" : "object" ,
356351 },
357352 "output_schema" : {
358- "properties" : {"result" : {"title" : "Result" , " type" : "integer" }},
353+ "properties" : {"result" : {"type" : "integer" }},
359354 "required" : ["result" ],
360- "title" : "_WrappedResult" ,
361355 "type" : "object" ,
362356 "x-fastmcp-wrap-result" : True ,
363357 },
@@ -467,9 +461,8 @@ def func() -> annotation: # type: ignore
467461 # Non-object types get wrapped
468462 expected_schema = {
469463 "type" : "object" ,
470- "properties" : {"result" : { ** base_schema , "title" : "Result" } },
464+ "properties" : {"result" : base_schema },
471465 "required" : ["result" ],
472- "title" : "_WrappedResult" ,
473466 "x-fastmcp-wrap-result" : True ,
474467 }
475468 assert tool .output_schema == expected_schema
@@ -495,9 +488,8 @@ def func() -> annotation: # type: ignore
495488 base_schema = TypeAdapter (annotation ).json_schema ()
496489 expected_schema = {
497490 "type" : "object" ,
498- "properties" : {"result" : { ** base_schema , "title" : "Result" } },
491+ "properties" : {"result" : base_schema },
499492 "required" : ["result" ],
500- "title" : "_WrappedResult" ,
501493 "x-fastmcp-wrap-result" : True ,
502494 }
503495 assert tool .output_schema == expected_schema
@@ -545,7 +537,9 @@ def func() -> Person:
545537 return Person (name = "John" , age = 30 )
546538
547539 tool = Tool .from_function (func )
548- expected_schema = compress_schema (TypeAdapter (Person ).json_schema ())
540+ expected_schema = compress_schema (
541+ TypeAdapter (Person ).json_schema (), prune_titles = True
542+ )
549543 assert tool .output_schema == expected_schema
550544
551545 async def test_base_model_return_annotation (self ):
@@ -561,11 +555,10 @@ def func() -> Person:
561555 assert tool .output_schema == snapshot (
562556 {
563557 "properties" : {
564- "name" : {"title" : "Name" , " type" : "string" },
565- "age" : {"title" : "Age" , " type" : "integer" },
558+ "name" : {"type" : "string" },
559+ "age" : {"type" : "integer" },
566560 },
567561 "required" : ["name" , "age" ],
568- "title" : "Person" ,
569562 "type" : "object" ,
570563 }
571564 )
@@ -582,11 +575,10 @@ def func() -> Person:
582575 assert tool .output_schema == snapshot (
583576 {
584577 "properties" : {
585- "name" : {"title" : "Name" , " type" : "string" },
586- "age" : {"title" : "Age" , " type" : "integer" },
578+ "name" : {"type" : "string" },
579+ "age" : {"type" : "integer" },
587580 },
588581 "required" : ["name" , "age" ],
589- "title" : "Person" ,
590582 "type" : "object" ,
591583 }
592584 )
@@ -766,9 +758,8 @@ def func() -> int:
766758 tool = Tool .from_function (func )
767759 assert tool .output_schema == snapshot (
768760 {
769- "properties" : {"result" : {"title" : "Result" , " type" : "integer" }},
761+ "properties" : {"result" : {"type" : "integer" }},
770762 "required" : ["result" ],
771- "title" : "_WrappedResult" ,
772763 "type" : "object" ,
773764 "x-fastmcp-wrap-result" : True ,
774765 }
@@ -839,9 +830,8 @@ def func() -> str:
839830 tool = Tool .from_function (func )
840831 assert tool .output_schema == snapshot (
841832 {
842- "properties" : {"result" : {"title" : "Result" , " type" : "string" }},
833+ "properties" : {"result" : {"type" : "string" }},
843834 "required" : ["result" ],
844- "title" : "_WrappedResult" ,
845835 "type" : "object" ,
846836 "x-fastmcp-wrap-result" : True ,
847837 }
@@ -1405,8 +1395,8 @@ def get_profile(user_id: str) -> UserProfile:
14051395 async with Client (mcp ) as client :
14061396 result = await client .call_tool ("get_profile" , {"user_id" : "456" })
14071397
1408- # Client should deserialize back to a dataclass (type name preserved with new compression )
1409- assert result .data .__class__ .__name__ == "UserProfile "
1398+ # Client should deserialize back to a dataclass (but type name is lost with title pruning )
1399+ assert result .data .__class__ .__name__ == "Root "
14101400 assert result .data .name == "Bob"
14111401 assert result .data .age == 25
14121402 assert result .data .verified is True
0 commit comments