Skip to content

Webhooks #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

pantanurag555
Copy link

Motivation and Context

This is draft PR for the changes discussed in specification discussion #523.

How Has This Been Tested?

Tested by setting up a webhook, client and server locally. The webhook received all messages when the server was setup with streamable http. It was tested for both json_response True and False. All units tests succeeded.

Breaking Changes

None

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

),
HTTPStatus.OK,
)
asyncio.create_task(

Choose a reason for hiding this comment

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

issue: we should start the this task before responding with a 200

for webhook in webhooks:
headers = {"Content-Type": CONTENT_TYPE_JSON}
# Add authorization headers
if webhook.authentication and webhook.authentication.credentials:

Choose a reason for hiding this comment

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

question: how much of the auth logic is duplicate from what is there for Streamable HTTP? Can auth stuff be abstracted into a helper layer if it is same?

creds_dict = json.loads(webhook.authentication.credentials)
if "username" in creds_dict and "password" in creds_dict:
# Create basic auth header from username and password
import base64

Choose a reason for hiding this comment

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

suggestion: generally it is not a good idea to do imports in the runtime code like this as things that would fail at server startup may not fail until a request comes in that hits this path. Better to import this up top directly imo despite the fact that it might lead to more deps. btw is base64 part of the standard python libs?

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