Verify visible hello MCP run and add shared control lease
This commit is contained in:
@@ -21,7 +21,8 @@ async def probe(socket: str, source: str, foreign_id: int):
|
||||
listed = await client.list_tools()
|
||||
names = {tool.name for tool in listed.tools}
|
||||
expected = {'session_status', 'where', 'read_registers', 'read_memory',
|
||||
'recent_events', 'set_line_breakpoint', 'clear_breakpoint'}
|
||||
'recent_events', 'set_line_breakpoint', 'clear_breakpoint',
|
||||
'claim_control', 'release_control'}
|
||||
if not expected <= names:
|
||||
raise RuntimeError('Не хватает MCP-инструментов: ' + str(expected - names))
|
||||
|
||||
@@ -39,6 +40,7 @@ async def probe(socket: str, source: str, foreign_id: int):
|
||||
memory = await call('read_memory', {'address': hex(location['pc']), 'length': 4})
|
||||
events = await call('recent_events', {'after': 0})
|
||||
if not status['build_id'] or location['status'] != 'mapped' or \
|
||||
not status['session_id'] or \
|
||||
registers['registers']['PC'] != location['pc'] or \
|
||||
len(memory['hex']) != 8 or not events['events']:
|
||||
raise RuntimeError('Неполный C-снимок MCP: ' + repr((status, location, memory)))
|
||||
@@ -47,10 +49,17 @@ async def probe(socket: str, source: str, foreign_id: int):
|
||||
foreign = await client.call_tool('clear_breakpoint', {'identifier': foreign_id})
|
||||
if not foreign.is_error or 'не принадлежит' not in str(foreign.content):
|
||||
raise RuntimeError('MCP не подтвердил защиту чужой точки VS Code')
|
||||
lease = await call('claim_control')
|
||||
if not lease['owner'].startswith('mcp:'):
|
||||
raise RuntimeError('MCP не захватил управление CPU: ' + repr(lease))
|
||||
released = await call('release_control')
|
||||
if released['released'] != lease['owner']:
|
||||
raise RuntimeError('MCP не освободил управление CPU: ' + repr(released))
|
||||
print(json.dumps({'event': 'mcp_shared_session_verified',
|
||||
'build_id': status['build_id'], 'pc': location['pc'],
|
||||
'tools': len(names), 'foreign_point_rejected': True,
|
||||
'owned_point_for_cleanup': own['id']},
|
||||
'owned_point_for_cleanup': own['id'],
|
||||
'control_claim_release': True},
|
||||
ensure_ascii=False), flush=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user