88from fastmcp .prompts .prompt import Prompt
99from fastmcp .resources .resource import Resource
1010from fastmcp .tools .tool import Tool
11+ from fastmcp .utilities .types import get_fn_name
1112
1213if TYPE_CHECKING :
1314 from fastmcp .server import FastMCP
@@ -34,7 +35,7 @@ def mcp_tool(
3435
3536 def decorator (func : Callable [..., Any ]) -> Callable [..., Any ]:
3637 call_args = {
37- "name" : name or func . __name__ ,
38+ "name" : name or get_fn_name ( func ) ,
3839 "description" : description ,
3940 "tags" : tags ,
4041 "annotations" : annotations ,
@@ -63,7 +64,7 @@ def mcp_resource(
6364 def decorator (func : Callable [..., Any ]) -> Callable [..., Any ]:
6465 call_args = {
6566 "uri" : uri ,
66- "name" : name or func . __name__ ,
67+ "name" : name or get_fn_name ( func ) ,
6768 "description" : description ,
6869 "mime_type" : mime_type ,
6970 "tags" : tags ,
@@ -88,7 +89,7 @@ def mcp_prompt(
8889
8990 def decorator (func : Callable [..., Any ]) -> Callable [..., Any ]:
9091 call_args = {
91- "name" : name or func . __name__ ,
92+ "name" : name or get_fn_name ( func ) ,
9293 "description" : description ,
9394 "tags" : tags ,
9495 "enabled" : enabled ,
@@ -146,7 +147,21 @@ def register_tools(
146147 registration_info ["name" ] = (
147148 f"{ prefix } { separator } { registration_info ['name' ]} "
148149 )
149- tool = Tool .from_function (fn = method , ** registration_info )
150+
151+ tool = Tool .from_function (
152+ fn = method ,
153+ name = registration_info .get ("name" ),
154+ title = registration_info .get ("title" ),
155+ description = registration_info .get ("description" ),
156+ tags = registration_info .get ("tags" ),
157+ annotations = registration_info .get ("annotations" ),
158+ exclude_args = registration_info .get ("exclude_args" ),
159+ serializer = registration_info .get ("serializer" ),
160+ output_schema = registration_info .get ("output_schema" ),
161+ meta = registration_info .get ("meta" ),
162+ enabled = registration_info .get ("enabled" ),
163+ )
164+
150165 mcp_server .add_tool (tool )
151166
152167 def register_resources (
@@ -175,7 +190,19 @@ def register_resources(
175190 registration_info ["uri" ] = (
176191 f"{ prefix } { separator } { registration_info ['uri' ]} "
177192 )
178- resource = Resource .from_function (fn = method , ** registration_info )
193+
194+ resource = Resource .from_function (
195+ fn = method ,
196+ uri = registration_info ["uri" ],
197+ name = registration_info .get ("name" ),
198+ description = registration_info .get ("description" ),
199+ mime_type = registration_info .get ("mime_type" ),
200+ tags = registration_info .get ("tags" ),
201+ enabled = registration_info .get ("enabled" ),
202+ annotations = registration_info .get ("annotations" ),
203+ meta = registration_info .get ("meta" ),
204+ )
205+
179206 mcp_server .add_resource (resource )
180207
181208 def register_prompts (
@@ -200,7 +227,15 @@ def register_prompts(
200227 registration_info ["name" ] = (
201228 f"{ prefix } { separator } { registration_info ['name' ]} "
202229 )
203- prompt = Prompt .from_function (fn = method , ** registration_info )
230+ prompt = Prompt .from_function (
231+ fn = method ,
232+ name = registration_info .get ("name" ),
233+ title = registration_info .get ("title" ),
234+ description = registration_info .get ("description" ),
235+ tags = registration_info .get ("tags" ),
236+ enabled = registration_info .get ("enabled" ),
237+ meta = registration_info .get ("meta" ),
238+ )
204239 mcp_server .add_prompt (prompt )
205240
206241 def register_all (
0 commit comments