Skip to content

Conversation

@cliffhall
Copy link
Member

  • This fixes Add log level setting in UI #188
  • In App.tsx
    • import LoggingLevel from sdk
    • add [logLevel, setLogLevel] useState with value of type LoggingLevel initialized to "debug"
    • add useEffect that stores the new logLevel in localStorage as "logLevel"
    • added sendLogLevelRequest function that takes a level argument of type LoggingLevel and sends the appropriate request. It calls setLogLevel when done, to update the local UI
    • pass logLevel and sendLogLevelRequest to Sidebar component as props
  • In Sidebar.tsx
    • Import LoggingLevel and LoggingLevelSchema from sdk
    • add props and prop types for logLevel and sendLogLevelRequest and loggingSupported
    • add Select component populated with the enum values of LoggingLevelSchema, shown only if loggingSupported is true and connectionStatus is "connected" *

Motivation and Context

We previously had an error report of log messages not getting through to the client. We added that functionality, but then had no way to set the logging level from the client, so we couldn't demonstrate a server respecting the set log level. More history in the issue.

How Has This Been Tested?

No Logging Level combo is shown when not connected

no-log-level-combo-when-not-connected

Logging Level combo is shown when connected to a server that supports logging.

log-level-combo-when-connected

Server support

Ran the Everything server with changes made to track and respect the log level set by the client.

In this screenshot, I've set the level to "warning" and only warning and higher messages are sent.
level-respected-messages

Breaking Changes

Nope.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

* This fixes modelcontextprotocol#188
* In App.tsx
  - import LoggingLevel from sdk
  - add [logLevel, setLogLevel] useState with value of type LoggingLevel initialized to "debug"
  - add useEffect that stores the new logLevel in localStorage as "logLevel"
  - added sendLogLevelRequest function that takes a level argument of type LoggingLevel and sends the appropriate request. It calls setLogLevel when done, to update the local UI
  - pass logLevel and sendLogLevelRequest to Sidebar component as props
* In Sidebar.tsx
  - Import LoggingLevel and LoggingLevelSchema from sdk
  - add props and prop types for  logLevel and sendLogLevelRequest and loggingSupported
  - add Select component populated with the enum values of LoggingLevelSchema, shown only if loggingSupported is true and connectionStatus is "connected"
*
@olaservo
Copy link
Member

Looks good to me, could you grab the latest from main? I think it will still prevent me from merging if I do it myself from the UI.

@olaservo olaservo merged commit de87951 into modelcontextprotocol:main Mar 21, 2025
2 checks passed
@cliffhall cliffhall deleted the add-log-level-setting branch March 21, 2025 16:06
IgnacioC44 referenced this pull request in MCPJam/inspector Jun 21, 2025
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.

Add log level setting in UI

2 participants