Skip to main content
Glama
bsmi021

MCP File Context Server

by bsmi021

getFiles

Retrieve content and metadata for multiple files by specifying their paths to enable file analysis and processing.

Instructions

Retrieve multiple files by their paths, returning content and metadata for each file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathListYesThe list of file paths for the file content to return.

Implementation Reference

  • The handler function for the 'getFiles' tool. It processes a list of file paths, validates access for each, reads metadata and content, handles individual file errors without failing the entire request, and returns a JSON response with file details including content, size, and last modified time.
    private async handleGetFiles(args: any) {
        const { filePathList } = args;
        await this.loggingService.debug('Getting files', {
            fileCount: filePathList?.length || 0,
            operation: 'get_files'
        });
    
        if (!Array.isArray(filePathList)) {
            throw new McpError(ErrorCode.InvalidParams, 'filePathList must be an array');
        }
    
        const results: any[] = [];
    
        // Process each file, handling errors gracefully
        for (const fileItem of filePathList) {
            const filePath = fileItem.fileName;
            
            try {
                // PATTERN: Use existing security validation
                const resolvedPath = await this.validateAccess(filePath);
                
                // PATTERN: Use existing file reading methods
                const metadata = await this.getFileMetadata(resolvedPath);
                const { content } = await this.readFileWithEncoding(resolvedPath, 'utf8');
                
                // TRANSFORM: Match required response schema
                results.push({
                    fileName: filePath,
                    content: content,
                    fileSize: metadata.size,
                    lastModifiedDateTime: metadata.modifiedTime
                });
            } catch (error) {
                // GOTCHA: Don't fail entire request - log error and continue
                await this.loggingService.error('Error reading file', error as Error, {
                    filePath,
                    operation: 'get_files'
                });
                
                // Include error info in response but continue processing
                results.push({
                    fileName: filePath,
                    content: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
                    fileSize: 0,
                    lastModifiedDateTime: new Date().toISOString()
                });
            }
        }
    
        // PATTERN: Use existing response format method
        return this.createJsonResponse(results);
    }
  • src/index.ts:1559-1583 (registration)
    Registration of the 'getFiles' tool in the ListTools response, including name, description, and input schema definition.
    {
        name: 'getFiles',
        description: 'Retrieve multiple files by their paths, returning content and metadata for each file',
        inputSchema: {
            type: 'object',
            properties: {
                filePathList: {
                    type: 'array',
                    description: 'The list of file paths for the file content to return.',
                    minItems: 1,
                    items: {
                        type: 'object',
                        properties: {
                            fileName: {
                                type: 'string',
                                description: 'Path and file name for the file to be retrieved.'
                            }
                        },
                        required: ['fileName']
                    }
                }
            },
            required: ['filePathList']
        }
    }
  • src/index.ts:1619-1620 (registration)
    Registration of the 'getFiles' tool handler in the CallToolRequestSchema switch statement.
    case 'getFiles':
        return await this.handleGetFiles(request.params.arguments);
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the action ('retrieve') and output ('content and metadata'), but lacks critical behavioral details such as permissions required, error handling for invalid paths, rate limits, or whether this is a read-only operation. This is a significant gap for a tool that interacts with files.

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, efficient sentence that front-loads the core action and output without any wasted words. It's appropriately sized for the tool's complexity.

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 the lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like safety, error handling, or output structure, which are crucial for a file retrieval tool. The agent would need to guess about these elements.

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 parameter 'filePathList' well-documented in the schema. The description adds minimal value beyond the schema by implying retrieval of multiple files, but doesn't provide additional semantics like path format examples or constraints beyond what's in the schema.

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 tool's purpose with specific verbs ('Retrieve multiple files') and resources ('files by their paths'), and specifies what it returns ('content and metadata for each file'). However, it doesn't explicitly differentiate from sibling tools like 'read_context' or 'get_profile_context', which might also involve file/content retrieval operations.

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, limitations, or compare it to sibling tools like 'read_context' or 'get_profile_context', leaving the agent without context for selection.

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/bsmi021/mcp-file-context-server'

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