feat: Add structured audit logging for MCP feature server#6456
Open
SIDDHESH1564 wants to merge 3 commits into
Open
feat: Add structured audit logging for MCP feature server#6456SIDDHESH1564 wants to merge 3 commits into
SIDDHESH1564 wants to merge 3 commits into
Conversation
Signed-off-by: Siddhesh Khairnar <khairnarsiddhesh4057@gmail.com>
Member
OTel is a follow-up is fine, but the core schema and sink abstraction feel like reinventing what opentelemetry-sdk already provides. Also, AuditEvent should carry a trace_id/span_id if OpenTelemetry is active. Also, the fundamental problem with this is that it intercepts at the HTTP transport layer rather than at the MCP protocol layer. It should implement bidirectional correlation - linking a request to its response. |
…orrelation Signed-off-by: Siddhesh Khairnar <khairnarsiddhesh4057@gmail.com>
Contributor
Author
|
Thanks for the review, @ntkathole. Both points have been addressed.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR adds structured audit logging in JSONL format for the Python MCP feature server.
Previously, the MCP integration only logged startup events and errors. Operators did not have a unified audit trail for MCP tool calls, internal REST requests, authentication results, authorization decisions, or request correlation.
This change introduces an
audit_loggingconfiguration section underfeature_serverand adds structured audit events for:X-Request-IdEach audit event follows a stable schema and includes:
event_typetimestamprequest_idprincipal(username,roles, andauth_type)source(ipandtransport)action(MCP tool name and/or HTTP path)resource(type,name, and permitted actions)outcomeduration_msSensitive data is intentionally excluded from audit logs. Tokens, entity rows, feature values, and request payloads are not logged.
Audit logging layers
McpAuditMiddleware/mcpJSON-RPC requestsmcp.tools.call,mcp.requestAuditLoggingMiddleware/get-online-featuresand/pushhttp.requestAuditLoggerhelpersauthn.success,authn.failure,authz.decisionNew files
sdk/python/feast/audit/audit_logger.pyAuditEventmodel.StdoutAuditSink,FileAuditSink, andLoggerAuditSink.AuditLoggerhelper methods for MCP, HTTP, authentication, and authorization events.sdk/python/feast/audit/audit_middleware.pyAuditLoggingMiddlewarefor REST endpoint auditing.McpAuditMiddlewarefor MCP JSON-RPC request auditing.Modified files
sdk/python/feast/infra/feature_servers/base_config.pyAuditLoggingConfigtoBaseFeatureServerConfig.sdk/python/feast/feature_server.pyget_app().Example configuration
Example JSONL event
{ "event_type": "mcp.tools.call", "timestamp": "2026-05-28T12:00:00.000Z", "request_id": "...", "principal": { "username": "jane@co.com", "roles": ["reader"], "auth_type": "oidc" }, "source": { "ip": "10.0.0.1", "transport": "mcp-http" }, "action": { "mcp_tool": "get_online_features", "path": "/mcp" }, "outcome": "success", "duration_ms": 42.0 }Which issue(s) this PR fixes:
Fixes #6452
Checks
git commit -s)Testing Strategy
Added 37 unit tests covering:
AuditEventserialization in JSONL format, including exclusion ofNonevaluesAuditLoggerhelpers:log_mcp_calllog_http_requestlog_authnlog_authzSuppression of successful read events when
log_successful_reads: falseAll supported sinks:
StdoutAuditSinkFileAuditSinkLoggerAuditSinkcreate_audit_logger_from_configfactory behavior and fallback handlingAuditLoggingConfigvalidation and inheritance throughMcpFeatureServerConfigAuditLoggingMiddlewarebehavior:X-Request-IdpropagationMcpAuditMiddlewarebehavior:Misc
audit_loggingis defined onBaseFeatureServerConfig, making it available to both local and MCP feature server types.SecurityManagercontext and supportsno_auth,oidc, andkubernetesauthentication modes.