Skip to main content
Glama

check_package_json

Analyze package.json files to identify dependencies, scripts, and configuration details for development workflow management.

Instructions

Read and analyze package.json file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNoDirectory containing package.json (default: current directory)

Implementation Reference

  • The handler function that reads the package.json file from the given directory, parses it, extracts key information (name, version, dependencies, devDependencies, scripts, main, type), formats it as JSON, and returns it in the tool response format.
    private async checkPackageJson(args: any) {
      const directory = args?.directory || process.cwd();
      const packagePath = join(directory, 'package.json');
      
      if (!existsSync(packagePath)) {
        throw new Error(`package.json not found in ${directory}`);
      }
      
      try {
        const packageContent = readFileSync(packagePath, 'utf8');
        const packageJson = JSON.parse(packageContent);
        
        const analysis = {
          name: packageJson.name || 'N/A',
          version: packageJson.version || 'N/A',
          dependencies: Object.keys(packageJson.dependencies || {}),
          devDependencies: Object.keys(packageJson.devDependencies || {}),
          scripts: Object.keys(packageJson.scripts || {}),
          main: packageJson.main || 'N/A',
          type: packageJson.type || 'commonjs'
        };
        
        return {
          content: [
            {
              type: 'text',
              text: `Package.json analysis:\n${JSON.stringify(analysis, null, 2)}`
            }
          ]
        };
      } catch (error: any) {
        throw new Error(`Failed to parse package.json: ${error.message}`);
      }
    }
  • Input schema definition for the check_package_json tool, specifying an optional directory parameter.
    inputSchema: {
      type: 'object',
      properties: {
        directory: {
          type: 'string',
          description: 'Directory containing package.json (default: current directory)'
        }
      }
    }
  • src/index.ts:81-93 (registration)
    Tool object registration in the ListToolsRequestHandler, defining name, description, and input schema.
    {
      name: 'check_package_json',
      description: 'Read and analyze package.json file',
      inputSchema: {
        type: 'object',
        properties: {
          directory: {
            type: 'string',
            description: 'Directory containing package.json (default: current directory)'
          }
        }
      }
    },
  • src/index.ts:143-144 (registration)
    Dispatch case in the CallToolRequestHandler that routes the tool call to the handler function.
    case 'check_package_json':
      return await this.checkPackageJson(args);
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. It states 'Read and analyze' which implies a read-only operation, but doesn't disclose behavioral traits like what analysis is performed, whether it validates the file, what happens if the file is missing or invalid, or what the output format is. This leaves significant gaps for a tool with no annotation coverage.

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 with just four words, front-loading the core action and resource. Every word earns its place, and there's no wasted text or redundancy.

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?

Given no annotations and no output schema, the description is incomplete for a tool that performs analysis. It doesn't explain what analysis is done, what the return values are, or how errors are handled. For a tool with 1 parameter but behavioral complexity implied by 'analyze', this leaves too many gaps.

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%, so the schema already documents the single parameter 'directory' with its type and default. The description adds no additional meaning about parameters beyond what the schema provides, such as path format constraints or analysis options, meeting the baseline for high 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 verb ('Read and analyze') and resource ('package.json file'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'lint_code' or 'run_build' which might also interact with package.json files, so it doesn't reach the highest score.

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 when to prefer this over other tools like 'install_dependencies' or 'run_build' that might also read package.json, nor does it specify prerequisites or exclusions.

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/TeodorTrotea/mcptest'

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