code-puppy 0.0.316__py3-none-any.whl → 0.0.325__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- code_puppy/agents/base_agent.py +241 -91
- code_puppy/cli_runner.py +8 -1
- code_puppy/command_line/add_model_menu.py +11 -0
- code_puppy/command_line/mcp/logs_command.py +173 -64
- code_puppy/command_line/model_settings_menu.py +6 -0
- code_puppy/keymap.py +8 -2
- code_puppy/mcp_/__init__.py +17 -0
- code_puppy/mcp_/blocking_startup.py +50 -29
- code_puppy/mcp_/managed_server.py +1 -1
- code_puppy/mcp_/mcp_logs.py +224 -0
- code_puppy/messaging/__init__.py +9 -0
- code_puppy/messaging/markdown_patches.py +57 -0
- code_puppy/model_factory.py +54 -0
- code_puppy/models.json +3 -3
- code_puppy/plugins/__init__.py +12 -0
- code_puppy/plugins/claude_code_oauth/utils.py +1 -0
- code_puppy/plugins/shell_safety/agent_shell_safety.py +1 -118
- code_puppy/plugins/shell_safety/register_callbacks.py +44 -3
- code_puppy/tools/command_runner.py +48 -21
- {code_puppy-0.0.316.data → code_puppy-0.0.325.data}/data/code_puppy/models.json +3 -3
- {code_puppy-0.0.316.dist-info → code_puppy-0.0.325.dist-info}/METADATA +1 -1
- {code_puppy-0.0.316.dist-info → code_puppy-0.0.325.dist-info}/RECORD +26 -24
- {code_puppy-0.0.316.data → code_puppy-0.0.325.data}/data/code_puppy/models_dev_api.json +0 -0
- {code_puppy-0.0.316.dist-info → code_puppy-0.0.325.dist-info}/WHEEL +0 -0
- {code_puppy-0.0.316.dist-info → code_puppy-0.0.325.dist-info}/entry_points.txt +0 -0
- {code_puppy-0.0.316.dist-info → code_puppy-0.0.325.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"""
|
|
2
|
-
MCP Logs Command - Shows
|
|
2
|
+
MCP Logs Command - Shows server logs from persistent log files.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
-
from datetime import datetime
|
|
7
6
|
from typing import List, Optional
|
|
8
7
|
|
|
9
|
-
from rich.
|
|
8
|
+
from rich.panel import Panel
|
|
9
|
+
from rich.syntax import Syntax
|
|
10
10
|
from rich.text import Text
|
|
11
11
|
|
|
12
|
+
from code_puppy.mcp_.mcp_logs import (
|
|
13
|
+
clear_logs,
|
|
14
|
+
get_log_file_path,
|
|
15
|
+
get_log_stats,
|
|
16
|
+
list_servers_with_logs,
|
|
17
|
+
read_logs,
|
|
18
|
+
)
|
|
12
19
|
from code_puppy.messaging import emit_error, emit_info
|
|
13
20
|
|
|
14
21
|
from .base import MCPCommandBase
|
|
@@ -22,105 +29,207 @@ class LogsCommand(MCPCommandBase):
|
|
|
22
29
|
"""
|
|
23
30
|
Command handler for showing MCP server logs.
|
|
24
31
|
|
|
25
|
-
Shows
|
|
32
|
+
Shows logs from persistent log files stored in ~/.code_puppy/mcp_logs/.
|
|
26
33
|
"""
|
|
27
34
|
|
|
28
35
|
def execute(self, args: List[str], group_id: Optional[str] = None) -> None:
|
|
29
36
|
"""
|
|
30
|
-
Show
|
|
37
|
+
Show logs for a server.
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
/mcp logs - List servers with logs
|
|
41
|
+
/mcp logs <server_name> - Show last 50 lines
|
|
42
|
+
/mcp logs <server_name> 100 - Show last 100 lines
|
|
43
|
+
/mcp logs <server_name> all - Show all logs
|
|
44
|
+
/mcp logs <server_name> --clear - Clear logs for server
|
|
31
45
|
|
|
32
46
|
Args:
|
|
33
|
-
args: Command arguments
|
|
47
|
+
args: Command arguments
|
|
34
48
|
group_id: Optional message group ID for grouping related messages
|
|
35
49
|
"""
|
|
36
50
|
if group_id is None:
|
|
37
51
|
group_id = self.generate_group_id()
|
|
38
52
|
|
|
53
|
+
# No args - list servers with logs
|
|
39
54
|
if not args:
|
|
40
|
-
|
|
55
|
+
self._list_servers_with_logs(group_id)
|
|
41
56
|
return
|
|
42
57
|
|
|
43
58
|
server_name = args[0]
|
|
44
|
-
|
|
59
|
+
|
|
60
|
+
# Check for --clear flag
|
|
61
|
+
if len(args) > 1 and args[1] == "--clear":
|
|
62
|
+
self._clear_logs(server_name, group_id)
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
# Determine number of lines
|
|
66
|
+
lines = 50 # Default
|
|
67
|
+
show_all = False
|
|
45
68
|
|
|
46
69
|
if len(args) > 1:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
if args[1].lower() == "all":
|
|
71
|
+
show_all = True
|
|
72
|
+
else:
|
|
73
|
+
try:
|
|
74
|
+
lines = int(args[1])
|
|
75
|
+
if lines <= 0:
|
|
76
|
+
emit_info(
|
|
77
|
+
"Lines must be positive, using default: 50",
|
|
78
|
+
message_group=group_id,
|
|
79
|
+
)
|
|
80
|
+
lines = 50
|
|
81
|
+
except ValueError:
|
|
50
82
|
emit_info(
|
|
51
|
-
"
|
|
83
|
+
f"Invalid number '{args[1]}', using default: 50",
|
|
52
84
|
message_group=group_id,
|
|
53
85
|
)
|
|
54
|
-
limit = 10
|
|
55
|
-
except ValueError:
|
|
56
|
-
emit_info(
|
|
57
|
-
f"Invalid limit '{args[1]}', using default: 10",
|
|
58
|
-
message_group=group_id,
|
|
59
|
-
)
|
|
60
86
|
|
|
87
|
+
self._show_logs(server_name, lines if not show_all else None, group_id)
|
|
88
|
+
|
|
89
|
+
def _list_servers_with_logs(self, group_id: str) -> None:
|
|
90
|
+
"""List all servers that have log files."""
|
|
91
|
+
servers = list_servers_with_logs()
|
|
92
|
+
|
|
93
|
+
if not servers:
|
|
94
|
+
emit_info(
|
|
95
|
+
"📋 No MCP server logs found.\n"
|
|
96
|
+
"Logs are created when servers are started.",
|
|
97
|
+
message_group=group_id,
|
|
98
|
+
)
|
|
99
|
+
return
|
|
100
|
+
|
|
101
|
+
lines = ["📋 **Servers with logs:**\n"]
|
|
102
|
+
|
|
103
|
+
for server in servers:
|
|
104
|
+
stats = get_log_stats(server)
|
|
105
|
+
size_kb = stats["total_size_bytes"] / 1024
|
|
106
|
+
size_str = (
|
|
107
|
+
f"{size_kb:.1f} KB" if size_kb < 1024 else f"{size_kb / 1024:.1f} MB"
|
|
108
|
+
)
|
|
109
|
+
rotated = (
|
|
110
|
+
f" (+{stats['rotated_count']} rotated)"
|
|
111
|
+
if stats["rotated_count"]
|
|
112
|
+
else ""
|
|
113
|
+
)
|
|
114
|
+
lines.append(
|
|
115
|
+
f" • **{server}** - {stats['line_count']} lines, {size_str}{rotated}"
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
lines.append("\n**Usage:** `/mcp logs <server_name> [lines|all]`")
|
|
119
|
+
|
|
120
|
+
emit_info("\n".join(lines), message_group=group_id)
|
|
121
|
+
|
|
122
|
+
def _show_logs(self, server_name: str, lines: Optional[int], group_id: str) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Show logs for a specific server.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
server_name: Name of the server
|
|
128
|
+
lines: Number of lines to show, or None for all
|
|
129
|
+
group_id: Message group ID
|
|
130
|
+
"""
|
|
61
131
|
try:
|
|
62
|
-
#
|
|
132
|
+
# Verify server exists in manager
|
|
63
133
|
server_id = find_server_id_by_name(self.manager, server_name)
|
|
64
134
|
if not server_id:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
135
|
+
# Server not configured, but might have logs from before
|
|
136
|
+
stats = get_log_stats(server_name)
|
|
137
|
+
if not stats["exists"]:
|
|
138
|
+
emit_info(
|
|
139
|
+
f"Server '{server_name}' not found and has no logs.",
|
|
140
|
+
message_group=group_id,
|
|
141
|
+
)
|
|
142
|
+
suggest_similar_servers(
|
|
143
|
+
self.manager, server_name, group_id=group_id
|
|
144
|
+
)
|
|
145
|
+
return
|
|
68
146
|
|
|
69
|
-
#
|
|
70
|
-
|
|
147
|
+
# Read logs
|
|
148
|
+
log_lines = read_logs(server_name, lines=lines)
|
|
71
149
|
|
|
72
|
-
if not
|
|
150
|
+
if not log_lines:
|
|
73
151
|
emit_info(
|
|
74
|
-
f"
|
|
152
|
+
f"📋 No logs found for server: **{server_name}**\n"
|
|
153
|
+
f"Log file: `{get_log_file_path(server_name)}`",
|
|
75
154
|
message_group=group_id,
|
|
76
155
|
)
|
|
77
156
|
return
|
|
78
157
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
158
|
+
# Get stats for header
|
|
159
|
+
stats = get_log_stats(server_name)
|
|
160
|
+
total_lines = stats["line_count"]
|
|
161
|
+
showing = len(log_lines)
|
|
162
|
+
|
|
163
|
+
# Format header
|
|
164
|
+
if lines is None:
|
|
165
|
+
header = f"📋 Logs for {server_name} (all {total_lines} lines)"
|
|
166
|
+
else:
|
|
167
|
+
header = (
|
|
168
|
+
f"📋 Logs for {server_name} (last {showing} of {total_lines} lines)"
|
|
85
169
|
)
|
|
86
|
-
return
|
|
87
170
|
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
171
|
+
# Format log content with syntax highlighting
|
|
172
|
+
log_content = "\n".join(log_lines)
|
|
173
|
+
|
|
174
|
+
# Create a panel with the logs
|
|
175
|
+
syntax = Syntax(
|
|
176
|
+
log_content,
|
|
177
|
+
"log",
|
|
178
|
+
theme="monokai",
|
|
179
|
+
word_wrap=True,
|
|
180
|
+
line_numbers=False,
|
|
181
|
+
)
|
|
93
182
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
183
|
+
panel = Panel(
|
|
184
|
+
syntax,
|
|
185
|
+
title=header,
|
|
186
|
+
subtitle=f"Log file: {get_log_file_path(server_name)}",
|
|
187
|
+
border_style="dim",
|
|
97
188
|
)
|
|
98
189
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# Color code event types
|
|
111
|
-
event_style = "cyan"
|
|
112
|
-
if "error" in event_type.lower():
|
|
113
|
-
event_style = "red"
|
|
114
|
-
elif event_type in ["started", "enabled", "registered"]:
|
|
115
|
-
event_style = "green"
|
|
116
|
-
elif event_type in ["stopped", "disabled"]:
|
|
117
|
-
event_style = "yellow"
|
|
118
|
-
|
|
119
|
-
table.add_row(
|
|
120
|
-
time_str, Text(event_type, style=event_style), details_str or "-"
|
|
190
|
+
emit_info(panel, message_group=group_id)
|
|
191
|
+
|
|
192
|
+
# Show hint for more options
|
|
193
|
+
if lines is not None and showing < total_lines:
|
|
194
|
+
emit_info(
|
|
195
|
+
Text.from_markup(
|
|
196
|
+
f"[dim]💡 Use `/mcp logs {server_name} all` to see all logs, "
|
|
197
|
+
f"or `/mcp logs {server_name} <number>` for specific count[/dim]"
|
|
198
|
+
),
|
|
199
|
+
message_group=group_id,
|
|
121
200
|
)
|
|
122
|
-
emit_info(table, message_group=group_id)
|
|
123
201
|
|
|
124
202
|
except Exception as e:
|
|
125
203
|
logger.error(f"Error getting logs for server '{server_name}': {e}")
|
|
126
204
|
emit_error(f"Error getting logs: {e}", message_group=group_id)
|
|
205
|
+
|
|
206
|
+
def _clear_logs(self, server_name: str, group_id: str) -> None:
|
|
207
|
+
"""
|
|
208
|
+
Clear logs for a specific server.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
server_name: Name of the server
|
|
212
|
+
group_id: Message group ID
|
|
213
|
+
"""
|
|
214
|
+
try:
|
|
215
|
+
stats = get_log_stats(server_name)
|
|
216
|
+
|
|
217
|
+
if not stats["exists"] and stats["rotated_count"] == 0:
|
|
218
|
+
emit_info(
|
|
219
|
+
f"No logs to clear for server: {server_name}",
|
|
220
|
+
message_group=group_id,
|
|
221
|
+
)
|
|
222
|
+
return
|
|
223
|
+
|
|
224
|
+
# Clear the logs
|
|
225
|
+
clear_logs(server_name, include_rotated=True)
|
|
226
|
+
|
|
227
|
+
cleared_count = 1 + stats["rotated_count"]
|
|
228
|
+
emit_info(
|
|
229
|
+
f"🗑️ Cleared {cleared_count} log file(s) for **{server_name}**",
|
|
230
|
+
message_group=group_id,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
except Exception as e:
|
|
234
|
+
logger.error(f"Error clearing logs for server '{server_name}': {e}")
|
|
235
|
+
emit_error(f"Error clearing logs: {e}", message_group=group_id)
|
|
@@ -84,6 +84,12 @@ SETTING_DEFINITIONS: Dict[str, Dict] = {
|
|
|
84
84
|
"default": 10000,
|
|
85
85
|
"format": "{:.0f}",
|
|
86
86
|
},
|
|
87
|
+
"interleaved_thinking": {
|
|
88
|
+
"name": "Interleaved Thinking",
|
|
89
|
+
"description": "Enable thinking between tool calls (Claude 4 only: Opus 4.5, Opus 4.1, Opus 4, Sonnet 4). Adds beta header. WARNING: On Vertex/Bedrock, this FAILS for non-Claude 4 models!",
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"default": False,
|
|
92
|
+
},
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
|
code_puppy/keymap.py
CHANGED
|
@@ -86,9 +86,15 @@ def cancel_agent_uses_signal() -> bool:
|
|
|
86
86
|
"""Check if the cancel agent key uses SIGINT (Ctrl+C).
|
|
87
87
|
|
|
88
88
|
Returns:
|
|
89
|
-
True if the cancel key is ctrl+c
|
|
90
|
-
False if it uses keyboard listener approach.
|
|
89
|
+
True if the cancel key is ctrl+c AND we're not on Windows
|
|
90
|
+
(uses SIGINT handler), False if it uses keyboard listener approach.
|
|
91
91
|
"""
|
|
92
|
+
import sys
|
|
93
|
+
|
|
94
|
+
# On Windows, always use keyboard listener - SIGINT is unreliable
|
|
95
|
+
if sys.platform == "win32":
|
|
96
|
+
return False
|
|
97
|
+
|
|
92
98
|
return get_cancel_agent_key() == "ctrl+c"
|
|
93
99
|
|
|
94
100
|
|
code_puppy/mcp_/__init__.py
CHANGED
|
@@ -17,6 +17,15 @@ from .error_isolation import (
|
|
|
17
17
|
)
|
|
18
18
|
from .managed_server import ManagedMCPServer, ServerConfig, ServerState
|
|
19
19
|
from .manager import MCPManager, ServerInfo, get_mcp_manager
|
|
20
|
+
from .mcp_logs import (
|
|
21
|
+
clear_logs,
|
|
22
|
+
get_log_file_path,
|
|
23
|
+
get_log_stats,
|
|
24
|
+
get_mcp_logs_dir,
|
|
25
|
+
list_servers_with_logs,
|
|
26
|
+
read_logs,
|
|
27
|
+
write_log,
|
|
28
|
+
)
|
|
20
29
|
from .registry import ServerRegistry
|
|
21
30
|
from .retry_manager import RetryManager, RetryStats, get_retry_manager, retry_mcp_call
|
|
22
31
|
from .status_tracker import Event, ServerStatusTracker
|
|
@@ -46,4 +55,12 @@ __all__ = [
|
|
|
46
55
|
"MCPDashboard",
|
|
47
56
|
"MCPConfigWizard",
|
|
48
57
|
"run_add_wizard",
|
|
58
|
+
# Log management
|
|
59
|
+
"get_mcp_logs_dir",
|
|
60
|
+
"get_log_file_path",
|
|
61
|
+
"read_logs",
|
|
62
|
+
"write_log",
|
|
63
|
+
"clear_logs",
|
|
64
|
+
"list_servers_with_logs",
|
|
65
|
+
"get_log_stats",
|
|
49
66
|
]
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
MCP Server with blocking startup capability and stderr capture.
|
|
3
3
|
|
|
4
4
|
This module provides MCP servers that:
|
|
5
|
-
1. Capture stderr output from stdio servers
|
|
5
|
+
1. Capture stderr output from stdio servers to persistent log files
|
|
6
6
|
2. Block until fully initialized before allowing operations
|
|
7
|
-
3.
|
|
7
|
+
3. Optionally emit stderr to users (disabled by default to reduce console noise)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import os
|
|
12
|
-
import tempfile
|
|
13
12
|
import threading
|
|
14
13
|
import uuid
|
|
15
14
|
from contextlib import asynccontextmanager
|
|
@@ -18,56 +17,73 @@ from typing import List, Optional
|
|
|
18
17
|
from mcp.client.stdio import StdioServerParameters, stdio_client
|
|
19
18
|
from pydantic_ai.mcp import MCPServerStdio
|
|
20
19
|
|
|
20
|
+
from code_puppy.mcp_.mcp_logs import get_log_file_path, rotate_log_if_needed, write_log
|
|
21
21
|
from code_puppy.messaging import emit_info
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class StderrFileCapture:
|
|
25
|
-
"""
|
|
25
|
+
"""
|
|
26
|
+
Captures stderr to a persistent log file and optionally monitors it.
|
|
27
|
+
|
|
28
|
+
Logs are written to ~/.code_puppy/mcp_logs/<server_name>.log
|
|
29
|
+
"""
|
|
26
30
|
|
|
27
31
|
def __init__(
|
|
28
32
|
self,
|
|
29
33
|
server_name: str,
|
|
30
|
-
emit_to_user: bool =
|
|
34
|
+
emit_to_user: bool = False, # Disabled by default to reduce console noise
|
|
31
35
|
message_group: Optional[uuid.UUID] = None,
|
|
32
36
|
):
|
|
33
37
|
self.server_name = server_name
|
|
34
38
|
self.emit_to_user = emit_to_user
|
|
35
39
|
self.message_group = message_group or uuid.uuid4()
|
|
36
|
-
self.
|
|
37
|
-
self.
|
|
40
|
+
self.log_file = None
|
|
41
|
+
self.log_path = None
|
|
38
42
|
self.monitor_thread = None
|
|
39
43
|
self.stop_monitoring = threading.Event()
|
|
40
44
|
self.captured_lines = []
|
|
45
|
+
self._last_read_pos = 0
|
|
41
46
|
|
|
42
47
|
def start(self):
|
|
43
|
-
"""Start capture by
|
|
44
|
-
#
|
|
45
|
-
self.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
self.
|
|
48
|
+
"""Start capture by opening persistent log file and monitor thread."""
|
|
49
|
+
# Rotate log if needed
|
|
50
|
+
rotate_log_if_needed(self.server_name)
|
|
51
|
+
|
|
52
|
+
# Get persistent log path
|
|
53
|
+
self.log_path = get_log_file_path(self.server_name)
|
|
54
|
+
|
|
55
|
+
# Write startup marker
|
|
56
|
+
write_log(self.server_name, "--- Server starting ---", "INFO")
|
|
49
57
|
|
|
50
|
-
#
|
|
58
|
+
# Open log file for appending stderr
|
|
59
|
+
self.log_file = open(self.log_path, "a", encoding="utf-8")
|
|
60
|
+
|
|
61
|
+
# Start monitoring thread only if we need to emit to user or capture lines
|
|
51
62
|
self.stop_monitoring.clear()
|
|
52
63
|
self.monitor_thread = threading.Thread(target=self._monitor_file)
|
|
53
64
|
self.monitor_thread.daemon = True
|
|
54
65
|
self.monitor_thread.start()
|
|
55
66
|
|
|
56
|
-
return self.
|
|
67
|
+
return self.log_file
|
|
57
68
|
|
|
58
69
|
def _monitor_file(self):
|
|
59
|
-
"""Monitor the
|
|
60
|
-
if not self.
|
|
70
|
+
"""Monitor the log file for new content."""
|
|
71
|
+
if not self.log_path:
|
|
61
72
|
return
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
# Start reading from current position (end of file before we started)
|
|
75
|
+
try:
|
|
76
|
+
self._last_read_pos = os.path.getsize(self.log_path)
|
|
77
|
+
except OSError:
|
|
78
|
+
self._last_read_pos = 0
|
|
79
|
+
|
|
64
80
|
while not self.stop_monitoring.is_set():
|
|
65
81
|
try:
|
|
66
|
-
with open(self.
|
|
67
|
-
f.seek(
|
|
82
|
+
with open(self.log_path, "r", encoding="utf-8", errors="replace") as f:
|
|
83
|
+
f.seek(self._last_read_pos)
|
|
68
84
|
new_content = f.read()
|
|
69
85
|
if new_content:
|
|
70
|
-
|
|
86
|
+
self._last_read_pos = f.tell()
|
|
71
87
|
# Process new lines
|
|
72
88
|
for line in new_content.splitlines():
|
|
73
89
|
if line.strip():
|
|
@@ -89,16 +105,21 @@ class StderrFileCapture:
|
|
|
89
105
|
if self.monitor_thread:
|
|
90
106
|
self.monitor_thread.join(timeout=1)
|
|
91
107
|
|
|
92
|
-
if self.
|
|
108
|
+
if self.log_file:
|
|
93
109
|
try:
|
|
94
|
-
self.
|
|
110
|
+
self.log_file.flush()
|
|
111
|
+
self.log_file.close()
|
|
95
112
|
except Exception:
|
|
96
113
|
pass
|
|
97
114
|
|
|
98
|
-
|
|
115
|
+
# Write shutdown marker
|
|
116
|
+
write_log(self.server_name, "--- Server stopped ---", "INFO")
|
|
117
|
+
|
|
118
|
+
# Read any remaining content for in-memory capture
|
|
119
|
+
if self.log_path and os.path.exists(self.log_path):
|
|
99
120
|
try:
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
with open(self.log_path, "r", encoding="utf-8", errors="replace") as f:
|
|
122
|
+
f.seek(self._last_read_pos)
|
|
102
123
|
content = f.read()
|
|
103
124
|
for line in content.splitlines():
|
|
104
125
|
if line.strip() and line not in self.captured_lines:
|
|
@@ -108,13 +129,13 @@ class StderrFileCapture:
|
|
|
108
129
|
f"MCP {self.server_name}: {line}",
|
|
109
130
|
message_group=self.message_group,
|
|
110
131
|
)
|
|
111
|
-
|
|
112
|
-
os.unlink(self.temp_path)
|
|
113
132
|
except Exception:
|
|
114
133
|
pass
|
|
115
134
|
|
|
135
|
+
# Note: We do NOT delete the log file - it's persistent now!
|
|
136
|
+
|
|
116
137
|
def get_captured_lines(self) -> List[str]:
|
|
117
|
-
"""Get all captured lines."""
|
|
138
|
+
"""Get all captured lines from this session."""
|
|
118
139
|
return self.captured_lines.copy()
|
|
119
140
|
|
|
120
141
|
|
|
@@ -204,7 +204,7 @@ class ManagedMCPServer:
|
|
|
204
204
|
**stdio_kwargs,
|
|
205
205
|
process_tool_call=process_tool_call,
|
|
206
206
|
tool_prefix=self.config.name,
|
|
207
|
-
emit_stderr=
|
|
207
|
+
emit_stderr=False, # Logs go to file, not console (use /mcp logs to view)
|
|
208
208
|
message_group=message_group,
|
|
209
209
|
)
|
|
210
210
|
|