MCP Logger

MCPAI代理

提供方 andkirby · 包名 @modelcontextprotocol/inspector

AI代理 stdio · 本地进程 无需鉴权 社区 / 第三方 Claude
查看接入方式

一个轻量级的日志系统,用于捕获前端控制台日志并通过MCP(模型上下文协议)访问,适用于开发和调试环境。

一句话选型结论

按资料字段整理

MCP Logger 属于AI代理类 MCP 服务器,stdio · 本地进程,无需鉴权,可直接接入 Claude,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类AI代理 传输方式stdio · 本地进程 鉴权无需鉴权 部署方式本地部署
GitHub 星标 1 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

AI代理
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

日志记录JavaScript本地部署前端调试开发工具MCP协议AI辅助

安装与配置

stdio · 本地进程 无需鉴权
客户端在本机拉起子进程,数据不出本机
npx @modelcontextprotocol/inspector --cli node $(pwd)/mcp-server.js \

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
给代理接外部能力

让代理在任务中途调用搜索、数据库等真实工具。

多步任务编排

把一串操作拆成步骤,由代理按顺序执行。

自动化重复流程

把固定流程交给代理跑,减少手工操作。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude,换客户端不用重新研究配置。
  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 已经在用 Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
MCP Logger当前 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Filesystem 560c4363 13 未标注 本地部署 无 2026-05-17
Server Everything (everything) 11 stdio · 本地进程 本地部署 有 2026-05-17
Time 7365cb6d 2 SSE · 服务端推送 远程部署 有 2026-05-18
Everything Claude Code 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Openmemory 557e1585 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

AI代理
字段来自项目仓库与公开索引,中文说明由本站标注
提供方andkirby上游标注的维护方 andkirby
分类AI代理本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时@modelcontextprotocol/inspector · Node.js本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

14.2 KB
来自项目仓库与上游目录的原文,未做删改

MCP-logger - Logging System + MCP Server + Browser Integration

A lightweight logging system that captures frontend console logs and makes them accessible via MCP (Model Context Protocol). Perfect for development and debugging environments with AI assistants.

📋 System Overview

The Browser Logging System consists of three main components:

  1. Frontend Logger (mcp-logger.js) - Captures console logs and sends to backend
  2. Backend Server (logger-server.js) - Receives and stores logs from frontend
  3. MCP Server (mcp-server.js) - Provides MCP access to stored logs

🏗️ Architecture Overview

System Context (C4 Level 1)```mermaid

graph TB
subgraph "Your Applications"
app1["Web App"]
app2["Mobile App"]
app3["Backend API"]
end

subgraph "Browser Logger System"
    logger["Logging System"]
end

dev["Developer"]
ai["AI Assistant"]

%% Your apps send logs to the system
app1 -->|"logs"| logger
app2 -->|"logs"| logger
app3 -->|"logs"| logger

%% You interact with AI to get insights
dev -->|"asks about issues"| ai
ai -->|"fetches logs"| logger
ai -->|"provides insights"| dev

classDef yourApp fill:#e8f5e8,stroke:#2e7d32
classDef logger fill:#e1f5fe,stroke:#01579b
classDef person fill:#fff3e0,stroke:#f57c00

class app1,app2,app3 yourApp
class logger logger
class dev,ai person

**How it works:**
1. Your applications send logs to the centralized logging system
2. You ask your AI assistant about issues or problems
3. AI retrieves and analyzes logs from any of your applications
4. You get actionable insights back from your AI assistant

## 🚀 Quick Start (5-Minute Setup)

### Step 1: Install Dependencies```bash
cd mcp-logger
npm install

Step 2: Configure (Optional)```bash

Copy the example configuration file

cp .env.example .env

Edit .env to customize settings (optional):

PORT=3000

HOST=0.0.0.0

MAX_LOG_ENTRIES=500


### Step 3: Start Backend Server```bash
# Terminal 1
node logger-server.js
# Expected: 🚀 Browser Logger Server running on http://localhost:22345

Step 4: Configure MCP Client

