From 4456188af07cb53d3dfb5741c76411c4fe562ec6 Mon Sep 17 00:00:00 2001 From: Guillaume Olivieri <31344086+Odysseus-deep@users.noreply.github.com> Date: Tue, 6 May 2025 12:39:36 +0200 Subject: [PATCH] fix: send startup logs to stderr to keep stdout JSON-only (#7) --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 4 +++- src/index.ts | 12 ++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..50022f8dbafeb83ddffb390b0b4a900e567a9359 GIT binary patch literal 6148 zcmeHK-AcnS6i&A3GKSC#MK1&14&0Q1!<$m)3s}($mD$>%#oCN^vlnB~TYVwl#OLvx zBn8KIE#l6BM`ap#soA(j>;NA_u5d+CL?kjBcFtc3c>meCpPxi z0l&S@a+a~ju=x4?Nt{o+-7j9NH@3E$qAA+q-hWnwKMkg{+zYZ>w62s&!b%Uq>v&v@ zoZWMkPJ=idXSyJc#*lJ%6Q_|XJT*(BT-W+0AX=g|a`xx*UjL*cPy36GoDYt>s16p3 zme@NyI=dXbB(JG@H*9hsTg#5c3O+!wi+S_2G*Rgjc&h9wi;x%~28aP-V8a=(2ZLyD zI1jXZVt^P}WdQdF2@TP;SQ^w@2XuIS#&`n}1$2B%AWDm_#nK=|K)5LdG^N}=F}NuQ zzqEO-#nPZDXI#$=> literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore index 7f106e9..8dd9545 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules/ build/ *.log -.env* \ No newline at end of file +.env* +# Do not push Morgan prompts +src/Morgan/prompts/ diff --git a/src/index.ts b/src/index.ts index 49bb095..57033e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,8 +117,8 @@ for (const definition of toolDefinitions) { }); indexes.set(definition.toolName!, index); - console.log( - `Created index for tool ${definition.toolName}: ${definition.indexName} - ${definition.description}`, + process.stderr.write( + `Created index for tool ${definition.toolName}: ${definition.indexName} - ${definition.description}\n`, ); } @@ -185,9 +185,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { * This allows the server to communicate via standard input/output streams. */ async function main() { - console.log(`Starting MCP server with ${toolDefinitions.length} tools:`); + process.stderr.write( + `Starting MCP server with ${toolDefinitions.length} tools:\n`, + ); toolDefinitions.forEach((def) => { - console.log(`- ${def.toolName}: ${def.indexName} - ${def.description}`); + process.stderr.write( + `- ${def.toolName}: ${def.indexName} - ${def.description}\n`, + ); }); const transport = new StdioServerTransport();