Skip to content

Improve documentation for the read_multiple_files action #2602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sebastien-rosset
Copy link

Description

This PR fixes the read_multiple_files function to properly handle empty arrays and improves documentation to make the parameter structure self-documenting for AI assistants.

Server Details

  • Server: filesystem
  • Changes to: tools (read_multiple_files function schema and validation)

Motivation and Context

Addresses issue #2032 where the read_multiple_files function lacked clear documentation about its parameter structure and behavior, causing AI assistants to use it incorrectly without explicit instruction. The function would accept empty arrays and return empty results without helpful feedback, making it difficult for AI assistants to understand proper usage.

How Has This Been Tested?

  • Schema validation tested with empty arrays (now properly rejected with clear error message)
  • Verified that non-empty arrays continue to work as expected
  • Confirmed that the JSON schema generation includes the new descriptive text
  • Tested backward compatibility with existing valid use cases

Breaking Changes

No breaking changes for valid usage. The only change is that empty arrays (which previously returned empty results) now return a clear error message explaining that at least one file path is required.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

Changes made:

  1. Schema validation: Added .min(1, "At least one file path must be provided") to reject empty arrays with a clear error message
  2. Parameter documentation: Added .describe() to the paths parameter explaining the expected format and requirements
  3. Code formatting: Reformatted the schema definition for better readability

Before this fix:

  • Empty arrays would be processed and return empty results
  • AI assistants required explicit instruction about parameter structure
  • No clear feedback about minimum requirements

After this fix:

  • Empty arrays are rejected with descriptive error: "At least one file path must be provided"
  • Schema is self-documenting with clear parameter descriptions
  • AI assistants can better understand correct usage without explicit instruction

The fix maintains full backward compatibility for all valid use cases while providing better guidance for incorrect usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant