Skip to content

Commit 7442b27

Browse files
committed
fix: Write serve command banner to stderr instead of stdout
The serve command without --mcp prints a help banner. Writing this to stdout breaks MCP stdio clients (like Cursor) that expect only JSON-RPC on stdout. Move all banner output to stderr so stdout stays clean. Fixes colbymchenry#43
1 parent 7f516b9 commit 7442b27

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/bin/codegraph.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -922,11 +922,12 @@ program
922922
await server.start();
923923
// Server will run until terminated
924924
} else {
925-
// Default: show info about MCP mode
926-
console.log(chalk.bold('\nCodeGraph MCP Server\n'));
927-
info('Use --mcp flag to start the MCP server');
928-
console.log('\nTo use with Claude Code, add to your MCP configuration:');
929-
console.log(chalk.dim(`
925+
// Default: show info about MCP mode.
926+
// Use stderr so stdout stays clean for any piped/stdio usage.
927+
console.error(chalk.bold('\nCodeGraph MCP Server\n'));
928+
console.error(chalk.blue('ℹ') + ' Use --mcp flag to start the MCP server');
929+
console.error('\nTo use with Claude Code, add to your MCP configuration:');
930+
console.error(chalk.dim(`
930931
{
931932
"mcpServers": {
932933
"codegraph": {
@@ -936,15 +937,15 @@ program
936937
}
937938
}
938939
`));
939-
console.log('Available tools:');
940-
console.log(chalk.cyan(' codegraph_search') + ' - Search for code symbols');
941-
console.log(chalk.cyan(' codegraph_context') + ' - Build context for a task');
942-
console.log(chalk.cyan(' codegraph_callers') + ' - Find callers of a symbol');
943-
console.log(chalk.cyan(' codegraph_callees') + ' - Find what a symbol calls');
944-
console.log(chalk.cyan(' codegraph_impact') + ' - Analyze impact of changes');
945-
console.log(chalk.cyan(' codegraph_node') + ' - Get symbol details');
946-
console.log(chalk.cyan(' codegraph_files') + ' - Get project file structure');
947-
console.log(chalk.cyan(' codegraph_status') + ' - Get index status');
940+
console.error('Available tools:');
941+
console.error(chalk.cyan(' codegraph_search') + ' - Search for code symbols');
942+
console.error(chalk.cyan(' codegraph_context') + ' - Build context for a task');
943+
console.error(chalk.cyan(' codegraph_callers') + ' - Find callers of a symbol');
944+
console.error(chalk.cyan(' codegraph_callees') + ' - Find what a symbol calls');
945+
console.error(chalk.cyan(' codegraph_impact') + ' - Analyze impact of changes');
946+
console.error(chalk.cyan(' codegraph_node') + ' - Get symbol details');
947+
console.error(chalk.cyan(' codegraph_files') + ' - Get project file structure');
948+
console.error(chalk.cyan(' codegraph_status') + ' - Get index status');
948949
}
949950
} catch (err) {
950951
captureException(err);

0 commit comments

Comments
 (0)