Skip to main content
Glama
masamunet

npm-dev-mcp

by masamunet

scan_project_dirs

Scans project directories to locate package.json files and identify available development scripts for npm run dev processes.

Instructions

プロジェクト内のpackage.jsonとdevスクリプトを検索

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main asynchronous handler function for the 'scan_project_dirs' tool. It creates a ProjectScanner instance, scans for projects with dev scripts, formats the results as JSON (including project details like directory, name, dev script, env file, priority, and top dependencies), handles empty results and errors gracefully.
    export async function scanProjectDirs(): Promise<string> {
      try {
        logger.info('Scanning for project directories');
        
        const scanner = new ProjectScanner();
        const projects = await scanner.scanForProjects();
        
        if (projects.length === 0) {
          return JSON.stringify({
            success: false,
            message: 'devスクリプトが定義されたpackage.jsonが見つかりませんでした',
            projects: []
          });
        }
        
        const result = {
          success: true,
          message: `${projects.length}個のプロジェクトが見つかりました`,
          projects: projects.map(project => ({
            directory: project.directory,
            name: project.packageJson.name || 'Unnamed Project',
            devScript: project.packageJson.scripts?.dev,
            hasEnvFile: !!project.envPath,
            envPath: project.envPath,
            priority: project.priority,
            dependencies: Object.keys({
              ...project.packageJson.dependencies,
              ...project.packageJson.devDependencies
            }).slice(0, 5) // Show first 5 dependencies
          }))
        };
        
        logger.info(`Found ${projects.length} projects with dev scripts`);
        return JSON.stringify(result, null, 2);
        
      } catch (error) {
        logger.error('Failed to scan project directories', { error });
        return JSON.stringify({
          success: false,
          message: `スキャンエラー: ${error}`,
          projects: []
        });
      }
    }
  • The Tool schema definition specifying the name, description, and empty input schema (no parameters required).
    export const scanProjectDirsSchema: Tool = {
      name: 'scan_project_dirs',
      description: 'プロジェクト内のpackage.jsonとdevスクリプトを検索',
      inputSchema: {
        type: 'object',
        properties: {},
        additionalProperties: false
      }
    };
  • src/index.ts:127-135 (registration)
    Registration and dispatch of the tool handler in the main CallToolRequestSchema switch statement. Executes scanProjectDirs() and wraps the result in the required MCP response format.
    case 'scan_project_dirs':
      return {
        content: [
          {
            type: 'text',
            text: await scanProjectDirs(),
          },
        ],
      };
  • src/index.ts:55-65 (registration)
    Registration of the tool schema in the tools array used by the ListToolsRequestSchema handler to advertise available tools.
    const tools = [
      scanProjectDirsSchema,
      startDevServerSchema,
      getDevStatusSchema,
      getDevLogsSchema,
      stopDevServerSchema,
      restartDevServerSchema,
      getHealthStatusSchema,
      recoverFromStateSchema,
      autoRecoverSchema,
    ];
  • Dependency mapping for the tool, specifying that 'scan_project_dirs' requires 'projectContext' service to be initialized before execution.
    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 the full burden of behavioral disclosure. It mentions searching but doesn't clarify whether this is a read-only operation, if it requires specific permissions, what the output format might be, or any potential side effects like performance impacts. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence in Japanese that directly states the tool's function without any unnecessary words. It is front-loaded with the core action and resources, making it highly concise and well-structured for quick understanding.

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

Completeness3/5

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

Given the tool's complexity (simple search operation with no parameters) and the lack of annotations and output schema, the description is minimally adequate. It states what the tool does but lacks details on behavior, output, or usage context. For a tool with no structured data beyond the input schema, this leaves gaps in completeness, though it meets the basic requirement of stating the purpose.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter semantics, and it doesn't introduce any confusion about parameters. A baseline score of 4 is appropriate as the description doesn't contradict the schema and the schema handles the parameter documentation completely.

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 tool's purpose: searching for package.json files and dev scripts within a project. It specifies both the target resources (package.json and dev scripts) and the action (searching). However, it doesn't explicitly differentiate from sibling tools like 'get_dev_logs' or 'get_dev_status', which might also involve project directory operations.

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. It doesn't mention any prerequisites, context for usage, or comparisons to sibling tools such as 'get_dev_logs' or 'restart_dev_server'. This leaves the agent with minimal direction on appropriate invocation scenarios.

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