SM

synqedai/mcp-trace-js

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

22 stars 1 forks Качество 49 Тренд 10

Tracing middleware for MCP servers in TypeScript. Logs all requests, tool calls, and responses to file, DB, or cloud with adapters for OTLP, Supabase, PostgreSQL, and Contexa.

Обзор

Log every request, tool call, and response to local files, PostgreSQL, Supabase, Contexa, console, OTLP, or your own backend—with full control over what gets logged. - 📦 : Add tracing to any MCP server in seconds - 🗃️ : Log to file, PostgreSQL, Supabase, Contexa, console, OTLP, or your own - 🛠️ : Enable/disable fields (tool args, responses, client ID, etc.) - 🧩 : Use multiple adapters at once - 📝 : All traces stored as JSON for easy querying - 🔒 : Control exactly what gets logged - ⚡ : Full type safety and IntelliSense - 🛡️ : Comprehensive error handling and memory management - 🔧 : Configuration validation with descriptive error messages - 🧹 : Prevents memory leaks with timeout management - 🌐 : Native OTLP integration for observability platforms See example/streamable-http-server.ts for a complete MCP server using Streamable HTTP transport with tracing.

README

Показан фрагмент оригинального README. Открыть оригинал.

mcp-trace

Flexible, pluggable tracing middleware for Model Context Protocol (MCP) servers in JavaScript/TypeScript. Log every request, tool call, and response to local files, PostgreSQL, Supabase, Contexa, console, OTLP, or your own backend—with full control over what gets logged.


Table of Contents


Features

  • 📦 Plug-and-play: Add tracing to any MCP server in seconds
  • 🗃️ Pluggable adapters: Log to file, PostgreSQL, Supabase, Contexa, console, OTLP, or your own
  • 🛠️ Configurable logging: Enable/disable fields (tool args, responses, client ID, etc.)
  • 🧩 Composable: Use multiple adapters at once
  • 📝 Schema-first: All traces stored as JSON for easy querying
  • 🔒 Privacy-aware: Control exactly what gets logged
  • ⚡ TypeScript support: Full type safety and IntelliSense
  • 🛡️ Production-ready: Comprehensive error handling and memory management
  • 🔧 Robust validation: Configuration validation with descriptive error messages
  • 🧹 Automatic cleanup: Prevents memory leaks with timeout management
  • 🌐 OpenTelemetry support: Native OTLP integration for observability platforms

Quickstart

Installation

npm install mcp-trace

Minimal Example

import { TraceMiddleware, FileAdapter } from "mcp-trace-js";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

// Create your MCP server
const server = new McpServer({ name: "my-server", version: "1.0.0" });

// Set up tracing
const traceAdapter = new FileAdapter("trace.log");
const traceMiddleware = new TraceMiddleware({ adapter: traceAdapter });

// Initialize tracing with your server
traceMiddleware.init(server);

// Your server is now fully traced!

Basic Usage

Streamable HTTP Server

Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →