@graphty/remote-logger 1.1.1 → 1.2.0
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.
- package/README.md +318 -10
- package/dist/client/RemoteLogClient.d.ts +2 -0
- package/dist/client/RemoteLogClient.d.ts.map +1 -1
- package/dist/client/RemoteLogClient.js +35 -4
- package/dist/client/RemoteLogClient.js.map +1 -1
- package/dist/client/types.d.ts +13 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/mcp/index.d.ts +9 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +32 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -0
- package/dist/mcp/mcp-server.js +270 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +14 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +14 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/logs-clear.d.ts +76 -0
- package/dist/mcp/tools/logs-clear.d.ts.map +1 -0
- package/dist/mcp/tools/logs-clear.js +58 -0
- package/dist/mcp/tools/logs-clear.js.map +1 -0
- package/dist/mcp/tools/logs-get-all.d.ts +60 -0
- package/dist/mcp/tools/logs-get-all.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-all.js +50 -0
- package/dist/mcp/tools/logs-get-all.js.map +1 -0
- package/dist/mcp/tools/logs-get-errors.d.ts +65 -0
- package/dist/mcp/tools/logs-get-errors.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-errors.js +46 -0
- package/dist/mcp/tools/logs-get-errors.js.map +1 -0
- package/dist/mcp/tools/logs-get-file-path.d.ts +75 -0
- package/dist/mcp/tools/logs-get-file-path.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-file-path.js +90 -0
- package/dist/mcp/tools/logs-get-file-path.js.map +1 -0
- package/dist/mcp/tools/logs-get-recent.d.ts +89 -0
- package/dist/mcp/tools/logs-get-recent.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-recent.js +74 -0
- package/dist/mcp/tools/logs-get-recent.js.map +1 -0
- package/dist/mcp/tools/logs-list-sessions.d.ts +64 -0
- package/dist/mcp/tools/logs-list-sessions.d.ts.map +1 -0
- package/dist/mcp/tools/logs-list-sessions.js +48 -0
- package/dist/mcp/tools/logs-list-sessions.js.map +1 -0
- package/dist/mcp/tools/logs-receive.d.ts +150 -0
- package/dist/mcp/tools/logs-receive.d.ts.map +1 -0
- package/dist/mcp/tools/logs-receive.js +68 -0
- package/dist/mcp/tools/logs-receive.js.map +1 -0
- package/dist/mcp/tools/logs-search.d.ts +91 -0
- package/dist/mcp/tools/logs-search.d.ts.map +1 -0
- package/dist/mcp/tools/logs-search.js +68 -0
- package/dist/mcp/tools/logs-search.js.map +1 -0
- package/dist/mcp/tools/logs-status.d.ts +45 -0
- package/dist/mcp/tools/logs-status.d.ts.map +1 -0
- package/dist/mcp/tools/logs-status.js +45 -0
- package/dist/mcp/tools/logs-status.js.map +1 -0
- package/dist/server/dual-server.d.ts +76 -0
- package/dist/server/dual-server.d.ts.map +1 -0
- package/dist/server/dual-server.js +214 -0
- package/dist/server/dual-server.js.map +1 -0
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/jsonl-writer.d.ts +93 -0
- package/dist/server/jsonl-writer.d.ts.map +1 -0
- package/dist/server/jsonl-writer.js +205 -0
- package/dist/server/jsonl-writer.js.map +1 -0
- package/dist/server/log-server.d.ts +62 -11
- package/dist/server/log-server.d.ts.map +1 -1
- package/dist/server/log-server.js +237 -101
- package/dist/server/log-server.js.map +1 -1
- package/dist/server/log-storage.d.ts +301 -0
- package/dist/server/log-storage.d.ts.map +1 -0
- package/dist/server/log-storage.js +408 -0
- package/dist/server/log-storage.js.map +1 -0
- package/dist/server/marker-utils.d.ts +69 -0
- package/dist/server/marker-utils.d.ts.map +1 -0
- package/dist/server/marker-utils.js +118 -0
- package/dist/server/marker-utils.js.map +1 -0
- package/dist/vite/index.d.ts +8 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +8 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/plugin.d.ts +42 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +46 -0
- package/dist/vite/plugin.js.map +1 -0
- package/package.json +12 -2
- package/src/client/RemoteLogClient.ts +52 -4
- package/src/client/types.ts +13 -0
- package/src/mcp/index.ts +25 -0
- package/src/mcp/mcp-server.ts +364 -0
- package/src/mcp/tools/index.ts +69 -0
- package/src/mcp/tools/logs-clear.ts +86 -0
- package/src/mcp/tools/logs-get-all.ts +78 -0
- package/src/mcp/tools/logs-get-errors.ts +71 -0
- package/src/mcp/tools/logs-get-file-path.ts +121 -0
- package/src/mcp/tools/logs-get-recent.ts +104 -0
- package/src/mcp/tools/logs-list-sessions.ts +71 -0
- package/src/mcp/tools/logs-receive.ts +96 -0
- package/src/mcp/tools/logs-search.ts +95 -0
- package/src/mcp/tools/logs-status.ts +69 -0
- package/src/server/dual-server.ts +308 -0
- package/src/server/index.ts +37 -0
- package/src/server/jsonl-writer.ts +277 -0
- package/src/server/log-server.ts +311 -119
- package/src/server/log-storage.ts +651 -0
- package/src/server/marker-utils.ts +144 -0
- package/src/vite/index.ts +8 -0
- package/src/vite/plugin.ts +59 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server for remote logging.
|
|
3
|
+
*
|
|
4
|
+
* Provides an MCP interface for Claude Code to query logs from browser
|
|
5
|
+
* applications. Uses STDIO transport for communication.
|
|
6
|
+
* @module mcp/mcp-server
|
|
7
|
+
*/
|
|
8
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
+
import { logsClearHandler, logsClearInputSchema, logsClearTool, logsGetAllHandler, logsGetAllInputSchema, logsGetAllTool, logsGetErrorsHandler, logsGetErrorsInputSchema, logsGetErrorsTool, logsGetFilePathHandler, logsGetFilePathInputSchema, logsGetFilePathTool, logsGetRecentHandler, logsGetRecentInputSchema, logsGetRecentTool, logsListSessionsHandler, logsListSessionsInputSchema, logsListSessionsTool, logsReceiveHandler, logsReceiveInputSchema, logsReceiveTool, logsSearchHandler, logsSearchInputSchema, logsSearchTool, logsStatusHandler, logsStatusTool, } from "./tools/index.js";
|
|
11
|
+
// Track registered tool names for testing
|
|
12
|
+
let registeredTools = [];
|
|
13
|
+
/**
|
|
14
|
+
* Get the names of all registered tools.
|
|
15
|
+
* Useful for testing.
|
|
16
|
+
* @returns Array of registered tool names
|
|
17
|
+
*/
|
|
18
|
+
export function getToolNames() {
|
|
19
|
+
return [...registeredTools];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Server instructions for LLMs describing the overall purpose and usage.
|
|
23
|
+
*/
|
|
24
|
+
const SERVER_INSTRUCTIONS = `Remote Logger MCP Server - View console.log output from browser applications.
|
|
25
|
+
|
|
26
|
+
## What is Remote Logging?
|
|
27
|
+
|
|
28
|
+
Browser applications run in a sandbox - their console.log() output appears in browser DevTools but is NOT visible to CLI tools or this assistant. Remote logging bridges this gap by sending browser logs to a server where they can be queried.
|
|
29
|
+
|
|
30
|
+
## When to Use Remote Logging
|
|
31
|
+
|
|
32
|
+
Use this when debugging applications where developer tools aren't easily accessible:
|
|
33
|
+
- Storybook components (stories running in browser)
|
|
34
|
+
- Web applications during development
|
|
35
|
+
- Mobile web apps (phones, tablets) where DevTools requires USB debugging
|
|
36
|
+
- VR/AR applications where you can't see a console while wearing a headset
|
|
37
|
+
- Embedded devices, kiosks, or smart displays without keyboard access
|
|
38
|
+
- Any JavaScript running in a browser context
|
|
39
|
+
|
|
40
|
+
Remote logging is especially valuable for LLM assistants like this one - it enables reading, interpreting, and acting on application logs without requiring user interaction with browser DevTools.
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+
Browser App → HTTP POST to /logs → Log Server (stores in memory + JSONL files) → MCP Tools (query logs)
|
|
45
|
+
|
|
46
|
+
## Setting Up a Browser App to Send Logs
|
|
47
|
+
|
|
48
|
+
First, get the server endpoint URL by calling logs_status - look for server.httpEndpoint in the response.
|
|
49
|
+
|
|
50
|
+
### Option 1: Using the RemoteLogClient SDK (Recommended)
|
|
51
|
+
|
|
52
|
+
Install: npm install @graphty/remote-logger
|
|
53
|
+
|
|
54
|
+
\`\`\`typescript
|
|
55
|
+
import { RemoteLogClient } from "@graphty/remote-logger";
|
|
56
|
+
|
|
57
|
+
const logger = new RemoteLogClient({
|
|
58
|
+
serverUrl: "http://localhost:9080/logs", // Get this from logs_status
|
|
59
|
+
projectMarker: "my-project", // Optional: for filtering
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Intercept all console.log/warn/error calls
|
|
63
|
+
logger.interceptConsole();
|
|
64
|
+
|
|
65
|
+
// Or log manually
|
|
66
|
+
logger.log("INFO", "Hello from browser!");
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
### Option 2: Raw fetch() calls
|
|
70
|
+
|
|
71
|
+
\`\`\`typescript
|
|
72
|
+
fetch("http://localhost:9080/logs", {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "Content-Type": "application/json" },
|
|
75
|
+
body: JSON.stringify({
|
|
76
|
+
sessionId: "unique-session-id",
|
|
77
|
+
logs: [
|
|
78
|
+
{ time: new Date().toISOString(), level: "INFO", message: "Hello!" }
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
## Querying Logs (MCP Tools)
|
|
85
|
+
|
|
86
|
+
Once browser logs are flowing to the server:
|
|
87
|
+
|
|
88
|
+
1. logs_status - Check server health, get endpoint URL, see retention settings
|
|
89
|
+
2. logs_get_recent - View recent logs (primary tool, sorted chronologically)
|
|
90
|
+
3. logs_get_errors - Quick filter for ERROR level only
|
|
91
|
+
4. logs_search - Find specific text (supports regex)
|
|
92
|
+
5. logs_list_sessions - See all browser sessions
|
|
93
|
+
6. logs_get_all - Get all logs grouped by session
|
|
94
|
+
7. logs_get_file_path - Get JSONL file path for Grep/Read tools
|
|
95
|
+
8. logs_clear - Delete logs (requires confirmation)
|
|
96
|
+
|
|
97
|
+
## Typical Debugging Workflow
|
|
98
|
+
|
|
99
|
+
1. Call logs_status to verify server is running and get the endpoint URL
|
|
100
|
+
2. Ensure the browser app is configured to send logs to that endpoint
|
|
101
|
+
3. Trigger the action in the browser you want to debug
|
|
102
|
+
4. Call logs_get_recent to see what happened
|
|
103
|
+
5. Use logs_search if looking for specific errors or messages`;
|
|
104
|
+
/**
|
|
105
|
+
* Create an MCP server with logging tools.
|
|
106
|
+
*
|
|
107
|
+
* Registers all logging tools and returns the configured server.
|
|
108
|
+
* The server is not started; use `startMcpServer` to run it.
|
|
109
|
+
* @param storage - The LogStorage instance to use for log operations
|
|
110
|
+
* @returns Configured McpServer instance
|
|
111
|
+
*/
|
|
112
|
+
export function createMcpServer(storage) {
|
|
113
|
+
const server = new McpServer({
|
|
114
|
+
name: "remote-logger",
|
|
115
|
+
version: "1.0.0",
|
|
116
|
+
}, {
|
|
117
|
+
instructions: SERVER_INSTRUCTIONS,
|
|
118
|
+
});
|
|
119
|
+
// Reset registered tools
|
|
120
|
+
registeredTools = [];
|
|
121
|
+
// Register logs_get_recent tool
|
|
122
|
+
server.registerTool(logsGetRecentTool.name, {
|
|
123
|
+
description: logsGetRecentTool.description,
|
|
124
|
+
inputSchema: logsGetRecentInputSchema,
|
|
125
|
+
}, (args) => {
|
|
126
|
+
return logsGetRecentHandler(storage, args).then((r) => ({
|
|
127
|
+
content: [
|
|
128
|
+
{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: JSON.stringify(r, null, 2),
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
registeredTools.push(logsGetRecentTool.name);
|
|
136
|
+
// Register logs_status tool
|
|
137
|
+
server.registerTool(logsStatusTool.name, {
|
|
138
|
+
description: logsStatusTool.description,
|
|
139
|
+
}, () => {
|
|
140
|
+
return logsStatusHandler(storage).then((r) => ({
|
|
141
|
+
content: [
|
|
142
|
+
{
|
|
143
|
+
type: "text",
|
|
144
|
+
text: JSON.stringify(r, null, 2),
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
}));
|
|
148
|
+
});
|
|
149
|
+
registeredTools.push(logsStatusTool.name);
|
|
150
|
+
// Register logs_list_sessions tool
|
|
151
|
+
server.registerTool(logsListSessionsTool.name, {
|
|
152
|
+
description: logsListSessionsTool.description,
|
|
153
|
+
inputSchema: logsListSessionsInputSchema,
|
|
154
|
+
}, (args) => {
|
|
155
|
+
return logsListSessionsHandler(storage, args).then((r) => ({
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: "text",
|
|
159
|
+
text: JSON.stringify(r, null, 2),
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
}));
|
|
163
|
+
});
|
|
164
|
+
registeredTools.push(logsListSessionsTool.name);
|
|
165
|
+
// Register logs_receive tool
|
|
166
|
+
server.registerTool(logsReceiveTool.name, {
|
|
167
|
+
description: logsReceiveTool.description,
|
|
168
|
+
inputSchema: logsReceiveInputSchema,
|
|
169
|
+
}, (args) => {
|
|
170
|
+
return logsReceiveHandler(storage, args).then((r) => ({
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
type: "text",
|
|
174
|
+
text: JSON.stringify(r, null, 2),
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
}));
|
|
178
|
+
});
|
|
179
|
+
registeredTools.push(logsReceiveTool.name);
|
|
180
|
+
// Register logs_get_all tool
|
|
181
|
+
server.registerTool(logsGetAllTool.name, {
|
|
182
|
+
description: logsGetAllTool.description,
|
|
183
|
+
inputSchema: logsGetAllInputSchema,
|
|
184
|
+
}, (args) => {
|
|
185
|
+
return logsGetAllHandler(storage, args).then((r) => ({
|
|
186
|
+
content: [
|
|
187
|
+
{
|
|
188
|
+
type: "text",
|
|
189
|
+
text: JSON.stringify(r, null, 2),
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
}));
|
|
193
|
+
});
|
|
194
|
+
registeredTools.push(logsGetAllTool.name);
|
|
195
|
+
// Register logs_get_errors tool
|
|
196
|
+
server.registerTool(logsGetErrorsTool.name, {
|
|
197
|
+
description: logsGetErrorsTool.description,
|
|
198
|
+
inputSchema: logsGetErrorsInputSchema,
|
|
199
|
+
}, (args) => {
|
|
200
|
+
return logsGetErrorsHandler(storage, args).then((r) => ({
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: "text",
|
|
204
|
+
text: JSON.stringify(r, null, 2),
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
209
|
+
registeredTools.push(logsGetErrorsTool.name);
|
|
210
|
+
// Register logs_clear tool
|
|
211
|
+
server.registerTool(logsClearTool.name, {
|
|
212
|
+
description: logsClearTool.description,
|
|
213
|
+
inputSchema: logsClearInputSchema,
|
|
214
|
+
}, (args) => {
|
|
215
|
+
return logsClearHandler(storage, args).then((r) => ({
|
|
216
|
+
content: [
|
|
217
|
+
{
|
|
218
|
+
type: "text",
|
|
219
|
+
text: JSON.stringify(r, null, 2),
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
}));
|
|
223
|
+
});
|
|
224
|
+
registeredTools.push(logsClearTool.name);
|
|
225
|
+
// Register logs_search tool
|
|
226
|
+
server.registerTool(logsSearchTool.name, {
|
|
227
|
+
description: logsSearchTool.description,
|
|
228
|
+
inputSchema: logsSearchInputSchema,
|
|
229
|
+
}, (args) => {
|
|
230
|
+
return logsSearchHandler(storage, args).then((r) => ({
|
|
231
|
+
content: [
|
|
232
|
+
{
|
|
233
|
+
type: "text",
|
|
234
|
+
text: JSON.stringify(r, null, 2),
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
}));
|
|
238
|
+
});
|
|
239
|
+
registeredTools.push(logsSearchTool.name);
|
|
240
|
+
// Register logs_get_file_path tool
|
|
241
|
+
server.registerTool(logsGetFilePathTool.name, {
|
|
242
|
+
description: logsGetFilePathTool.description,
|
|
243
|
+
inputSchema: logsGetFilePathInputSchema,
|
|
244
|
+
}, (args) => {
|
|
245
|
+
return logsGetFilePathHandler(storage, args).then((r) => ({
|
|
246
|
+
content: [
|
|
247
|
+
{
|
|
248
|
+
type: "text",
|
|
249
|
+
text: JSON.stringify(r, null, 2),
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
}));
|
|
253
|
+
});
|
|
254
|
+
registeredTools.push(logsGetFilePathTool.name);
|
|
255
|
+
return server;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Start the MCP server with STDIO transport.
|
|
259
|
+
*
|
|
260
|
+
* This function runs the MCP server and blocks until the connection is closed.
|
|
261
|
+
* @param storage - The LogStorage instance to use for log operations
|
|
262
|
+
*/
|
|
263
|
+
export async function startMcpServer(storage) {
|
|
264
|
+
const server = createMcpServer(storage);
|
|
265
|
+
const transport = new StdioServerTransport();
|
|
266
|
+
await server.connect(transport);
|
|
267
|
+
// Keep the process alive
|
|
268
|
+
// The connection will handle cleanup when stdin closes
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/mcp/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EACH,gBAAgB,EAEhB,oBAAoB,EACp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CAAC,CAAC;IACR,CAAC,CACJ,CAAC;IACF,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,mCAAmC;IACnC,MAAM,CAAC,YAAY,CACf,mBAAmB,CAAC,IAAI,EACxB;QACI,WAAW,EAAE,mBAAmB,CAAC,WAAW;QAC5C,WAAW,EAAE,0BAA0B;KAC1C,EACD,CAAC,IAA0B,EAAE,EAAE;QAC3B,OAAO,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtD,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;iBACnC;aACJ;SACJ,CAAC,CAAC,CAAC;IACR,CAAC,CACJ,CAAC;IACF,eAAe,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAmB;IACpD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,yBAAyB;IACzB,uDAAuD;AAC3D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exports and registration.
|
|
3
|
+
* @module mcp/tools
|
|
4
|
+
*/
|
|
5
|
+
export { logsClearHandler, type LogsClearInput, logsClearInputSchema, type LogsClearOutput, logsClearTool, } from "./logs-clear.js";
|
|
6
|
+
export { logsGetAllHandler, type LogsGetAllInput, logsGetAllInputSchema, type LogsGetAllOutput, logsGetAllTool, } from "./logs-get-all.js";
|
|
7
|
+
export { logsGetErrorsHandler, type LogsGetErrorsInput, logsGetErrorsInputSchema, type LogsGetErrorsOutput, logsGetErrorsTool, } from "./logs-get-errors.js";
|
|
8
|
+
export { getLogFilePath, logsGetFilePathHandler, type LogsGetFilePathInput, logsGetFilePathInputSchema, type LogsGetFilePathOutput, logsGetFilePathTool, } from "./logs-get-file-path.js";
|
|
9
|
+
export { logsGetRecentHandler, type LogsGetRecentInput, logsGetRecentInputSchema, type LogsGetRecentOutput, logsGetRecentTool, } from "./logs-get-recent.js";
|
|
10
|
+
export { logsListSessionsHandler, type LogsListSessionsInput, logsListSessionsInputSchema, type LogsListSessionsOutput, logsListSessionsTool, } from "./logs-list-sessions.js";
|
|
11
|
+
export { logsReceiveHandler, type LogsReceiveInput, logsReceiveInputSchema, type LogsReceiveOutput, logsReceiveTool, } from "./logs-receive.js";
|
|
12
|
+
export { logsSearchHandler, type LogsSearchInput, logsSearchInputSchema, type LogsSearchOutput, logsSearchTool, } from "./logs-search.js";
|
|
13
|
+
export { logsStatusHandler, type LogsStatusInput, logsStatusInputSchema, type LogsStatusOutput, logsStatusTool, } from "./logs-status.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAChB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,aAAa,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,iBAAiB,EACjB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,cAAc,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,iBAAiB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,cAAc,EACd,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,iBAAiB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,oBAAoB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,eAAe,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,iBAAiB,EACjB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,cAAc,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,iBAAiB,EACjB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,cAAc,GACjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool exports and registration.
|
|
3
|
+
* @module mcp/tools
|
|
4
|
+
*/
|
|
5
|
+
export { logsClearHandler, logsClearInputSchema, logsClearTool, } from "./logs-clear.js";
|
|
6
|
+
export { logsGetAllHandler, logsGetAllInputSchema, logsGetAllTool, } from "./logs-get-all.js";
|
|
7
|
+
export { logsGetErrorsHandler, logsGetErrorsInputSchema, logsGetErrorsTool, } from "./logs-get-errors.js";
|
|
8
|
+
export { getLogFilePath, logsGetFilePathHandler, logsGetFilePathInputSchema, logsGetFilePathTool, } from "./logs-get-file-path.js";
|
|
9
|
+
export { logsGetRecentHandler, logsGetRecentInputSchema, logsGetRecentTool, } from "./logs-get-recent.js";
|
|
10
|
+
export { logsListSessionsHandler, logsListSessionsInputSchema, logsListSessionsTool, } from "./logs-list-sessions.js";
|
|
11
|
+
export { logsReceiveHandler, logsReceiveInputSchema, logsReceiveTool, } from "./logs-receive.js";
|
|
12
|
+
export { logsSearchHandler, logsSearchInputSchema, logsSearchTool, } from "./logs-search.js";
|
|
13
|
+
export { logsStatusHandler, logsStatusInputSchema, logsStatusTool, } from "./logs-status.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAEhB,oBAAoB,EAEpB,aAAa,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,iBAAiB,EAEjB,qBAAqB,EAErB,cAAc,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,oBAAoB,EAEpB,wBAAwB,EAExB,iBAAiB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,cAAc,EACd,sBAAsB,EAEtB,0BAA0B,EAE1B,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,oBAAoB,EAEpB,wBAAwB,EAExB,iBAAiB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,uBAAuB,EAEvB,2BAA2B,EAE3B,oBAAoB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,kBAAkB,EAElB,sBAAsB,EAEtB,eAAe,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,iBAAiB,EAEjB,qBAAqB,EAErB,cAAc,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,iBAAiB,EAEjB,qBAAqB,EAErB,cAAc,GACjB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* logs_clear MCP tool implementation.
|
|
3
|
+
*
|
|
4
|
+
* Clears logs with confirmation requirement for safety.
|
|
5
|
+
* @module mcp/tools/logs-clear
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v3";
|
|
8
|
+
import type { LogStorage } from "../../server/log-storage.js";
|
|
9
|
+
/**
|
|
10
|
+
* Input schema for the logs_clear tool.
|
|
11
|
+
*/
|
|
12
|
+
export declare const logsClearInputSchema: z.ZodObject<{
|
|
13
|
+
/** Safety flag: must be set to true for the operation to proceed. Prevents accidental deletion. */
|
|
14
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
/** Clear only logs for this project. Clears all projects if omitted. */
|
|
16
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
17
|
+
/** Clear only logs for this specific session. Clears all sessions if omitted. */
|
|
18
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
sessionId?: string | undefined;
|
|
21
|
+
projectMarker?: string | undefined;
|
|
22
|
+
confirm?: boolean | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
sessionId?: string | undefined;
|
|
25
|
+
projectMarker?: string | undefined;
|
|
26
|
+
confirm?: boolean | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Input type for the logs_clear handler.
|
|
30
|
+
*/
|
|
31
|
+
export type LogsClearInput = z.infer<typeof logsClearInputSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* Output type for the logs_clear handler.
|
|
34
|
+
*/
|
|
35
|
+
export interface LogsClearOutput {
|
|
36
|
+
/** Whether the operation succeeded */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** Number of sessions cleared */
|
|
39
|
+
cleared: number;
|
|
40
|
+
/** Error message if operation failed */
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handler for the logs_clear tool.
|
|
45
|
+
*
|
|
46
|
+
* Clears logs with optional filtering. Requires explicit confirmation
|
|
47
|
+
* to prevent accidental data loss.
|
|
48
|
+
* @param storage - The log storage instance
|
|
49
|
+
* @param input - Input parameters
|
|
50
|
+
* @returns Success status and count of cleared sessions
|
|
51
|
+
*/
|
|
52
|
+
export declare function logsClearHandler(storage: LogStorage, input: Partial<LogsClearInput>): Promise<LogsClearOutput>;
|
|
53
|
+
/**
|
|
54
|
+
* Tool definition for MCP registration.
|
|
55
|
+
*/
|
|
56
|
+
export declare const logsClearTool: {
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
inputSchema: z.ZodObject<{
|
|
60
|
+
/** Safety flag: must be set to true for the operation to proceed. Prevents accidental deletion. */
|
|
61
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
/** Clear only logs for this project. Clears all projects if omitted. */
|
|
63
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
64
|
+
/** Clear only logs for this specific session. Clears all sessions if omitted. */
|
|
65
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
sessionId?: string | undefined;
|
|
68
|
+
projectMarker?: string | undefined;
|
|
69
|
+
confirm?: boolean | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
sessionId?: string | undefined;
|
|
72
|
+
projectMarker?: string | undefined;
|
|
73
|
+
confirm?: boolean | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=logs-clear.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-clear.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/logs-clear.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC7B,mGAAmG;;IAEnG,wEAAwE;;IAExE,iFAAiF;;;;;;;;;;EAEnF,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAC/B,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;;QA7DtB,mGAAmG;;QAEnG,wEAAwE;;QAExE,iFAAiF;;;;;;;;;;;CAkEpF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* logs_clear MCP tool implementation.
|
|
3
|
+
*
|
|
4
|
+
* Clears logs with confirmation requirement for safety.
|
|
5
|
+
* @module mcp/tools/logs-clear
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v3";
|
|
8
|
+
/**
|
|
9
|
+
* Input schema for the logs_clear tool.
|
|
10
|
+
*/
|
|
11
|
+
export const logsClearInputSchema = z.object({
|
|
12
|
+
/** Safety flag: must be set to true for the operation to proceed. Prevents accidental deletion. */
|
|
13
|
+
confirm: z.boolean().optional(),
|
|
14
|
+
/** Clear only logs for this project. Clears all projects if omitted. */
|
|
15
|
+
projectMarker: z.string().optional(),
|
|
16
|
+
/** Clear only logs for this specific session. Clears all sessions if omitted. */
|
|
17
|
+
sessionId: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Handler for the logs_clear tool.
|
|
21
|
+
*
|
|
22
|
+
* Clears logs with optional filtering. Requires explicit confirmation
|
|
23
|
+
* to prevent accidental data loss.
|
|
24
|
+
* @param storage - The log storage instance
|
|
25
|
+
* @param input - Input parameters
|
|
26
|
+
* @returns Success status and count of cleared sessions
|
|
27
|
+
*/
|
|
28
|
+
export function logsClearHandler(storage, input) {
|
|
29
|
+
// Require explicit confirmation
|
|
30
|
+
if (input.confirm !== true) {
|
|
31
|
+
return Promise.resolve({
|
|
32
|
+
success: false,
|
|
33
|
+
cleared: 0,
|
|
34
|
+
error: "Operation requires confirm: true to proceed. This prevents accidental data loss.",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const result = storage.clearLogs({
|
|
38
|
+
projectMarker: input.projectMarker,
|
|
39
|
+
sessionId: input.sessionId,
|
|
40
|
+
});
|
|
41
|
+
return Promise.resolve({
|
|
42
|
+
success: true,
|
|
43
|
+
cleared: result.cleared,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Tool definition for MCP registration.
|
|
48
|
+
*/
|
|
49
|
+
export const logsClearTool = {
|
|
50
|
+
name: "logs_clear",
|
|
51
|
+
description: "Clear logs from the server. " +
|
|
52
|
+
"Requires confirm: true to proceed - this prevents accidental data loss. " +
|
|
53
|
+
"Can optionally filter by projectMarker to clear only one project, " +
|
|
54
|
+
"or by sessionId to clear a specific session. " +
|
|
55
|
+
"Without filters, clears ALL logs.",
|
|
56
|
+
inputSchema: logsClearInputSchema,
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=logs-clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-clear.js","sourceRoot":"","sources":["../../../src/mcp/tools/logs-clear.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,mGAAmG;IACnG,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,wEAAwE;IACxE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,iFAAiF;IACjF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAmBH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC5B,OAAmB,EACnB,KAA8B;IAE9B,gCAAgC;IAChC,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,kFAAkF;SAC5F,CAAC,CAAC;IACP,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;QAC7B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,OAAO,CAAC;QACnB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;KAC1B,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,IAAI,EAAE,YAAY;IAClB,WAAW,EACP,8BAA8B;QAC9B,0EAA0E;QAC1E,oEAAoE;QACpE,+CAA+C;QAC/C,mCAAmC;IACvC,WAAW,EAAE,oBAAoB;CACpC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* logs_get_all MCP tool implementation.
|
|
3
|
+
*
|
|
4
|
+
* Returns all logs grouped by session.
|
|
5
|
+
* @module mcp/tools/logs-get-all
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v3";
|
|
8
|
+
import type { LogEntry, LogStorage } from "../../server/log-storage.js";
|
|
9
|
+
/**
|
|
10
|
+
* Input schema for the logs_get_all tool.
|
|
11
|
+
*/
|
|
12
|
+
export declare const logsGetAllInputSchema: z.ZodObject<{
|
|
13
|
+
/** Filter results to a specific project identifier. Returns all projects if omitted. */
|
|
14
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
projectMarker?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
projectMarker?: string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Input type for the logs_get_all handler.
|
|
22
|
+
*/
|
|
23
|
+
export type LogsGetAllInput = z.infer<typeof logsGetAllInputSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Output type for the logs_get_all handler.
|
|
26
|
+
*/
|
|
27
|
+
export interface LogsGetAllOutput {
|
|
28
|
+
/** Logs grouped by session ID */
|
|
29
|
+
sessions: Record<string, LogEntry[]>;
|
|
30
|
+
/** Number of sessions */
|
|
31
|
+
sessionCount: number;
|
|
32
|
+
/** Total number of logs across all sessions */
|
|
33
|
+
totalLogs: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Handler for the logs_get_all tool.
|
|
37
|
+
*
|
|
38
|
+
* Returns all logs grouped by session ID, with optional filtering by
|
|
39
|
+
* project marker.
|
|
40
|
+
* @param storage - The log storage instance
|
|
41
|
+
* @param input - Input parameters
|
|
42
|
+
* @returns Logs grouped by session
|
|
43
|
+
*/
|
|
44
|
+
export declare function logsGetAllHandler(storage: LogStorage, input: Partial<LogsGetAllInput>): Promise<LogsGetAllOutput>;
|
|
45
|
+
/**
|
|
46
|
+
* Tool definition for MCP registration.
|
|
47
|
+
*/
|
|
48
|
+
export declare const logsGetAllTool: {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
inputSchema: z.ZodObject<{
|
|
52
|
+
/** Filter results to a specific project identifier. Returns all projects if omitted. */
|
|
53
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
projectMarker?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
projectMarker?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=logs-get-all.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-get-all.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/logs-get-all.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAC9B,wFAAwF;;;;;;EAE1F,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrC,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAgB3B;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;QAtDvB,wFAAwF;;;;;;;CA8D3F,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* logs_get_all MCP tool implementation.
|
|
3
|
+
*
|
|
4
|
+
* Returns all logs grouped by session.
|
|
5
|
+
* @module mcp/tools/logs-get-all
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v3";
|
|
8
|
+
/**
|
|
9
|
+
* Input schema for the logs_get_all tool.
|
|
10
|
+
*/
|
|
11
|
+
export const logsGetAllInputSchema = z.object({
|
|
12
|
+
/** Filter results to a specific project identifier. Returns all projects if omitted. */
|
|
13
|
+
projectMarker: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Handler for the logs_get_all tool.
|
|
17
|
+
*
|
|
18
|
+
* Returns all logs grouped by session ID, with optional filtering by
|
|
19
|
+
* project marker.
|
|
20
|
+
* @param storage - The log storage instance
|
|
21
|
+
* @param input - Input parameters
|
|
22
|
+
* @returns Logs grouped by session
|
|
23
|
+
*/
|
|
24
|
+
export function logsGetAllHandler(storage, input) {
|
|
25
|
+
const sessions = storage.getAllLogsBySession({
|
|
26
|
+
projectMarker: input.projectMarker,
|
|
27
|
+
});
|
|
28
|
+
// Calculate totals
|
|
29
|
+
let totalLogs = 0;
|
|
30
|
+
for (const logs of Object.values(sessions)) {
|
|
31
|
+
totalLogs += logs.length;
|
|
32
|
+
}
|
|
33
|
+
return Promise.resolve({
|
|
34
|
+
sessions,
|
|
35
|
+
sessionCount: Object.keys(sessions).length,
|
|
36
|
+
totalLogs,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Tool definition for MCP registration.
|
|
41
|
+
*/
|
|
42
|
+
export const logsGetAllTool = {
|
|
43
|
+
name: "logs_get_all",
|
|
44
|
+
description: "Get all logs grouped by session. " +
|
|
45
|
+
"Use this to see a complete view of logging activity across all browser sessions. " +
|
|
46
|
+
"Returns logs organized by session ID, making it easy to trace activity per browser tab. " +
|
|
47
|
+
"For a flat list of recent logs, use logs_get_recent instead.",
|
|
48
|
+
inputSchema: logsGetAllInputSchema,
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=logs-get-all.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-get-all.js","sourceRoot":"","sources":["../../../src/mcp/tools/logs-get-all.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,wFAAwF;IACxF,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAmBH;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC7B,OAAmB,EACnB,KAA+B;IAE/B,MAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC;QACzC,aAAa,EAAE,KAAK,CAAC,aAAa;KACrC,CAAC,CAAC;IAEH,mBAAmB;IACnB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC;QACnB,QAAQ;QACR,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;QAC1C,SAAS;KACZ,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,WAAW,EACP,mCAAmC;QACnC,mFAAmF;QACnF,0FAA0F;QAC1F,8DAA8D;IAClE,WAAW,EAAE,qBAAqB;CACrC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* logs_get_errors MCP tool implementation.
|
|
3
|
+
*
|
|
4
|
+
* Returns only ERROR level logs.
|
|
5
|
+
* @module mcp/tools/logs-get-errors
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v3";
|
|
8
|
+
import type { LogEntryWithSession, LogStorage } from "../../server/log-storage.js";
|
|
9
|
+
/**
|
|
10
|
+
* Input schema for the logs_get_errors tool.
|
|
11
|
+
*/
|
|
12
|
+
export declare const logsGetErrorsInputSchema: z.ZodObject<{
|
|
13
|
+
/** Filter errors to a specific project identifier. Returns all projects if omitted. */
|
|
14
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
15
|
+
/** Return only errors after this timestamp. Format: ISO 8601 (e.g., "2025-01-08T12:00:00Z"). */
|
|
16
|
+
since: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
projectMarker?: string | undefined;
|
|
19
|
+
since?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
projectMarker?: string | undefined;
|
|
22
|
+
since?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Input type for the logs_get_errors handler.
|
|
26
|
+
*/
|
|
27
|
+
export type LogsGetErrorsInput = z.infer<typeof logsGetErrorsInputSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Output type for the logs_get_errors handler.
|
|
30
|
+
*/
|
|
31
|
+
export interface LogsGetErrorsOutput {
|
|
32
|
+
/** Array of ERROR level log entries */
|
|
33
|
+
errors: LogEntryWithSession[];
|
|
34
|
+
/** Number of errors returned */
|
|
35
|
+
count: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Handler for the logs_get_errors tool.
|
|
39
|
+
*
|
|
40
|
+
* Returns only ERROR level logs, sorted chronologically.
|
|
41
|
+
* @param storage - The log storage instance
|
|
42
|
+
* @param input - Input parameters
|
|
43
|
+
* @returns Error logs and count
|
|
44
|
+
*/
|
|
45
|
+
export declare function logsGetErrorsHandler(storage: LogStorage, input: Partial<LogsGetErrorsInput>): Promise<LogsGetErrorsOutput>;
|
|
46
|
+
/**
|
|
47
|
+
* Tool definition for MCP registration.
|
|
48
|
+
*/
|
|
49
|
+
export declare const logsGetErrorsTool: {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
inputSchema: z.ZodObject<{
|
|
53
|
+
/** Filter errors to a specific project identifier. Returns all projects if omitted. */
|
|
54
|
+
projectMarker: z.ZodOptional<z.ZodString>;
|
|
55
|
+
/** Return only errors after this timestamp. Format: ISO 8601 (e.g., "2025-01-08T12:00:00Z"). */
|
|
56
|
+
since: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
projectMarker?: string | undefined;
|
|
59
|
+
since?: string | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
projectMarker?: string | undefined;
|
|
62
|
+
since?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=logs-get-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-get-errors.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/logs-get-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,wBAAwB;IACjC,uFAAuF;;IAEvF,gGAAgG;;;;;;;;EAElG,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,uCAAuC;IACvC,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;QA/C1B,uFAAuF;;QAEvF,gGAAgG;;;;;;;;;CAqDnG,CAAC"}
|