11from asgiref .sync import sync_to_async
2- from mcp import Tool
3- from mcp .types import TextContent
42from rest_framework .response import Response
53from starlette .status import HTTP_204_NO_CONTENT
64
@@ -23,6 +21,8 @@ class ListRowsMcpTool(MCPTool):
2321 name = "list_table_rows"
2422
2523 async def list (self , endpoint ):
24+ from mcp import Tool
25+
2626 return [
2727 Tool (
2828 name = self .name ,
@@ -64,6 +64,8 @@ async def call(
6464 name_parameters ,
6565 call_arguments ,
6666 ):
67+ from mcp .types import TextContent
68+
6769 table_id = call_arguments ["table_id" ]
6870 if not await sync_to_async (table_in_workspace_of_endpoint )(endpoint , table_id ):
6971 return [TextContent (type = "text" , text = "Table not in endpoint workspace." )]
@@ -92,6 +94,8 @@ class CreateRowMcpTool(MCPTool):
9294 name = "create_row_table_{id}"
9395
9496 async def list (self , endpoint ):
97+ from mcp import Tool
98+
9599 tables = await sync_to_async (get_all_tables )(endpoint )
96100 tables = await sync_to_async (remove_table_no_permission )(
97101 endpoint , tables , CreateRowDatabaseTableOperationType
@@ -127,6 +131,8 @@ async def call(
127131 name_parameters ,
128132 call_arguments ,
129133 ):
134+ from mcp .types import TextContent
135+
130136 table_id = name_parameters ["id" ]
131137 if not await sync_to_async (table_in_workspace_of_endpoint )(endpoint , table_id ):
132138 return [TextContent (type = "text" , text = "Table not in endpoint workspace." )]
@@ -148,6 +154,8 @@ class UpdateRowMcpTool(MCPTool):
148154 name = "update_row_table_{id}"
149155
150156 async def list (self , endpoint ):
157+ from mcp import Tool
158+
151159 tables = await sync_to_async (get_all_tables )(endpoint )
152160 tables = await sync_to_async (remove_table_no_permission )(
153161 endpoint , tables , UpdateDatabaseRowOperationType
@@ -187,6 +195,8 @@ async def call(
187195 name_parameters ,
188196 call_arguments ,
189197 ):
198+ from mcp .types import TextContent
199+
190200 table_id = name_parameters ["id" ]
191201 if not await sync_to_async (table_in_workspace_of_endpoint )(endpoint , table_id ):
192202 return [TextContent (type = "text" , text = "Table not in endpoint workspace." )]
@@ -211,6 +221,8 @@ class DeleteRowMcpTool(MCPTool):
211221 name = "delete_table_row"
212222
213223 async def list (self , endpoint ):
224+ from mcp import Tool
225+
214226 return [
215227 Tool (
216228 name = self .name ,
@@ -241,6 +253,8 @@ async def call(
241253 name_parameters ,
242254 call_arguments ,
243255 ):
256+ from mcp .types import TextContent
257+
244258 table_id = call_arguments ["table_id" ]
245259 if not await sync_to_async (table_in_workspace_of_endpoint )(endpoint , table_id ):
246260 return [TextContent (type = "text" , text = "Table not in endpoint workspace." )]
0 commit comments