The MCP server uses STDIO transport and is launched automatically by your LLM client:```bash

Show quick setup with Claude Code CLI

node mcp-server.js mcp-help


With default app `my-app` (AI client will use MCP `FE-logs` only for app `my-app`):```bash
claude mcp add FE-logs node $(pwd)/mcp-server.js \
    --scope local --env FILTER_APP=my-app

Or use base setup (requires app parameter in get_logs calls):```bash
claude mcp add FE-logs node $(pwd)/mcp-server.js


**Test with MCP inspector:**```bash
npx @modelcontextprotocol/inspector --cli node $(pwd)/mcp-server.js \
  -e FILTER_APP=my-app --method tools/call --tool-name 'get_logs'

Step 5: Add to Frontend Application

Add this single script to your HTML file - it handles both online and offline scenarios automatically:```html
<script>
window.MCP_LOGGING_ENABLED = true;
window.MCP_LOGGING_APP_NAME = 'my-app'; // REQUIRED: Set your app name
window.MCP_LOGGING_BACKEND_URL = 'http://localhost:22345';
(function() {
// Try to load from server first, fallback to local file
var script = document.createElement('script');
script.src = window.MCP_LOGGING_BACKEND_URL + '/mcp-logger.js';
script.onerror = function() {
// Server is down, create a simple fallback logger
console.log('MCP Logger server offline, using local fallback');
window.logger = {
log: function(namespace, data) {
console.debug('[' + namespace + ']', data);
}
};
};
document.head.appendChild(script);
})();
</script>


### Step 6: Test Your Setup
Use the `get_logs()` tool in your MCP client to retrieve logs from your frontend application.

**Without FILTER_APP (requires app parameter):**```javascript
get_logs(app=&quot;my-app&quot;)
get_logs(app=&quot;my-app&quot;, filter=&quot;error&quot;, lines=50)

With FILTER_APP set (app parameter optional):```javascript
get_logs() // Uses default app
get_logs(filter="error", lines=50) // Uses default app
get_logs(app="other-app") // Override default app


## 🔧 Configuration

### Environment Variables (.env file)

Create a `.env` file from `.env.example` to customize your setup:```bash
# Copy the example configuration
cp .env.example .env

Backend Server Configuration:```bash
PORT=22345 # Server port
HOST=localhost # Server host (use 0.0.0.0 for external access)
MAX_LOG_ENTRIES=500 # Max log entries per namespace


**MCP Server Configuration:**```bash
BACKEND_HOST=localhost                  # Host where MCP server can reach backend
BACKEND_PORT=22345                      # Port where MCP server can reach backend
FILTER_APP=my-app                       # Default app name for get_logs tool

Custom Host/Port Examples

Different Port:```bash

.env file

PORT=3000
HOST=localhost

Frontend script

window.MCP_LOGGING_BACKEND_URL = 'http://localhost:3000';


**External Access:**```bash
# .env file
PORT=22345
HOST=0.0.0.0
BACKEND_HOST=192.168.1.100

# Frontend script
window.MCP_LOGGING_BACKEND_URL = &#x27;http://192.168.1.100:22345&#x27;;

Complete Remote Setup:```bash

.env file

PORT=3000
HOST=0.0.0.0
BACKEND_HOST=192.168.1.100
BACKEND_PORT=3000
FILTER_APP=dashboard


## 🔌 API Endpoints

**Main Endpoints:**
- `POST /api/logs/submit` - Submit logs from frontend
- `GET /api/logs/status` - Get all apps, hosts, and namespaces
- `GET /api/health` - Health check
- `GET /` - Web log viewer interface
- `GET /mcp-logger.js` - Frontend logger script

## 📖 Usage Examples

### Console Logging (Automatic)```javascript
// All console methods are automatically captured
console.log(&#x27;Application started&#x27;);
console.info(&#x27;User logged in&#x27;);
console.warn(&#x27;Deprecated API used&#x27;);
console.error(&#x27;Network request failed&#x27;);

Application Logging (Structured)```javascript

// User interaction logging
logger.log('user-actions', {
action: 'click',
target: 'submit-button',
page: '/checkout',
timestamp: Date.now()
});

// API call logging
logger.log('api-calls', {
method: 'POST',
url: '/api/users',
status: 200,
duration: 150
});

// Error logging
logger.log('errors', {
type: 'validation',
message: 'Invalid email format',
field: 'email'
});


### Shell Command Logging```bash
# First argument is app name, rest is command
./shell-log.sh my-app npm run build
./shell-log.sh api-test curl -s http://api.example.com/health
./shell-log.sh markdown-ticket bash start.sh

# View logs in web interface at http://localhost:22345
# App: my-app, Namespace: npm (auto-generated from command)

MCP Tool Usage```javascript

// Basic log retrieval
// auto-selects single host
// use app=unknown-app or defined in app=${FILTER_APP} env variable
get_logs()

// Retrieve with filtering
get_logs(filter="error", lines=10)

// Specific host and namespace
get_logs(frontend_host="localhost:3000", namespace="user-actions")


## 🖥️ Web Log Viewer

Access the web interface at **http://localhost:22345** when the backend server is running.

**Features:**
- Real-time log streaming
- Filter by text, log level, or source
- Dark/light themes
- Export logs to clipboard
- Pause/resume streaming```bash
# Start backend and open viewer
npm run start-backend
open http://localhost:22345

🧪 Testing and Verification

Basic Connectivity Test```bash

Test backend health

curl http://localhost:22345/api/health


### Postman API Testing

The comprehensive Postman collection provides complete API testing coverage:```bash
# Import the collection
1. Open Postman → Import → File → sandbox/MCP-Logger-API.postman_collection.json
2. Run individual requests or use Collection Runner for bulk testing
3. View detailed guide: sandbox/POSTMAN_API_GUIDE.md

Test Coverage:
- ✅ System health and status endpoints
- ✅ Log submission (browser, application, shell formats)
- ✅ Log retrieval with filtering and pagination
- ✅ Real-time SSE streaming
- ✅ Frontend asset serving
- ✅ Load testing and concurrent requests
- ✅ Error handling and edge cases

Frontend Integration Test

Open test/test-frontend.html in your browser to test logging functionality.

🔧 Frontend Configuration```javascript

// Set before loading mcp-logger.js
window.MCP_LOGGING_ENABLED = true; // Enable/disable logging
window.MCP_LOGGING_APP_NAME = 'my-app'; // REQUIRED: Your app name
window.MCP_LOGGING_BACKEND_URL = 'http://localhost:22345'; // Backend URL
window.MCP_LOGGING_BUFFER_SIZE = 100; // Log buffer size


**Note:** Backend configuration is handled through the `.env` file (see Configuration section above).

## 🐛 Troubleshooting

### Common Issues

**Backend server won&#x27;t start:**```bash
# Check if port is in use
lsof -i :22345

# Check .env file configuration
cat .env

# Use different port if needed
PORT=3001 node logger-server.js

# Or use environment variables directly
HOST=0.0.0.0 PORT=3001 node logger-server.js

Frontend can't connect:```bash

Check backend health

curl http://localhost:22345/api/health


**Logs not appearing in MCP:**
- Check browser console for errors
- Verify network requests are being sent to `/api/logs/submit`
- Ensure backend server is running

**MCP tool not available:**
- Verify AI Client configuration path is correct
- Check that args array contains absolute path to `mcp-server.js`

## 🔒 Security Note

This system is designed for development environments only. It uses HTTP communication and assumes trusted local networks. For production use, implement proper authentication and use HTTPS.

## 📁 File Structure```
mcp-logger/
├── mcp-logger.js                    # Frontend logger
├── inject-logger.js                 # Auto-loading script
├── logger-server.js                 # Backend HTTP server
├── mcp-server.js                     # MCP server (STDIO transport)
├── shell-log.sh                     # Bash wrapper for shell command logging
├── .env.example                     # Example configuration
├── .env                             # Your configuration (create from .env.example)
├── package.json                     # Dependencies and scripts
├── openapi.yaml                     # OpenAPI 3.1 specification
├── CLAUDE.md                        # Claude Code project instructions
├── assets/                          # Web viewer assets
│   ├── log-viewer.css               # Web viewer styles
│   └── log-viewer.js                # Web viewer functionality
├── templates/                       # HTML templates
│   └── log-viewer.html              # Web log viewer template
├── docs/                            # Documentation
│   ├── SHELL_LOGGING.md             # Comprehensive shell logging guide
│   └── CRs/                         # Change requests (gitignored)
│       ├── MCL-001-*.md             # Shell logging feature
│       └── MCL-002-*.md             # Web UI feature
├── sandbox/                         # Non-tracked files (gitignored)
│   ├── MCP-Logger-API.postman_collection.json  # Postman API testing collection
│   ├── POSTMAN_API_GUIDE.md         # Postman collection usage guide
│   ├── SSE_MONITORING.md            # SSE monitoring guide
│   └── *.sh, *.html                 # Various test scripts and files
├── test/                            # Test files
│   ├── test-frontend.html           # Full integration test
│   ├── test-frontend-simulation.js  # Backend test simulation
│   └── test-spam-protection.js      # Rate limiting test
├── test-log-viewer.html             # Standalone log viewer test
└── README.md                        # This file

📞 Backend Integration

Shell Command Logging

Capture shell command output in real-time using nohup with process substitution.```bash

Usage: ./shell-log.sh app-name command [args...]

./shell-log.sh my-app npm run build
./shell-log.sh api-test curl -s http://api.example.com/health
./shell-log.sh markdown-ticket bash start.sh

With verbose output

MCP_LOGGING_VERBOSE=true ./shell-log.sh test-app your-command


**Key Features:**
- First argument is the **app name**
- Namespace is **auto-generated** from command (truncated to 30 chars)
- **Background process capture** using nohup + process substitution
- **Memory-only logging** (no disk files)
- **Real-time streaming** to web interface
- **Stdout/stderr separation** with LOG/ERROR levels

**Environment Variables:**
- `MCP_LOGGING_BACKEND_URL` - Backend URL (default: http://localhost:22345)
- `MCP_LOGGING_VERBOSE` - Enable debug output
- `HOSTNAME` - Host identifier (default: system hostname)

📖 **Detailed Guide**: See docs/SHELL_LOGGING.md for comprehensive shell logging documentation.

### Backend System Logging

This logger can be simply used from any backend system as well, just use `http://localhost:22345/api/logs/submit` endpoint with```
POST /api/logs/submit
Content-Type: application/json
``````json
{
    &quot;app&quot;: &quot;my-backend-app&quot;,
    &quot;host&quot;: &quot;localhost:3000&quot;,
    &quot;logs&quot;: {
        &quot;{your namespace}&quot;: [  ]
    }
}

📞 Support

For technical support:
1. Check the troubleshooting section above
2. See CLAUDE.md for project setup guidance
3. Create an issue with detailed information

📚 Documentation

📖 API Documentation

  • 📖 OpenAPI Specification: openapi.yaml - Complete OpenAPI 3.1 specification
  • 📮 Postman Collection: sandbox/MCP-Logger-API.postman_collection.json - Complete API testing collection
  • 📮 Postman Guide: sandbox/POSTMAN_API_GUIDE.md - Comprehensive Postman usage guide
  • 🌊 SSE Monitoring: sandbox/SSE_MONITORING.md - SSE monitoring guide

🏗️ Project Documentation

  • 🤖 Claude Code Setup: CLAUDE.md - Project instructions and development guidance

🧪 Testing

  • 🌐 Frontend Integration: test/test-frontend.html - Full integration test
  • ⚡ Backend Simulation: test/test-frontend-simulation.js - Test backend API directly
  • 🛡️ Rate Limiting: test/test-spam-protection.js - Test rate limiting functionality

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
MCP Logger 怎么安装?

在客户端按下面的安装命令接入:npx @modelcontextprotocol/inspector --cli node $(pwd)/mcp-server.js \。对应的包名是 @modelcontextprotocol/inspector。装完在客户端配置里引用同一个包或端点。

MCP Logger 怎么在 Claude 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

MCP Logger 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Logger 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

MCP Logger 支持哪些客户端?

资料标注支持 Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

MCP Logger 能提供哪些能力?

资料显示能力标签包括 日志记录、开发工具、JavaScript、Claude。具体工具清单以官方文档为准。

MCP Logger 需要什么运行环境?

运行时为 Node.js;属于本地进程,需要在本机装好运行环境。

MCP Logger 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。