Skip to main content
Glama

check_package_json

Analyze package.json files to identify dependencies, scripts, and configurations. Supports multiple package managers and provides detailed insights for development workflows.

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 executes the tool's logic: reads package.json, parses it, analyzes key fields (name, version, dependencies, devDependencies, scripts, main, type), and returns a text response with the analysis.
    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}`); } }
  • src/index.ts:81-93 (registration)
    Registers the tool in the ListTools response, specifying 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)' } } } },
  • Input schema definition for the tool, defining an optional 'directory' string parameter.
    inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Directory containing package.json (default: current directory)' } } }
  • Switch case in the CallToolRequest handler that routes the tool call to the checkPackageJson method.
    case 'check_package_json': return await this.checkPackageJson(args);

Other Tools

Related 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