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);

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