Add mcp-trace and tracing integration #147
Open
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.
Add MCP Tracing Support with mcp-trace
Summary
This PR adds comprehensive tracing capabilities to the Notion MCP Server using the
mcp-tracemiddleware. This enables observability and debugging of all MCP requests, tool calls, and responses, making it easier to monitor and troubleshoot the server in development and production environments.Changes
Core Integration
mcp-tracedependency (v0.2.0) - Already present inpackage.jsonTraceMiddlewareintoMCPProxyclass to capture all MCP communicationFiles Modified
src/openapi-mcp-server/mcp/proxy.tsTraceMiddlewareimport and integrationtraceOptionsparameter toMCPProxyconstructorsrc/init-server.tsTraceMiddlewareOptionsparameter toinitProxyfunctionMCPProxyscripts/start-server.ts--trace/--enable-traceCLI flag to enable tracingMCP_TRACE_ENABLEDenvironment variable supportMCP_TRACE_LOG_FIELDSenvironment variable for log field configurationConsoleAdapterfor tracing outputUsage
Enable Tracing via CLI
Enable Tracing via Environment Variable
What Gets Traced
When tracing is enabled, the middleware captures:
Benefits
Testing
Manual Testing
Test with STDIO transport:
NOTION_TOKEN="your_token" npx tsx scripts/start-server.ts --traceTest with HTTP transport:
NOTION_TOKEN="your_token" npx tsx scripts/start-server.ts --transport http --traceVerify tracing output:
Expected Behavior
--traceflag is used, tracing is enabled and console output shows trace informationBreaking Changes
None - This is a fully backward-compatible feature addition. Tracing is opt-in and disabled by default.
Dependencies
mcp-trace@^0.2.0- Already present inpackage.jsonRelated Issues
N/A - Feature addition
Checklist