-
Notifications
You must be signed in to change notification settings - Fork 4
Add Gateway Interceptor for passing tenant ID #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import json | ||
| import uuid | ||
|
|
||
| def lambda_handler(event, context): | ||
| # Extract the gateway request | ||
| mcp_data = event.get('mcp', {}) | ||
| gateway_request = mcp_data.get('gatewayRequest', {}) | ||
| headers = gateway_request.get('headers', {}) | ||
| body = gateway_request.get('body', {}) | ||
| extended_body = body | ||
|
|
||
| auth_header = headers.get('authorization', '') or headers.get('Authorization', '') | ||
|
|
||
| # Extract Tenant Id from custom header for propagation | ||
| tenant_id = headers.get('X-Tenant-ID', '') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get this tenant id from the access token which is in the Authorization header |
||
|
|
||
| if "params" in extended_body and "arguments" in extended_body["params"]: | ||
| # Add custom header to arguments for downstream processing | ||
| extended_body["params"]["arguments"]["tenant_id"] = tenant_id | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have kb-mcp-handler and log-mcp-handler tools(lambda) which uses tenant_id. So this tenant_id will be available as a part of lambda handler event? |
||
| # Return transformed request without passing the original authorization header | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add/move this assume role code from log-mcp-handler, to here. Then send the generated credentials as a arguments so that log-mcp-handler tool can directly use the generated credentials. |
||
| response = { | ||
| "interceptorOutputVersion": "1.0", | ||
| "mcp": { | ||
| "transformedGatewayRequest": { | ||
| "headers": { | ||
| "Accept": "application/json", | ||
| "Content-Type": "application/json" | ||
| }, | ||
| "body": extended_body | ||
| } | ||
| } | ||
| } | ||
| return response | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access_token already has the tenant id, so lets not add the tenant_id in the headers.