fix: send startup logs to stderr to keep stdout JSON-only (#7)

This commit is contained in:
Guillaume Olivieri
2025-05-06 12:39:36 +02:00
committed by GitHub
parent 5b07690eca
commit 4456188af0
3 changed files with 11 additions and 5 deletions
Vendored
BIN
View File
Binary file not shown.
+3 -1
View File
@@ -1,4 +1,6 @@
node_modules/ node_modules/
build/ build/
*.log *.log
.env* .env*
# Do not push Morgan prompts
src/Morgan/prompts/
+8 -4
View File
@@ -117,8 +117,8 @@ for (const definition of toolDefinitions) {
}); });
indexes.set(definition.toolName!, index); indexes.set(definition.toolName!, index);
console.log( process.stderr.write(
`Created index for tool ${definition.toolName}: ${definition.indexName} - ${definition.description}`, `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. * This allows the server to communicate via standard input/output streams.
*/ */
async function main() { 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) => { 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(); const transport = new StdioServerTransport();