Skip to content

Commit 50ea091

Browse files
Refactor MCP decorators and imports, improve type hints
Co-authored-by: itay.dar <itay.dar@lemonade.com>
1 parent 0bda5c3 commit 50ea091

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

nest/common/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from nest.common.mcp_resolver import MCPResolver
1+

nest/common/module.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from typing import Any, List, Type
66
from uuid import uuid4
77

8-
from nest.core import Module
9-
108

119
class ModulesContainer(dict):
1210
def __init__(self):
@@ -104,10 +102,10 @@ def distance(self):
104102
def distance(self, value):
105103
self._distance = value
106104

107-
def add_import(self, module_ref: Module):
105+
def add_import(self, module_ref: "Module"):
108106
self._imports.add(module_ref)
109107

110-
def add_imports(self, module_ref: List[Module]):
108+
def add_imports(self, module_ref: List["Module"]):
111109
for module in module_ref:
112110
self.add_import(module)
113111

nest/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from nest.core.pynest_container import PyNestContainer
1717
from nest.core.pynest_factory import PyNestFactory
1818

19-
# MCP exports
19+
# MCP application and factory (safe: fastmcp is lazily imported when used)
2020
from nest.core.pynest_mcp_application import PyNestMCPApp
2121
from nest.core.mcp_factory import MCPFactory
2222

2323
# MCP decorators
24-
from nest.core.decorators.mcp.mcp_decorators import (
24+
from nest.core.decorators.mcp import (
2525
McpController,
2626
McpTool,
2727
McpResource,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from nest.core.decorators.mcp.mcp_decorators import McpController, McpTool, McpResource, McpPrompt

nest/core/decorators/mcp/mcp_decorators.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from nest.core.decorators.utils import get_instance_variables, parse_dependencies
24

35

@@ -22,7 +24,7 @@ def decorator(cls):
2224
return decorator
2325

2426

25-
def McpTool(name: str | None = None, **kwargs):
27+
def McpTool(name: Optional[str] = None, **kwargs):
2628
def decorator(func):
2729
metadata = {"name": name}
2830
metadata.update(kwargs)
@@ -44,7 +46,7 @@ def decorator(func):
4446
return decorator
4547

4648

47-
def McpPrompt(name: str | None = None, **kwargs):
49+
def McpPrompt(name: Optional[str] = None, **kwargs):
4850
def decorator(func):
4951
metadata = {"name": name}
5052
metadata.update(kwargs)

0 commit comments

Comments
 (0)