@@ -175,8 +175,7 @@ def add_component_tools(mcp: FastMCP) -> None:
175
175
176
176
async def list_components (ctx : Context ) -> List [ComponentListItem ]:
177
177
"""Retrieve a list of all available Keboola components in the project."""
178
- client = ctx .session .state ["sapi_client" ]
179
- assert isinstance (client , KeboolaClient )
178
+ client = KeboolaClient .from_state (ctx .session .state )
180
179
181
180
r_components = client .storage_client .components .list ()
182
181
logger .info (f"Found { len (r_components )} components." )
@@ -192,9 +191,8 @@ async def list_component_configurations(
192
191
],
193
192
ctx : Context ,
194
193
) -> List [ComponentConfigurationListItem ]:
195
- """Retrieve all configurations that exist for a specific Keboola component."""
196
- client = ctx .session .state ["sapi_client" ]
197
- assert isinstance (client , KeboolaClient )
194
+ client = KeboolaClient .from_state (ctx .session .state )
195
+
198
196
199
197
component = await get_component_details (component_id , ctx )
200
198
r_configs = client .storage_client .configurations .list (component_id )
@@ -214,8 +212,8 @@ async def get_component_details(
214
212
ctx : Context ,
215
213
) -> Component :
216
214
"""Retrieve detailed information about a original Keboola component object given component ID."""
217
- client = ctx .session .state [ "sapi_client" ]
218
- assert isinstance ( client , KeboolaClient )
215
+ client = KeboolaClient . from_state ( ctx .session .state )
216
+
219
217
endpoint = "branch/{}/components/{}" .format (client .storage_client ._branch_id , component_id )
220
218
r_component = await client .get (endpoint )
221
219
return Component .model_validate (r_component )
0 commit comments