Skip to content

Conversation

@vincent0426
Copy link

Allow extra field within context log

without extra:

{
  "method": "notifications/message",
  "params": {
    "level": "info",
    "data": "test message"
  }
}

with extra:

{
  "method": "notifications/message",
  "params": {
    "level": "info",
    "data": {
      "message": "test message",
      "additional_string": "example",
      "additional_number": 123,
      "additional_boolean": true,
      "additional_list": [
        "a",
        "b",
        "c"
      ],
      "additional_dict": {
        "a": 1,
        "b": 2,
        "c": 3
      },
      "additional_null": null
    }
  }
}

Motivation and Context

Closes #565

How Has This Been Tested?

Unit test, manual test with inspector

Breaking Changes

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

message: str,
*,
logger_name: str | None = None,
**extra: Any,
Copy link
Member

Choose a reason for hiding this comment

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

If we want to create this extra, let's not make it a kwargs.

Suggested change
**extra: Any,
extra: dict[str, Any],

Copy link
Author

Choose a reason for hiding this comment

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

fixed, also addressed other helper logger args

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.

Context.log does not actually accept or pass forward extra kwargs

2 participants