Skip to main content
Glama
0xjcf
by 0xjcf

project-info

Analyzes code projects to extract key information for development workflows, including syntax structure and dependencies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'project-info' tool that executes the logic to retrieve project metadata including package information, git status, and file statistics.
    server.tool("project-info", {}, async () => {
      try {
        const packageJsonPath = join(process.cwd(), "package.json");
        let packageInfo = {};
    
        if (existsSync(packageJsonPath)) {
          const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
          packageInfo = {
            name: packageJson.name,
            version: packageJson.version,
            description: packageJson.description,
            dependencies: Object.keys(packageJson.dependencies || {}),
            devDependencies: Object.keys(packageJson.devDependencies || {}),
          };
        }
    
        // Get git info
        let gitInfo = {};
        try {
          const branch = execSync("git branch --show-current", {
            encoding: "utf-8",
          }).trim();
          const lastCommit = execSync(
            'git log -1 --pretty=format:"%h - %s (%cr)"',
            { encoding: "utf-8" }
          ).trim();
          gitInfo = { branch, lastCommit };
        } catch (e) {
          gitInfo = { error: "Git information not available" };
        }
    
        // Count files by type
        let fileStats = {};
        try {
          const tsFiles = execSync('find src -name "*.ts" | wc -l', {
            encoding: "utf-8",
          }).trim();
          const jsFiles = execSync('find src -name "*.js" | wc -l', {
            encoding: "utf-8",
          }).trim();
          const testFiles = execSync('find src -name "*.test.ts" | wc -l', {
            encoding: "utf-8",
          }).trim();
          fileStats = {
            tsFiles: parseInt(tsFiles, 10),
            jsFiles: parseInt(jsFiles, 10),
            testFiles: parseInt(testFiles, 10),
          };
        } catch (e) {
          fileStats = { error: "File statistics not available" };
        }
    
        const result = createSuccessResponse(
          {
            packageInfo,
            gitInfo,
            fileStats,
            timestamp: new Date().toISOString(),
          },
          "project-info"
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                createErrorResponse(
                  error instanceof Error ? error.message : String(error),
                  "project-info"
                ),
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    });
  • Registration of the 'project-info' tool using server.tool() within the dev-tools feature module.
    server.tool("project-info", {}, async () => {
      try {
        const packageJsonPath = join(process.cwd(), "package.json");
        let packageInfo = {};
    
        if (existsSync(packageJsonPath)) {
          const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
          packageInfo = {
            name: packageJson.name,
            version: packageJson.version,
            description: packageJson.description,
            dependencies: Object.keys(packageJson.dependencies || {}),
            devDependencies: Object.keys(packageJson.devDependencies || {}),
          };
        }
    
        // Get git info
        let gitInfo = {};
        try {
          const branch = execSync("git branch --show-current", {
            encoding: "utf-8",
          }).trim();
          const lastCommit = execSync(
            'git log -1 --pretty=format:"%h - %s (%cr)"',
            { encoding: "utf-8" }
          ).trim();
          gitInfo = { branch, lastCommit };
        } catch (e) {
          gitInfo = { error: "Git information not available" };
        }
    
        // Count files by type
        let fileStats = {};
        try {
          const tsFiles = execSync('find src -name "*.ts" | wc -l', {
            encoding: "utf-8",
          }).trim();
          const jsFiles = execSync('find src -name "*.js" | wc -l', {
            encoding: "utf-8",
          }).trim();
          const testFiles = execSync('find src -name "*.test.ts" | wc -l', {
            encoding: "utf-8",
          }).trim();
          fileStats = {
            tsFiles: parseInt(tsFiles, 10),
            jsFiles: parseInt(jsFiles, 10),
            testFiles: parseInt(testFiles, 10),
          };
        } catch (e) {
          fileStats = { error: "File statistics not available" };
        }
    
        const result = createSuccessResponse(
          {
            packageInfo,
            gitInfo,
            fileStats,
            timestamp: new Date().toISOString(),
          },
          "project-info"
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                createErrorResponse(
                  error instanceof Error ? error.message : String(error),
                  "project-info"
                ),
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    });
  • Helper function createSuccessResponse used by the project-info handler to format successful responses in standard format.
    export function createSuccessResponse<T>(
      data: T,
      tool: string,
      options?: {
        version?: string;
        sessionId?: string;
        relatedResults?: string[];
        executionTime?: number;
      }
    ): ToolResponse<T> {
      const startTime =
        options?.executionTime !== undefined
          ? Date.now() - options.executionTime
          : undefined;
    
      const response: ToolResponse<T> = {
        data,
        metadata: {
          tool,
          version: options?.version || "1.0.0",
          executionTime: options?.executionTime || 0,
          timestamp: new Date().toISOString(),
        },
        status: {
          success: true,
          code: 200,
        },
      };
    
      // Add context if we have session information
      if (options?.sessionId || options?.relatedResults) {
        response.context = {
          sessionId: options?.sessionId,
          relatedResults: options?.relatedResults,
        };
      }
    
      // If we need to calculate execution time
      if (startTime) {
        response.metadata.executionTime = Date.now() - startTime;
      }
    
      // Validate the response structure
      try {
        ToolResponseSchema.parse(response);
      } catch (error) {
        console.error("Invalid response structure:", error);
        // Still return the response even if validation fails
      }
    
      return response;
    }
  • Helper function createErrorResponse used by the project-info handler for error responses.
    export function createErrorResponse<T = null>(
      message: string,
      tool: string,
      options?: {
        code?: number;
        data?: T;
        version?: string;
        sessionId?: string;
        executionTime?: number;
      }
    ): ToolResponse<T | null> {
      const startTime =
        options?.executionTime !== undefined
          ? Date.now() - options.executionTime
          : undefined;
    
      const response: ToolResponse<T | null> = {
        data: options?.data || null,
        metadata: {
          tool,
          version: options?.version || "1.0.0",
          executionTime: options?.executionTime || 0,
          timestamp: new Date().toISOString(),
        },
        status: {
          success: false,
          code: options?.code || 400,
          message,
        },
      };
    
      // Add context if we have session information
      if (options?.sessionId) {
        response.context = {
          sessionId: options?.sessionId,
        };
      }
    
      // If we need to calculate execution time
      if (startTime) {
        response.metadata.executionTime = Date.now() - startTime;
      }
    
      // Validate the response structure
      try {
        ToolResponseSchema.parse(response);
      } catch (error) {
        console.error("Invalid error response structure:", error);
        // Still return the response even if validation fails
      }
    
      return response;
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/0xjcf/MCP_CodeAnalysis'

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