Verify visible hello MCP run and add shared control lease
This commit is contained in:
@@ -96,6 +96,8 @@ def main():
|
||||
parser.add_argument('--launch-path', default=None)
|
||||
parser.add_argument('--mcp-python', default=None,
|
||||
help='Python 3.12 с MCP SDK 2.x для совместной живой пробы DAP/MCP')
|
||||
parser.add_argument('--orphan-expiry', action='store_true',
|
||||
help='проверить очистку точки владельца MCP без heartbeat через 30 с')
|
||||
parser.add_argument('--clear-while-running', action='store_true',
|
||||
help='во время WAITKEY удалить личную точку; использовать с --waitkey --emulated-key')
|
||||
parser.add_argument('--exit-while-stopped', action='store_true',
|
||||
@@ -152,6 +154,29 @@ def main():
|
||||
capture_output=True, text=True, timeout=45, check=False)
|
||||
if probe.returncode:
|
||||
raise RuntimeError('MCP SDK probe: '+probe.stderr[-4000:])
|
||||
if options.orphan_expiry:
|
||||
owner = 'mcp:orphan-expiry-probe'
|
||||
orphan = rpc_call(launched['body']['socket'], 'break_line', {
|
||||
'file': source, 'line': 62, 'owner': owner})
|
||||
rpc_call(launched['body']['socket'], 'claim_control', {'owner': owner})
|
||||
print('Ожидание истечения MCP owner и очистки его точки...', flush=True)
|
||||
deadline = time.monotonic()+36
|
||||
while time.monotonic() < deadline:
|
||||
events = rpc_call(launched['body']['socket'], 'events', {'after': 0})
|
||||
if any(event['event'] == 'owner_expired' and
|
||||
event['body']['owner'] == owner for event in events['events']):
|
||||
break
|
||||
time.sleep(.5)
|
||||
else:
|
||||
raise RuntimeError('MCP owner не истёк за 36 с')
|
||||
try:
|
||||
rpc_call(launched['body']['socket'], 'clear_breakpoint', {
|
||||
'id': orphan['id'], 'owner': owner})
|
||||
except SessionError as error:
|
||||
if 'Неизвестная логическая точка' not in str(error):
|
||||
raise
|
||||
else:
|
||||
raise RuntimeError('MCP orphan-точка не была очищена')
|
||||
send(process, 6, 'continue')
|
||||
_, buffer, _ = wait_response(process, buffer, 'continue', 10)
|
||||
stopped, buffer = wait_event(process, buffer, 'stopped', 20)
|
||||
@@ -170,6 +195,9 @@ def main():
|
||||
if stale:
|
||||
raise RuntimeError('Точка MCP осталась после закрытия stdio-клиента')
|
||||
print(probe.stdout.strip(), flush=True)
|
||||
if options.orphan_expiry:
|
||||
print(json.dumps({'event': 'mcp_orphan_expired_and_cleared',
|
||||
'id': orphan['id']}, ensure_ascii=False), flush=True)
|
||||
send(process, 10, 'disconnect')
|
||||
wait_response(process, buffer, 'disconnect', 10)
|
||||
if options.socket:
|
||||
|
||||
Reference in New Issue
Block a user