2
2
from fastmcp import Context
3
3
4
4
from integtests .conftest import ConfigDef
5
- from keboola_mcp_server .client import KeboolaClient
5
+ from keboola_mcp_server .client import ORCHESTRATOR_COMPONENT_ID , KeboolaClient
6
+ from keboola_mcp_server .config import MetadataField
6
7
from keboola_mcp_server .tools .flow import (
7
8
FlowToolResponse ,
8
9
create_flow ,
@@ -55,6 +56,7 @@ async def test_create_and_retrieve_flow(mcp_context: Context, configs: list[Conf
55
56
tasks = tasks ,
56
57
)
57
58
flow_id = created .flow_id
59
+ client = KeboolaClient .from_state (mcp_context .session .state )
58
60
try :
59
61
assert isinstance (created , FlowToolResponse )
60
62
assert created .description == flow_description
@@ -68,8 +70,20 @@ async def test_create_and_retrieve_flow(mcp_context: Context, configs: list[Conf
68
70
assert detail .phases [0 ].name == 'Extract'
69
71
assert detail .phases [1 ].name == 'Transform'
70
72
assert detail .tasks [0 ].task ['componentId' ] == configs [0 ].component_id
73
+
74
+ # Verify the metadata - check that KBC.MCP.createdBy is set to 'true'
75
+ metadata = await client .storage_client .configuration_metadata_get (
76
+ component_id = ORCHESTRATOR_COMPONENT_ID ,
77
+ configuration_id = flow_id
78
+ )
79
+
80
+ # Convert metadata list to dictionary for easier checking
81
+ # metadata is a list of dicts with 'key' and 'value' keys
82
+ assert isinstance (metadata , list )
83
+ metadata_dict = {item ['key' ]: item ['value' ] for item in metadata if isinstance (item , dict )}
84
+ assert MetadataField .CREATED_BY_MCP in metadata_dict
85
+ assert metadata_dict [MetadataField .CREATED_BY_MCP ] == 'true'
71
86
finally :
72
- client = KeboolaClient .from_state (mcp_context .session .state )
73
87
await client .storage_client .flow_delete (flow_id , skip_trash = True )
74
88
75
89
@@ -106,6 +120,7 @@ async def test_update_flow(mcp_context: Context, configs: list[ConfigDef]) -> No
106
120
tasks = tasks ,
107
121
)
108
122
flow_id = created .flow_id
123
+ client = KeboolaClient .from_state (mcp_context .session .state )
109
124
try :
110
125
new_name = 'Updated Flow Name'
111
126
new_description = 'Updated description.'
@@ -123,8 +138,21 @@ async def test_update_flow(mcp_context: Context, configs: list[ConfigDef]) -> No
123
138
assert updated .description == new_description
124
139
assert updated .success is True
125
140
assert len (updated .links ) == 3
141
+
142
+ # Verify the metadata - check that KBC.MCP.updatedBy.version.{version} is set to 'true'
143
+ metadata = await client .storage_client .configuration_metadata_get (
144
+ component_id = ORCHESTRATOR_COMPONENT_ID ,
145
+ configuration_id = flow_id
146
+ )
147
+
148
+ assert isinstance (metadata , list )
149
+ metadata_dict = {item ['key' ]: item ['value' ] for item in metadata if isinstance (item , dict )}
150
+ sync_flow = await client .storage_client .flow_detail (flow_id )
151
+ updated_by_md_key = f'{ MetadataField .UPDATED_BY_MCP_PREFIX } { sync_flow ["version" ]} '
152
+ assert updated_by_md_key in metadata_dict
153
+ assert metadata_dict [updated_by_md_key ] == 'true'
154
+
126
155
finally :
127
- client = KeboolaClient .from_state (mcp_context .session .state )
128
156
await client .storage_client .flow_delete (flow_id , skip_trash = True )
129
157
130
158
0 commit comments