Spaces:
Running
Running
Ryan Malloy commited on
Update mcp_mixin.py to include enabled, annotations, excluded_args, serializer
Browse filesannotations: ToolAnnotations | None = None,
exclude_args: list[str] | None = None,
serializer: Callable[[Any], str] | None = None,
enabled: bool | None = None,
src/fastmcp/contrib/mcp_mixin/mcp_mixin.py
CHANGED
|
@@ -23,6 +23,10 @@ def mcp_tool(
|
|
| 23 |
name: str | None = None,
|
| 24 |
description: str | None = None,
|
| 25 |
tags: set[str] | None = None,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
| 27 |
"""Decorator to mark a method as an MCP tool for later registration."""
|
| 28 |
|
|
@@ -31,6 +35,10 @@ def mcp_tool(
|
|
| 31 |
"name": name or func.__name__,
|
| 32 |
"description": description,
|
| 33 |
"tags": tags,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|
| 36 |
setattr(func, _MCP_REGISTRATION_TOOL_ATTR, call_args)
|
|
@@ -46,6 +54,7 @@ def mcp_resource(
|
|
| 46 |
description: str | None = None,
|
| 47 |
mime_type: str | None = None,
|
| 48 |
tags: set[str] | None = None,
|
|
|
|
| 49 |
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
| 50 |
"""Decorator to mark a method as an MCP resource for later registration."""
|
| 51 |
|
|
@@ -56,6 +65,7 @@ def mcp_resource(
|
|
| 56 |
"description": description,
|
| 57 |
"mime_type": mime_type,
|
| 58 |
"tags": tags,
|
|
|
|
| 59 |
}
|
| 60 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|
| 61 |
|
|
@@ -78,6 +88,7 @@ def mcp_prompt(
|
|
| 78 |
"name": name or func.__name__,
|
| 79 |
"description": description,
|
| 80 |
"tags": tags,
|
|
|
|
| 81 |
}
|
| 82 |
|
| 83 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|
|
|
|
| 23 |
name: str | None = None,
|
| 24 |
description: str | None = None,
|
| 25 |
tags: set[str] | None = None,
|
| 26 |
+
annotations: ToolAnnotations | None = None,
|
| 27 |
+
exclude_args: list[str] | None = None,
|
| 28 |
+
serializer: Callable[[Any], str] | None = None,
|
| 29 |
+
enabled: bool | None = None,
|
| 30 |
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
| 31 |
"""Decorator to mark a method as an MCP tool for later registration."""
|
| 32 |
|
|
|
|
| 35 |
"name": name or func.__name__,
|
| 36 |
"description": description,
|
| 37 |
"tags": tags,
|
| 38 |
+
"annotations": annotations,
|
| 39 |
+
"exclude_args": exclude_args,
|
| 40 |
+
"serializer": serializer,
|
| 41 |
+
"enabled": enabled,
|
| 42 |
}
|
| 43 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|
| 44 |
setattr(func, _MCP_REGISTRATION_TOOL_ATTR, call_args)
|
|
|
|
| 54 |
description: str | None = None,
|
| 55 |
mime_type: str | None = None,
|
| 56 |
tags: set[str] | None = None,
|
| 57 |
+
enabled: bool | None = None,
|
| 58 |
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
| 59 |
"""Decorator to mark a method as an MCP resource for later registration."""
|
| 60 |
|
|
|
|
| 65 |
"description": description,
|
| 66 |
"mime_type": mime_type,
|
| 67 |
"tags": tags,
|
| 68 |
+
"enabled": enabled,
|
| 69 |
}
|
| 70 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|
| 71 |
|
|
|
|
| 88 |
"name": name or func.__name__,
|
| 89 |
"description": description,
|
| 90 |
"tags": tags,
|
| 91 |
+
"enabled": enabled,
|
| 92 |
}
|
| 93 |
|
| 94 |
call_args = {k: v for k, v in call_args.items() if v is not None}
|