Skip to content

vmcp: server never closes its MCP auditor's log file #7372

Backlog

Description

@rdimitrov

Problem

Server.Handler (pkg/vmcp/server/server.go) builds the MCP auditor with audit.NewAuditorWithTransport when AuditConfig is set. With AuditConfig.LogFile set, that opens the file through Config.GetLogWriter. The auditor is a local variable: only its middleware is kept, and Server.Stop never calls Auditor.Close.

So each server built with an audit log file keeps one file descriptor open after it stops. A process that builds and stops vMCP servers repeatedly, such as an embedder, leaks one descriptor per build.

WorkflowAuditor had the same leak, fixed in #6094. The MCP auditor was not covered.

Proposal

Keep the auditor on the Server when Handler creates it, and close it in Stop after the HTTP server has shut down, next to the session data storage close. Closing after shutdown means no in-flight request writes to a closed file.

Done when

  • Stop closes the MCP auditor's log writer when one was opened, and reports a close error with the others.
  • A test builds a server with an audit log file, stops it, and checks the auditor was closed.

Context

Mecatl embeds the vMCP with an audit log file and builds one server per process build, so it hits this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions