Skip to content

Conversation

@keremgocen
Copy link
Contributor

@keremgocen keremgocen commented Nov 13, 2025

Introduce a logging service to enhance error handling and debugging capabilities across various components of the application. Update configuration to include log level and format, and ensure that logging is integrated into the server and tool dependencies.

WIP: only integrated for the get-schema tool for now. Tests to follow.

Part 1: (in this PR)

  • covers the foundations, a logger service with log levels from the MCP spec
  • An MCP server hook allows MCP clients to set the level
  • log format and output are decided at the start via env variables (although VSCode MCP client sets it to INFO and I could not find a way to change it)
  • logger only implemented for the get-schema tool for now implemented for all tools
  • added basic test coverage

Part 2: (not in this PR)

  • Add a redaction mechanism to remove sensitive data
  • Add test coverage

https://linear.app/neo4j/issue/DEVSURF-806/design-and-create-logger-to-handle-logging-in-the-mcp-server

}

// Initialize logger
log := logger.New(cfg.LogLevel, cfg.LogFormat, os.Stderr)
Copy link
Contributor Author

@keremgocen keremgocen Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially we can set the level, format and the output stream, as long as it implements the io.Writer interface.

@keremgocen keremgocen changed the title Implement logging changes throughout the application Implement unified logger with log level - part 1 Nov 13, 2025
})

t.Run("all log levels can be set dynamically", func(t *testing.T) {
levels := []string{"debug", "info", "notice", "warn", "warning", "error", "critical", "alert", "emergency"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably won't need this many levels, but it's in the spec https://modelcontextprotocol.io/specification/draft/server/utilities/logging#log-levels

@keremgocen keremgocen marked this pull request as ready for review November 14, 2025 16:02
Params := args.Params

log.Printf("cypher-query: %s", Query)
deps.Log.Info("executing read cypher query", "query", Query)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this as a debug instead, but VSCode MCP client is setting the log level to Info and I could not find a way to change that. Not sure if we want cypher queries to be logged all the time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants