MM

mlshv/mcps-logger

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

23 stars 1 forks 품질 44 트렌드 10MIT

stdio MCP 서버를 위한 console.log

개요

MCP (Model Context Protocol) 서버를 개발할 때 stdio 수송, console.log는 프로토콜 통신과 방해합니다. 예를 들어, 이것은 MCP 검사기 npx @modelcontextprotocol/inspector에서 콘솔을 호출 할 때 일반적으로 얻을 수있는 것입니다. MCP 서버 코드에 로그인: 이 패키지는 콘솔 메소드 (log, warn, error, debug)를 패치하고 별도의 터미널에 로그를 리디렉션합니다. https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00] [T0]] [T0]] [T0]] [T0]] [T0]] [T0]] [T0]] [T0] [T0] [T0]] [T0] [T0] [T0]] [T0]] [T0] [T0] [T0] [T0] [T0]] [T0] [T0]] [T0] [T0] [T0]] [T0]] [T0] [T0] [T0]] https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00] https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]] https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]] [[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]] [[[[[[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]]]]]]]]] [[[[[[[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]]]]]]]]]]]]] [[[[[[[[[[[[[[[[[[[[[[ 로그를보고 싶은 터미널에서 로거를 시작: 또는 개발 모드에서만 사용하려면:

개요(AI 번역)

stdio MCP 서버를 위한 console.log

왜?

MCP (Model Context Protocol) 서버를 개발할 때 stdio 수송, console.log는 프로토콜 통신과 방해합니다.

예를 들어, MCP 검사기 npx @modelcontextprotocol/inspector]에서 MCP 서버 코드에 console.log를 호출할 때 일반적으로 MCP 검사기 npx @modelcontextprotocol/inspector에서 얻을 수 있습니다.

해결책

이 패키지는 콘솔 메소드 (log, warn, error, debug)를 패치하고 별도의 터미널에 로그를 리디렉션합니다.

https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00 https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]] [T2]] [T2]] [T2]] [T2]] [T2]] [T2]] [T2] [T2]] [T2] [T2]] [T2]] [T2]] [T2] [T2]] [T2]] [T2] [T2]] [T2]] [T2] [T2]] [T2]] [T2]] [T2] [T2]] [T2] https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]] https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]] [[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]]]]]]] [[[[[[[[[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]]]]]]]]]]] [[[[[[[[[[[[[https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

사용법

로그를보고 싶은 터미널에서 로거를 시작:

MCP 서버에서 logger 설치:

MCP 서버 입력 파일에 추가:

또는 개발 모드에서만 사용하려면:

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

MCP Server Logger

console.log for your stdio MCP server

Why?

When developing an MCP (Model Context Protocol) server with stdio transport, console.log interferes with the protocol communication.

For example, this is what you normally get in MCP inspector npx @modelcontextprotocol/inspector when calling console.log in your MCP server code:

Error from MCP server: SyntaxError: Unexpected token S in JSON at position 0

Solution

This package patches the console methods (log, warn, error, debug) and redirects logs to a separate terminal.

https://github.com/user-attachments/assets/33ff367e-74b4-48e8-9f04-0bcafbad5e00

Usage

Start the logger in a terminal where you want to see the logs:

npx mcps-logger

Install the logger in your MCP server:

npm install mcps-logger

Add it to your MCP server entry file:

import "mcps-logger/console";

Or if you want to use in development mode only:

if (process.env.NODE_ENV !== "production") {
    import("mcps-logger/console");
}
GitHub에서 전체 README 보기

설치

npx mcps-logger
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →