Skip to content

feat(filesystem): add Resources and Prompts - #4093

Closed
moezdil wants to merge 1 commit into
modelcontextprotocol:mainfrom
moezdil:feat/filesystem-resources-prompts
Closed

moezdil wants to merge 1 commit into
modelcontextprotocol:mainfrom
moezdil:feat/filesystem-resources-prompts

Conversation

@moezdil

@moezdil moezdil commented May 3, 2026 •

Copy link
Copy Markdown

Description

This PR adds Resources and Prompts to the filesystem reference server, which previously exposed only Tools. Per CONTRIBUTING.md, demonstrating underutilized protocol features (Resources, Prompts, Roots) on existing reference servers is explicitly encouraged. The filesystem server is also called out by name in CONTRIBUTING.md as a good vehicle for showcasing these features.

Server Details

  • Server: filesystem
  • Changes to: resources, prompts, README

What is added

Resources

  • filesystem://allowed-directories (static) — exposes the live set of allowed directories. The content reflects whether directories were set via command-line arguments or updated dynamically through MCP Roots.
  • file://{path} (template) — reads a file within the allowed directories and returns its contents as a resource. The path is validated against the allowed-directories list before the read, so the existing security boundary is preserved.

Prompts

  • read-file — a simple prompt that asks the model to read and summarize a file at a given absolute path.

Motivation and Context

  • allowed-directories as a Resource is a natural fit: clients can subscribe to it and get a live, structured view of what the server can see, rather than calling a tool every time they want to check.
  • file://{path} as a template lets clients reference files declaratively in conversation context, which is what Resources are designed for, complementing the existing read_text_file tool rather than duplicating it.
  • read-file Prompt demonstrates the simplest useful prompt pattern: argument-driven, references a path, and pairs naturally with the tools and resources above.

How Has This Been Tested?

  • npm run build — clean
  • npm test — 151 tests pass
  • Tested with MCP Inspector v0.21.2 against the built server. Verified:
    • resources/list returns the static resource
    • resources/templates/list returns the file template
    • resources/read on filesystem://allowed-directories returns the configured directory
    • prompts/list returns read-file
  • Tested end-to-end with Claude Desktop: server initializes cleanly, advertises tools, resources, and prompts capabilities, and responds correctly to tools/list, resources/list, prompts/list, and resources/read.
Screenshot 2026-05-03 at 15 29 33 Screenshot 2026-05-03 at 15 28 04 Screenshot 2026-05-03 at 15 26 47

Breaking Changes

None. This is a purely additive change.

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

@moezdil moezdil changed the title Add Resources and Prompts to filesystem server feat(filesystem): add Resources and Prompts May 3, 2026
@moezdil moezdil closed this Jun 27, 2026
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