Fix background MCP input and add mirror dungeon feedback records

Browse Source
This commit is contained in:
Codex Agent
2026-10-02 13:58:43 +08:00
parent a4b27f991c
commit da7dcefadd
45 changed files with 6180 additions and 9 deletions
+45
View File
@@ -0,0 +1,45 @@
"""Exercise the installed stdio bridge with an actual MCP handshake and tool call."""
import argparse
import json
import os
import subprocess
import sys
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('tool', nargs='?', default='get_state')
parser.add_argument('arguments', nargs='?', default='{}')
parser.add_argument('--timeout', type=float, default=30)
args = parser.parse_args()
arguments = json.loads(args.arguments)
root = Path(__file__).resolve().parents[1]
requests = [
{'jsonrpc': '2.0', 'id': 1, 'method': 'initialize', 'params': {
'protocolVersion': '2024-11-05', 'capabilities': {},
'clientInfo': {'name': 'lc-mcp-probe', 'version': '1'}}},
{'jsonrpc': '2.0', 'method': 'notifications/initialized'},
{'jsonrpc': '2.0', 'id': 2, 'method': 'tools/list'},
{'jsonrpc': '2.0', 'id': 3, 'method': 'tools/call',
'params': {'name': args.tool, 'arguments': arguments}},
]
process = subprocess.run(
[sys.executable, '-X', 'utf8', str(root / 'lc_mcp' / 'bridge.py')],
cwd=root, env=dict(os.environ, PYTHONUTF8='1'),
input=''.join(json.dumps(r, ensure_ascii=False) + '\n' for r in requests),
capture_output=True, text=True, encoding='utf-8', timeout=args.timeout,
)
responses = [json.loads(line) for line in process.stdout.splitlines() if line.strip()]
response = next((r for r in responses if r.get('id') == 3), None)
if process.returncode or not response or 'error' in response:
print(json.dumps({'ok': False, 'response': response, 'stderr': process.stderr}, ensure_ascii=False))
return 1
result = response['result']
data = json.loads(result['content'][0]['text'])
print(json.dumps(data, ensure_ascii=False))
return 1 if result.get('isError') else 0
if __name__ == '__main__':
sys.exit(main())