feat(CF-1354): Add withSentryTransaction to tool handlers

Wrap CallToolRequest handler with withSentryTransaction for
per-tool tracing. Remove broken $(vault) DSN from .env.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-02-18 12:20:53 +02:00
parent 4f8996cd82
commit 02c009a551
2 changed files with 4 additions and 2 deletions

2
.env
View File

@@ -11,7 +11,7 @@
# - PostgreSQL integration for database error tracking
#
# Created: 2026-01-29
SENTRY_DSN=$(vault get sentry.dsn.mcp-servers)
# SENTRY_DSN provided via ~/.claude.json env (dotenv can't expand shell commands)
SENTRY_ENVIRONMENT=production
SENTRY_TRACE_SAMPLE_RATE=0.1
SENTRY_PROFILE_SAMPLE_RATE=0.01

View File

@@ -19,7 +19,7 @@ const envPath = join(__dirname, '..', '.env');
const result = dotenv.config({ path: envPath, override: true });
// Initialize Sentry for error tracking
import { initSentry } from './sentry.js';
import { initSentry, withSentryTransaction } from './sentry.js';
initSentry(process.env.SENTRY_ENVIRONMENT || 'production');
if (result.error) {
@@ -99,6 +99,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
return withSentryTransaction(name, async () => {
try {
let result: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -544,6 +545,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
};
}
});
});
// Main entry point
async function main() {