Skip to main content
Glama
itsocialist

Claude Code Connector MCP

by itsocialist

read_from_project

Retrieve specific file content from registered Claude Code projects by specifying project ID, file path, and optional line ranges for targeted code access.

Instructions

Read file content from registered project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesID of registered project
filePathYesRelative path within project
startLineNoStart reading from line N (1-indexed)
endLineNoStop reading at line N (1-indexed)

Implementation Reference

  • The main execution logic for the read_from_project tool, handling file reading from projects with security, line ranges, and error handling.
    export async function readFromProject(args: ReadFromProjectArgs): Promise<{
        content: string;
        path: string;
    }> {
        const projectManager = new ProjectManager();
        const project = await projectManager.getProject(args.projectId);
    
        if (!project) {
            throw new MCPError(ErrorCode.PROJECT_NOT_FOUND, `Project '${args.projectId}' not found`);
        }
    
        // Prevent directory traversal
        if (args.filePath.includes('..') || isAbsolute(args.filePath)) {
            throw new MCPError(ErrorCode.INVALID_PATH, `Invalid file path: ${args.filePath}`);
        }
    
        const fullPath = join(project.rootPath, args.filePath);
    
        try {
            const stats = await stat(fullPath);
            if (!stats.isFile()) {
                throw new MCPError(ErrorCode.INVALID_PATH, `Path is not a file: ${args.filePath}`);
            }
    
            let content = await readFile(fullPath, 'utf-8');
    
            // Handle line ranges if specified
            if (args.startLine !== undefined || args.endLine !== undefined) {
                const lines = content.split('\n');
                const start = (args.startLine || 1) - 1;
                const end = args.endLine || lines.length;
    
                content = lines.slice(start, end).join('\n');
            }
    
            // Update last accessed
            project.lastAccessed = new Date().toISOString();
    
            return {
                content,
                path: fullPath
            };
        } catch (error: any) {
            if (error.status === ErrorCode.INVALID_PATH || error instanceof MCPError) {
                throw error;
            }
            if (error.code === 'ENOENT') {
                throw new MCPError(ErrorCode.FILE_NOT_FOUND, `File '${args.filePath}' not found in project`);
            }
            throw new MCPError(ErrorCode.INTERNAL_ERROR, `Failed to read file: ${error.message}`);
        }
    }
  • TypeScript interface defining the input parameters for the read_from_project tool.
    export interface ReadFromProjectArgs {
      projectId: string;
      filePath: string;
      startLine?: number;
      endLine?: number;
    }
  • src/index.ts:96-108 (registration)
    Tool registration in ListToolsRequestHandler, including name, description, and input schema.
      name: 'read_from_project',
      description: 'Read file content from registered project',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: { type: 'string', description: 'ID of registered project' },
          filePath: { type: 'string', description: 'Relative path within project' },
          startLine: { type: 'number', description: 'Start reading from line N (1-indexed)' },
          endLine: { type: 'number', description: 'Stop reading at line N (1-indexed)' }
        },
        required: ['projectId', 'filePath']
      }
    }
  • src/index.ts:133-136 (registration)
    Handler dispatch in CallToolRequestHandler that invokes the readFromProject function.
    case 'read_from_project':
      return {
        content: [{ type: 'text', text: JSON.stringify(await readFromProject(args as unknown as ReadFromProjectArgs), null, 2) }]
      };
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose permissions required, rate limits, error handling, or output format (e.g., text string, binary data). 'Read' implies a safe operation, but without annotations, more context is needed for safe invocation.

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 a single, clear sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity, making it easy to parse quickly.

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. It doesn't explain what is returned (e.g., file content as text, error if file not found), behavioral traits, or usage context. For a read operation with 4 parameters, more information is needed for reliable agent use.

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 parameters are well-documented in the schema. The description adds no additional meaning beyond implying file content reading, which aligns with the schema. Baseline 3 is appropriate as the schema handles parameter semantics adequately.

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 'Read file content from registered project' clearly states the action (read) and target (file content from registered project), distinguishing it from siblings like list_projects, register_project, and write_to_project. However, it doesn't specify what type of content is read (e.g., text, binary) or how it's returned, keeping it from a perfect 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 prerequisites (e.g., project must be registered), exclusions, or comparisons to siblings like write_to_project for modifications. Usage is implied by the name but not explicitly stated.

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/itsocialist/claude-code-connector-mcp'

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