Skip to content

Commit 2843e0a

Browse files
committed
minor changes to reduce diff noise
1 parent 3884e63 commit 2843e0a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/mcp/server/fastmcp/utilities/func_metadata.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ def func_metadata(
171171
- TypedDict - converted to a Pydantic model with same fields
172172
- NamedTuple - converted to a Pydantic model with same fields
173173
- Dataclasses and other annotated classes - converted to Pydantic models
174-
- Generic types (list, dict, Union, etc.) - wrapped in a model with a
175-
'result' field
174+
- Generic types (list, dict, Union, etc.) - wrapped in a model with a 'result' field
176175
Raises InvalidSignature if the return type has no annotations.
177176
Returns:
178177
A FuncMetadata object containing:
@@ -206,14 +205,18 @@ def func_metadata(
206205
WithJsonSchema({"title": param.name, "type": "string"}),
207206
]
208207

209-
output_info = FieldInfo.from_annotated_attribute(
208+
field_info = FieldInfo.from_annotated_attribute(
210209
_get_typed_annotation(annotation, globalns),
211210
param.default if param.default is not inspect.Parameter.empty else PydanticUndefined,
212211
)
213-
dynamic_pydantic_model_params[param.name] = (output_info.annotation, output_info)
212+
dynamic_pydantic_model_params[param.name] = (field_info.annotation, field_info)
214213
continue
215214

216-
arguments_model = create_model(f"{func.__name__}Arguments", **dynamic_pydantic_model_params, __base__=ArgModelBase)
215+
arguments_model = create_model(
216+
f"{func.__name__}Arguments",
217+
**dynamic_pydantic_model_params,
218+
__base__=ArgModelBase,
219+
)
217220

218221
output_model = None
219222
output_conversion = "none"

src/mcp/server/lowlevel/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,19 @@ def decorator(
405405

406406
async def handler(req: types.CallToolRequest):
407407
try:
408-
result = await func(req.params.name, (req.params.arguments or {}))
408+
results = await func(req.params.name, (req.params.arguments or {}))
409409

410-
if isinstance(result, dict):
411-
json_content = pydantic_core.to_json(result, fallback=str, indent=2).decode()
410+
if isinstance(results, dict):
411+
json_content = pydantic_core.to_json(results, fallback=str, indent=2).decode()
412412
return types.ServerResult(
413413
types.CallToolResult(
414414
content=[types.TextContent(type="text", text=json_content)],
415-
structuredContent=cast(dict[str, Any], result),
415+
structuredContent=cast(dict[str, Any], results),
416416
isError=False,
417417
)
418418
)
419419
else:
420-
return types.ServerResult(types.CallToolResult(content=list(result), isError=False))
420+
return types.ServerResult(types.CallToolResult(content=list(results), isError=False))
421421
except Exception as e:
422422
return types.ServerResult(
423423
types.CallToolResult(

0 commit comments

Comments
 (0)