code wiki / (root) / nx_mcp_sse_live_gate_t316.nx

nx_mcp_sse_live_gate_t316.nx source

↩ module page · 32 lines · 2468 B

1import "nx_mcp_authenticated_gate.nx" 2// Read-only finite SSE compatibility qualification for the existing served endpoint. 3// Uses the existing native stdin/stdout fixture; no secret bytes are read by this gate. 4func main(argc:i64,argv:*i64)->i64{ 5 if argc!=2&&argc!=3{return 2} 6 let c:*i64=gv_ctr();gv_head("MCP-NATIVE-SSE-LIVE") 7 let prefix:*u8=sys_mmap(256);var z:i64=mpe_cat(prefix,0,"/tmp/nishi-mcp-sse-live-");z=mpe_catn(prefix,z,sys_now_ms());prefix[z]=0 as u8 8 var credential:*u8=argv[1] as *u8 9 if argc==3{ 10 var file:NxCapFile 11 if cm_file_read(credential,&file)!=0{return 3} 12 var verdict:i64=0;let reply:*NxValue=nx_value_parse_json(file.bytes,file.length,&verdict) 13 var exp:i64=0 14 if verdict!=NX_VAL_PARSE_OK{cm_file_close(&file);return 3} 15 if nx_value_object_get_int(reply,"exp",3,&exp)!=1{cm_file_close(&file);return 3} 16 cm_file_close(&file) 17 credential=mhg_path(prefix,".scoped.cap") 18 let extract:i64=mag_reply_cap(argv[1] as *u8,credential,exp,cm_atoi(argv[2] as *u8)) 19 if extract!=0{gv_kv("private_handoff_error",extract);return 3} 20 } 21 let request:*u8="{\"jsonrpc\":\"2.0\",\"id\":\"sse-live-a\",\"method\":\"tools/call\",\"params\":{\"name\":\"nx_fs\",\"arguments\":{\"argv\":[\"size\",\"buildroot/knowledge/gates/shared-adoption-t315.json\"]}}}\n{\"jsonrpc\":\"2.0\",\"id\":\"sse-live-b\",\"method\":\"tools/call\",\"params\":{\"name\":\"nx_fs\",\"arguments\":{\"argv\":[\"size\",\"buildroot/knowledge/gates/shared-adoption-t315.json\"]}}}\n" 22 let b:*u8=sys_mmap(16384);var n:i64=0 23 let rc:i64=mhg_run("_build/nx_mcp_stdio_sse_t316.sov.elf","https://nishifamily.com",prefix,credential,request,b,&n) 24 gv_check("native bridge exits successfully",rc==0,c) 25 gv_check("two notification and result pairs are JSON lines",mhg_lines(b,n)==4,c) 26 gv_check("tools changed notification forwarded",mhg_has(b,n,"notifications/tools/list_changed")==1,c) 27 gv_check("both request IDs preserved",mhg_has(b,n,"\"id\":\"sse-live-a\"")==1&&mhg_has(b,n,"\"id\":\"sse-live-b\"")==1,c) 28 gv_check("live file result and no protocol error",mhg_has(b,n,"NX-FS-SIZE buildroot/knowledge/gates/shared-adoption-t315.json bytes=2843 exact=1")==1&&mhg_has(b,n,"\"error\":")==0,c) 29 gv_kv("bridge_exit",rc);gv_kv("protocol_bytes",n) 30 gv_puts("retained_fixture_prefix=");gv_puts(prefix);gv_puts("\n");sys_write(1,b,n) 31 return gv_verdict("MCP-NATIVE-SSE-LIVE",c,"Actual finite SSE endpoint compatibility through the compiled stdio bridge; no full protocol conformance claim.") 32}