Skip to main content
Glama
masamunet

npm-dev-mcp

by masamunet

get_dev_logs

Retrieve npm run dev logs to monitor development server output, with options to specify log lines and project directory.

Instructions

npm run devのログ取得

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linesNo取得行数(デフォルト:50)
directoryNo対象ディレクトリ(複数起動時に指定)

Implementation Reference

  • The main handler function `getDevLogs` that executes the tool logic: retrieves logs from the dev server process using ProcessManager and LogManager, formats them, adds statistics, and returns JSON.
    export async function getDevLogs(args: { lines?: number; directory?: string }): Promise<string> {
      try {
        const requestedLines = args.lines || 50;
    
        const processManager = ProcessManager.getInstance();
    
        // Determine which process to look at
        const processInfo = processManager.getProcess(args.directory);
    
        if (!processInfo) {
          return JSON.stringify({
            success: false,
            message: 'Dev serverが起動していません(または指定されたディレクトリが見つかりません)',
            logs: []
          });
        }
    
        const logManager = processManager.getLogManager(processInfo.directory);
    
        if (!logManager) {
          return JSON.stringify({
            success: false,
            message: 'ログマネージャーが見つかりませんでした',
            logs: []
          });
        }
    
        const logs = await logManager.getLogs(requestedLines);
    
        // Format logs for better readability
        const formattedLogs = logs.map(log => ({
          timestamp: log.timestamp.toISOString(),
          level: log.level,
          source: log.source,
          message: log.message
        }));
    
        const logStats = logManager.getLogStats();
    
        const result = {
          success: true,
          message: `${logs.length}行のログを取得しました`,
          logs: formattedLogs,
          statistics: {
            totalLogs: logStats.total,
            errors: logStats.errors,
            warnings: logStats.warnings,
            info: logStats.info,
            requested: requestedLines,
            returned: logs.length
          },
          process: {
            pid: processInfo.pid,
            directory: processInfo.directory,
            status: processInfo.status
          }
        };
    
        if (logStats.errors > 0) {
          result.message += `\n⚠️ ${logStats.errors}個のエラーが含まれています`;
        }
    
        return JSON.stringify(result, null, 2);
    
      } catch (error) {
        logger.error('Failed to get dev server logs', { error });
        return JSON.stringify({
          success: false,
          message: `ログ取得に失敗しました: ${error}`,
          logs: [],
          error: String(error)
        });
      }
    }
  • The Tool schema definition `getDevLogsSchema` including name, description, and inputSchema with properties for lines and directory.
    export const getDevLogsSchema: Tool = {
      name: 'get_dev_logs',
      description: 'npm run devのログ取得',
      inputSchema: {
        type: 'object',
        properties: {
          lines: {
            type: 'number',
            description: '取得行数(デフォルト:50)',
            minimum: 1,
            maximum: 1000
          },
          directory: {
            type: 'string',
            description: '対象ディレクトリ(複数起動時に指定)'
          }
        },
        additionalProperties: false
      }
    };
  • src/index.ts:157-165 (registration)
    Registration and dispatch of the get_dev_logs handler in the main CallToolRequestSchema switch statement.
    case 'get_dev_logs':
      return {
        content: [
          {
            type: 'text',
            text: await getDevLogs(args as { lines?: number; directory?: string }),
          },
        ],
      };
  • src/index.ts:55-65 (registration)
    Registration of the getDevLogsSchema in the tools array used for ListToolsRequestSchema response.
    const tools = [
      scanProjectDirsSchema,
      startDevServerSchema,
      getDevStatusSchema,
      getDevLogsSchema,
      stopDevServerSchema,
      restartDevServerSchema,
      getHealthStatusSchema,
      recoverFromStateSchema,
      autoRecoverSchema,
    ];
  • Dependency registration for get_dev_logs tool, requiring 'stateManager' service in MCPServerInitializer.
    export const SERVICE_DEPENDENCIES = {
      'scan_project_dirs': ['projectContext'],
      'start_dev_server': ['stateManager'],
      'get_dev_status': ['stateManager'],
      'get_dev_logs': ['stateManager'],
      'stop_dev_server': ['stateManager'],
      'restart_dev_server': ['stateManager'],
      'get_health_status': ['healthChecker'],
      'recover_from_state': ['stateManager'],
      'auto_recover': ['stateManager', 'healthChecker']
    } as const;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'ログ取得' implies a read-only operation, it doesn't specify whether this requires specific permissions, how logs are formatted, whether they're real-time or historical, or any rate limits. The description mentions the source but lacks operational context needed for safe invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single Japanese phrase that directly states the tool's function. Every word earns its place with no wasted text. It's front-loaded with the core purpose and could not be more efficiently structured given its brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what format the logs are returned in, whether they include timestamps, error levels, or other metadata. Given the complexity of log retrieval and the lack of structured output documentation, the description should provide more context about the return value.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters well-documented in Japanese. The description doesn't add any parameter information beyond what's in the schema. Since the schema already fully describes 'lines' and 'directory', the baseline score of 3 is appropriate - the description doesn't compensate but doesn't need to given complete schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('ログ取得' - log retrieval) and specifies the source ('npm run dev'), making the purpose understandable. However, it doesn't distinguish this tool from potential sibling logging tools (none are listed, but the agent might assume others exist). The description is specific about what logs are being retrieved but lacks differentiation context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get_dev_status' and 'get_health_status' available, there's no indication whether this tool should be used for monitoring, debugging, or other purposes. No prerequisites, timing, or exclusion criteria are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/masamunet/npm-dev-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server