mcp-log-query-server 3.7.0 → 3.8.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/config.js CHANGED
@@ -63,6 +63,15 @@ export const SERVICES = {
63
63
  logFile: 'normal.log',
64
64
  aliases: ['assess', '评估']
65
65
  },
66
+ 'clife-senior-care-assistant-bff': {
67
+ name: 'clife-senior-care-assistant-bff',
68
+ description: '养老照护助手BFF服务',
69
+ namespace: 'saas-itest',
70
+ podPattern: 'clife-senior-care-assistant-bff-app',
71
+ logPath: '/www/logs/clife-senior-care-assistant-bff-app/normal_logs',
72
+ logFile: 'normal.log',
73
+ aliases: ['care-assistant-bff', 'care-assistant', 'care-bff', '照护助手', '照护助手BFF', '照护BFF']
74
+ },
66
75
  'clife-senior-common': {
67
76
  name: 'clife-senior-common',
68
77
  description: '养老公共服务',
@@ -140,8 +149,8 @@ export const SERVICES = {
140
149
  description: '养老设备告警服务',
141
150
  namespace: 'saas-itest',
142
151
  podPattern: 'clife-senior-device-warn-app',
143
- logPath: '/www/logs/clife-senior-device-warn-app/normal_logs',
144
- logFile: 'normal.log',
152
+ logPath: '/www/logs/clife-senior-device-warn-app',
153
+ logFile: 'application.out',
145
154
  aliases: ['device-warn', '设备告警']
146
155
  },
147
156
  'clife-senior-dispatch': {
package/index.js CHANGED
@@ -332,6 +332,30 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
332
332
  required: ['workspace_path']
333
333
  }
334
334
  },
335
+ // ========== 自定义命令工具 ==========
336
+ {
337
+ name: 'exec_in_pod',
338
+ description: '在指定 pod 内执行自定义命令。适用于日志文件路径不在默认配置中、需要 ls/cat/wc 等探索性操作、或需要自定义 grep/tail 参数的场景。',
339
+ inputSchema: {
340
+ type: 'object',
341
+ properties: {
342
+ pod: {
343
+ type: 'string',
344
+ description: 'Pod 名称或名称模式(支持部分匹配)'
345
+ },
346
+ command: {
347
+ type: 'string',
348
+ description: '要在 pod 内执行的命令,如 grep -C 5 "keyword" /www/logs/app/application.out'
349
+ },
350
+ namespace: {
351
+ type: 'string',
352
+ description: 'K8s namespace,默认 saas-itest',
353
+ default: 'saas-itest'
354
+ }
355
+ },
356
+ required: ['pod', 'command']
357
+ }
358
+ },
335
359
  // ========== Loki 生产环境工具 ==========
336
360
  {
337
361
  name: 'list_loki_environments',
@@ -821,6 +845,24 @@ async function handleToolCall(name, args, signal) {
821
845
  };
822
846
  }
823
847
 
848
+ // ========== 自定义命令工具处理 ==========
849
+ case 'exec_in_pod': {
850
+ const namespace = args.namespace || DEFAULT_NAMESPACE;
851
+ const podPattern = args.pod;
852
+ const command = args.command;
853
+
854
+ const cmd = `kubectl exec $(kubectl get pod -n ${namespace} -o name | grep ${podPattern} | head -1) -n ${namespace} -- ${command}`;
855
+ log(`[MCP] exec_in_pod: pod=${podPattern}, command=${command}`);
856
+ const result = await executeKubectl(cmd, { signal });
857
+
858
+ return {
859
+ content: [{
860
+ type: 'text',
861
+ text: `## Pod 命令执行结果\n\n**Pod**: ${podPattern}\n**Namespace**: ${namespace}\n**Command**: \`${command}\`\n\n\`\`\`\n${result}\n\`\`\``
862
+ }]
863
+ };
864
+ }
865
+
824
866
  // ========== Loki 生产环境工具处理 ==========
825
867
  case 'list_loki_environments': {
826
868
  const envs = getLokiEnvList();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-log-query-server",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "MCP Server for querying server logs via SSH jump host and Grafana Loki API",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/ssh-client.js CHANGED
@@ -229,8 +229,6 @@ function buildKubectlCommand(service, logCommand) {
229
229
  const file = logFile || 'normal.log';
230
230
  const fullPath = `${logPath}/${file}`;
231
231
 
232
- // 构建完整命令
233
- // 例如: kubectl exec pod/xxx -n namespace -- tail -100 /path/to/normal.log
234
232
  return `kubectl exec $(kubectl get pod -n ${namespace} -o name | grep ${podPattern} | head -1) -n ${namespace} -- ${logCommand} ${fullPath}`;
235
233
  }
236
234