Skip to content

Add action/session level MCP interaction logging#4

Merged
ansalls merged 1 commit intomcpfrom
add-mcp-server-package-with-bootstrap-module
Feb 18, 2026
Merged

Add action/session level MCP interaction logging#4
ansalls merged 1 commit intomcpfrom
add-mcp-server-package-with-bootstrap-module

Conversation

@ansalls
Copy link
Owner

@ansalls ansalls commented Feb 18, 2026

Motivation

  • Provide per-interaction observability for MCP operations so activity can be traced by origin and correlated across systems for debugging and security audits.
  • Surface stable correlation identifiers (action_id, session_id) at the tool-invocation boundary and forward them to downstream services.

Description

  • Generate and propagate correlation IDs: MCPServer.call_tool now generates action_id/session_id (and accepts caller-provided session_id/source) and returns them on every ToolCallResponse.
  • Add lifecycle logging in app/domains/mcp_server/server.py for tool invocation events (started, not_found, missing_argument, succeeded, failed) and endpoint-level logs for /mcp/tools and /mcp/resources including source IP and path metadata.
  • Add outbound HTTP client logs and header propagation in app/domains/mcp_server/client.py via mcp_outbound_request, mcp_outbound_response, and mcp_outbound_error, and forward X-MCP-Action-ID and X-MCP-Session-ID on requests.
  • Update unit tests to assert presence and propagation of action_id/session_id and update docs (README.md, ARCHITECTURE.md, AI_CHANGE_CHECKLIST.md) to document the traceability behavior.

Testing

  • Unit tests: ran python -m pytest tests/unit/test_mcp_client_unit.py tests/unit/test_mcp_server_unit.py -q and all tests passed (9 passed).
  • Project checks: attempted make lint and make typecheck but the environment is missing local virtualenv tools (.venv/bin/ruff, .venv/bin/mypy) so these targets could not run to completion.
  • Security and full test gate: attempted make audit-security and make test but these failed in the current environment due to missing docker and .venv/bin/pytest respectively, which are environmental blockers rather than code failures.

Codex Task

@ansalls ansalls merged commit 98e2144 into mcp Feb 18, 2026
3 of 4 checks passed
@ansalls ansalls deleted the add-mcp-server-package-with-bootstrap-module branch February 18, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant