@@ -24,12 +24,12 @@ Re‑implement the existing Python MCP proxy in Go, delivering a single‑binary
2424
2525* WebSocket/stdin transports, distributed indexing, vector search.
2626
27- ## 3 Tech Stack
27+ ## 3 Tech Stack
2828
2929| Concern | Library | Reason |
3030| ----------------- | --------------------------------- | ---------------------------------- |
3131| MCP server/client | ** ` mark3labs/mcp-go ` ** | Native Go, Streamable‑HTTP support |
32- | Full‑text search | ** Bleve v2** | Embeddable BM25 |
32+ | Full‑text search | ** Bleve v2** | Embeddable BM25 |
3333| CLI & config | ** ` spf13/cobra ` + ` spf13/viper ` ** | Flags → env → file binding |
3434| Persistence | ** bbolt** | Single‑file ACID |
3535| Sys‑tray | ** ` fyne.io/systray ` ** | Tiny cross‑platform tray |
@@ -66,7 +66,7 @@ Re‑implement the existing Python MCP proxy in Go, delivering a single‑binary
6666 * Stored alongside tool metadata in both Bleve doc and Bolt ` toolhash ` bucket.
6767 * During re‑sync ` ListTools ` results are hashed; unchanged hashes skip re‑indexing.
6868
69- ## 6 Data Model (bbolt)
69+ ## 6 Data Model (bbolt)
7070
7171| Bucket | Key | Value |
7272| ----------- | ------------- | ---------------------------- |
@@ -119,7 +119,22 @@ Input: {"operation":"add","url":"https://api.mcp.dev","name":"dev"}
119119Output: {" id" : " uuid" ," enabled" : true }
120120```
121121
122- Operations: ` list ` / ` add ` / ` remove ` / ` update ` .
122+ Operations: ` list ` / ` add ` / ` remove ` / ` update ` / ` tail_log ` .
123+
124+ #### 8.3.1 ` tail_log ` Operation
125+
126+ The ` tail_log ` operation allows LLMs to read recent log entries from a specific upstream server for debugging purposes:
127+
128+ ``` jsonc
129+ Input: {" operation" : " tail_log" ," name" : " dev" ," lines" : 50 }
130+ Output: {" server" : " dev" ," lines" : 50 ," log_entries" : [... ]}
131+ ```
132+
133+ ** Parameters:**
134+ - ` name ` (required): Server name to read logs from
135+ - ` lines ` (optional): Number of recent lines to return (default: 50, max: 500)
136+
137+ ** Use Case:** Enables AI agents to autonomously diagnose connection issues, authentication failures, and other upstream server problems by reading recent log entries.
123138
124139### 8.4 ` tools_stat `
125140
@@ -134,10 +149,55 @@ Returns `{total_tools, top:[{tool_name,count}]}`.
134149
135150## 10 CLI, Config & Tray
136151
137- * ` mcpproxy [--listen :8080] [--data -dir ~/.mcpproxy] [--upstream "prod=https://api"] `
152+ * ` mcpproxy [--listen :8080] [--log -dir ~/.mcpproxy/logs ] [--upstream "prod=https://api"] `
138153* Viper reads ` $MCPP_ ` envs and ` config.toml ` .
139154* Tray (systray): icon + menu items (Enable, Disable, Add…, Reindex, Quit).
140155
156+ ### 10.1 Logging System
157+
158+ #### Per-Upstream Server Logging
159+
160+ mcpproxy implements comprehensive per-upstream-server logging to facilitate debugging of connection issues and MCP communication problems.
161+
162+ ** Log File Structure:**
163+ ```
164+ ~/.mcpproxy/logs/
165+ ├── main.log # Main application log
166+ ├── server-github.log # GitHub MCP server interactions
167+ ├── server-filesystem.log # Filesystem MCP server interactions
168+ └── server-database.log # Database MCP server interactions
169+ ```
170+
171+ ** Log Content:**
172+ - ** MCP Protocol Messages** : All JSON-RPC messages between mcpproxy and upstream servers
173+ - ** Connection Events** : Connect, disconnect, retry attempts, and failures
174+ - ** Authentication** : OAuth flows, token refreshes, and auth errors
175+ - ** Process Output** : STDERR from stdio-based MCP servers
176+ - ** Timing Information** : Request/response latencies and timeout events
177+
178+ ** Example Log Format:**
179+ ```
180+ 2025-06-04T03:42:38.375Z [github] [info] Connecting to upstream server
181+ 2025-06-04T03:42:38.630Z [github] [info] Connected successfully
182+ 2025-06-04T03:42:38.663Z [github] [debug] [Client→Server] initialize
183+ 2025-06-04T03:42:38.663Z [github] [debug] {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"mcpproxy-go","version":"1.0.0"}},"jsonrpc":"2.0","id":0}
184+ 2025-06-04T03:42:38.700Z [github] [debug] [Server→Client] 0
185+ 2025-06-04T03:42:38.700Z [github] [debug] {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"GitHub MCP Server","version":"1.0.0"}}}
186+ 2025-06-04T03:42:41.670Z [github] [error] Connection error: HTTP 500 - Internal Server Error
187+ 2025-06-04T03:42:41.671Z [github] [info] Attempting reconnection in 5 seconds...
188+ ```
189+
190+ ** CLI Configuration:**
191+ - ` --log-dir ` : Specify custom log directory (default: OS-specific standard location)
192+ - ` --log-level ` : Set log level for all loggers (debug, info, warn, error)
193+ - Main application log: ` main.log `
194+ - Per-server logs: ` server-{name}.log `
195+
196+ ** Log Rotation:**
197+ - Automatic rotation based on file size (10MB default)
198+ - Configurable retention (5 backup files, 30 days default)
199+ - Optional compression for rotated files
200+
141201## 11 Build & Packaging
142202
143203* Cross‑compile via ` GOOS=darwin/windows/linux ` .
@@ -171,7 +231,10 @@ The proxy supports dynamic management of upstream MCP servers through the `upstr
171231~/.mcpproxy/
172232├── mcp_config.json # Main configuration file
173233├── data.bolt # BoltDB storage (tool stats, metadata)
174- └── index.bleve/ # Search index directory
234+ ├── index.bleve/ # Search index directory
235+ └── logs/ # Log files directory
236+ ├── main.log # Main application log
237+ └── server-*.log # Per-upstream server logs
175238```
176239
177240#### Configuration Flow
0 commit comments