Skip to main content
Glama
MaheshDoiphode

Project Content Server

latest_project_data

Retrieve project file names and contents from a specified directory using the MCP server for streamlined access and error handling.

Instructions

Get latest project data including file names and contents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the project directory

Implementation Reference

  • Main handler logic for the 'latest_project_data' tool: validates input arguments, calls getProjectFiles to retrieve project files, serializes to JSON, and returns as text content or error.
    if (request.params.name === "latest_project_data") {
      if (
        !request.params.arguments ||
        typeof request.params.arguments !== "object"
      ) {
        return {
          content: [
            {
              type: "text",
              text: "Invalid arguments provided",
            },
          ],
          isError: true,
        };
      }
    
      const { projectPath } = request.params.arguments as {
        projectPath: string;
      };
    
      if (!projectPath || typeof projectPath !== "string") {
        return {
          content: [
            {
              type: "text",
              text: "projectPath must be a valid string",
            },
          ],
          isError: true,
        };
      }
    
      try {
        const files = await this.getProjectFiles(projectPath);
    
        // Convert to JSON string
        const jsonString = JSON.stringify(files, null, 2);
    
        // Send the JSON string as individual characters (like FileReadingServer)
        return {
          content: [
            {
              type: "text",
              text: jsonString
            }
          ],
        };
      } catch (error) {
        const message =
          error instanceof Error ? error.message : "Unknown error occurred";
        return {
          content: [
            {
              type: "text",
              text: `Error: ${message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Schema definition for the 'latest_project_data' tool, including name, description, and input schema requiring 'projectPath'.
      {
        name: "latest_project_data",
        description:
          "Get latest project data including file names and contents",
        inputSchema: {
          type: "object",
          properties: {
            projectPath: {
              type: "string",
              description: "Path to the project directory",
            },
          },
          required: ["projectPath"],
        },
      },
    ],
  • src/index.ts:58-76 (registration)
    Registration of the 'latest_project_data' tool in the ListToolsRequestSchema handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: "latest_project_data",
          description:
            "Get latest project data including file names and contents",
          inputSchema: {
            type: "object",
            properties: {
              projectPath: {
                type: "string",
                description: "Path to the project directory",
              },
            },
            required: ["projectPath"],
          },
        },
      ],
    }));
  • Helper function that reads project files recursively based on directory mapping from MCP settings file, cleans contents, and returns a record of relative paths to cleaned file contents.
    private async getProjectFiles(projectPath: string) {
      const result: Record<string, string> = {};
      const self = this; // Store reference to class instance
    
      const normalizePathForOutput = (
        filePath: string,
        basePath: string
      ): string => {
        return path.relative(basePath, filePath).replace(/\\/g, "/");
      };
    
      try {
        const settingsPath =
          "C:/Users/Mahes/AppData/Roaming/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json";
    
        let settings;
        try {
          const settingsContent = await fs.readFile(settingsPath, "utf-8");
          settings = JSON.parse(settingsContent);
        } catch (err: unknown) {
          const errorMessage = err instanceof Error ? err.message : String(err);
          throw new Error(
            `Failed to read settings file at ${settingsPath}: ${errorMessage}`
          );
        }
    
        const mapping =
          settings.mcpServers?.ProjectContentServer?.directoryMapping?.[
            projectPath
          ];
    
        if (!mapping) {
          throw new Error(
            `No directory mapping found for project path: ${projectPath}`
          );
        }
    
        async function processPath(itemPath: string) {
          const fullPath = path.normalize(itemPath);
          try {
            const stats = await fs.stat(fullPath);
    
            if (stats.isDirectory()) {
              const files = await fs.readdir(fullPath);
              for (const file of files) {
                await processPath(path.join(itemPath, file));
              }
            } else if (stats.isFile()) {
              const content = await fs.readFile(fullPath, {
                encoding: "utf8",
                flag: "r",
              });
              const relativePath = normalizePathForOutput(fullPath, projectPath);
              // Use stored reference to access class method
              result[relativePath] = self.cleanFileContent(content);
            }
          } catch (err: unknown) {
            const errorMessage = err instanceof Error ? err.message : String(err);
            console.error(`Error processing path ${fullPath}: ${errorMessage}`);
          }
        }
    
        for (const pathItem of mapping) {
          await processPath(pathItem);
        }
    
        return result;
      } catch (err: unknown) {
        const errorMessage = err instanceof Error ? err.message : String(err);
        throw new Error(`Failed to process project files: ${errorMessage}`);
      }
    }
  • Helper function to clean file content by normalizing whitespace and line endings.
    private cleanFileContent(content: string): string {
      return content
        .replace(/\r\n|\n/g, " ") // Replace all line endings with space
        .replace(/\s+/g, " ") // Normalize multiple spaces to single
        .trim(); // Remove leading/trailing whitespace
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions retrieving 'latest project data' but doesn't specify whether this is a read-only operation, potential side effects, performance characteristics, or error conditions. The description is insufficient for a tool with zero 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.

Conciseness4/5

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

The description is a single, efficient sentence that communicates the core functionality without unnecessary words. It's appropriately sized for a simple tool, though it could be slightly more structured by separating purpose from scope.

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?

For a single-parameter tool with good schema coverage but no annotations and no output schema, the description provides basic purpose but lacks important behavioral context. It's minimally adequate but leaves significant gaps in understanding how the tool behaves and what it returns.

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% with the single parameter 'projectPath' well-documented in the schema. The description doesn't add any meaningful parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate.

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 action ('Get') and resource ('latest project data'), specifying it includes 'file names and contents'. This provides a specific verb+resource combination, though without sibling tools, differentiation cannot be evaluated.

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, prerequisites, or contextual constraints. It simply states what the tool does without indicating appropriate usage 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

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/MaheshDoiphode/mcp-cline-project-content-server'

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