
synqedai/mcp-trace-js
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
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
- Quickstart
- Basic Usage
- Feature Usage
- Contexa Adapter
- Other Adapters
- Requirements
- Contributing
- License
- Links & Acknowledgements
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
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →