okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
a16109803
main
1// A minimal MCP server over stdio (newline-delimited JSON-RPC), for the tool-server test. One tool, `shout`: it upper-cases 2// its text and reports whether the secret from the environment arrived, WITHOUT printing the secret. 3import { createInterface } from 'node:readline' ; 4 5const send = message => process . stdout . write ( ` ${ JSON . stringify ({ jsonrpc : '2.0' , ... message })} \n` ); 6createInterface ({ input :process . stdin }). on ( 'line' , line => { 7let m ; try { m = JSON . parse ( line ); } catch { return ; } 8if ( m . method === 'initialize' ) { 9send ({ id :m . id , result :{ protocolVersion :m . params ?. protocolVersion ?? '2025-06-18' , capabilities :{ tools :{ listChanged :false } }, serverInfo :{ name :'mini' , version :'1.0.0' } } }); 10} else if ( m . method === 'tools/list' ) { 11send ({ id :m . id , result :{ tools :[{ name :'shout' , description :'Upper-case the text.' , inputSchema :{ type :'object' , properties :{ text :{ type :'string' } }, required :[ 'text' ] } }] } }); 12} else if ( m . method === 'tools/call' ) { 13const text = String ( m . params ?. arguments ?. text ?? '' ); 14send ({ id :m . id , result :{ content :[{ type :'text' , text :` ${ text . toUpperCase ()} |token: ${ process . env . DEMO_TOKEN ? 'set' : 'missing' } ` }] } }); 15} else if ( m . id !== undefined && m . method ) { 16send ({ id :m . id , result :{} }); 17} 18});