Commit Graph

148 Commits

Author SHA1 Message Date
Arif Celebi
b60eca1b3b fix(filesystem): ensure bare Windows drive letters normalize to root (#3434)
fix(filesystem): ensure bare Windows drive letters normalize to root

Appends path.sep to bare drive letters (e.g. "C:") before calling path.normalize(), preventing them from normalizing to "C:." (current directory on drive) instead of "C:\" (drive root). Includes test coverage with platform mocking.

Fixes #3418
2026-03-16 12:12:00 -07:00
Ola Hungerford
72efc42976 Merge pull request #3230 from nulone/fix/filesystem-move-file-destructive-hint
fix(filesystem): mark move_file as destructive operation
2026-02-28 14:17:21 -07:00
Ola Hungerford
a83b1451c5 Merge pull request #3254 from wingding12/fix/filesystem-macos-symlink-path-resolution
fix(filesystem): resolve symlinked allowed directories to both forms
2026-02-19 07:36:47 -07:00
Ellis Shang
1b96551ef0 fix(filesystem): use fileURLToPath for Windows absolute path parsing (#3205) 2026-02-19 05:52:11 -07:00
Cliff Hall
3921f5c041 Merge branch 'main' into claude/issue-2526-20250824-0240 2026-02-07 16:57:16 -05:00
Ola Hungerford
10d382798e Merge pull request #3229 from nulone/fix/graceful-unavailable-paths
fix(filesystem): gracefully handle unavailable directories
2026-02-06 06:38:30 -07:00
dependabot[bot]
e95bb9c44b Bump the npm_and_yarn group across 1 directory with 2 updates
Bumps the npm_and_yarn group with 1 update in the / directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).


Updates `@modelcontextprotocol/sdk` from 1.25.2 to 1.26.0
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/v1.25.2...v1.26.0)

Updates `hono` from 4.11.3 to 4.11.7
- [Release notes](https://github.com/honojs/hono/releases)
- [Commits](https://github.com/honojs/hono/compare/v4.11.3...v4.11.7)

---
updated-dependencies:
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.26.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
- dependency-name: hono
  dependency-version: 4.11.7
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-04 20:38:38 +00:00
Ola Hungerford
760829a778 Merge pull request #3206 from modelcontextprotocol/chore/apache-2.0-license
chore: update licensing to Apache 2.0 for new contributions
2026-02-04 06:00:33 -07:00
olaservo
dd6594c083 fix(filesystem): use vi.fn() instead of jest.fn() in test
The project uses Vitest, not Jest. Replace jest.fn() with vi.fn()
to fix the ReferenceError in the relative path resolution test.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 05:24:02 -07:00
Ola Hungerford
39a1db9bf2 Merge branch 'main' into claude/issue-2526-20250824-0240 2026-02-03 19:59:23 -07:00
wingding12
8f2e9cc678 fix(filesystem): resolve symlinked allowed directories to both forms
On macOS, /tmp is a symlink to /private/tmp. When users specify /tmp
as an allowed directory, the server was resolving it to /private/tmp
during startup but then rejecting paths like /tmp/file.txt because
they dont start with /private/tmp.

This fix stores BOTH the original normalized path AND the resolved
path in allowedDirectories, so users can access files through either
form. For example, with /tmp as allowed directory, both /tmp/file.txt
and /private/tmp/file.txt will now be accepted.

Fixes #3253
2026-01-26 18:28:49 -05:00
lunov
86fd903d5f fix(filesystem): mark move_file as destructive operation
move_file deletes the source file, which is a destructive operation.
Updated annotations and README documentation to reflect this.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 19:58:26 +07:00
lunov
2dfa15dc6e fix(filesystem): gracefully handle unavailable directories
Previously, the server would crash if any configured directory was
unavailable (e.g., unmounted external drive). Now it:

- Filters out inaccessible directories with a warning
- Continues operating with remaining accessible directories
- Only fails if NO directories are accessible

Fixes #2815
2026-01-19 19:53:45 +07:00
dependabot[bot]
3d6c7c1391 Bump diff in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the / directory: [diff](https://github.com/kpdecker/jsdiff).


Updates `diff` from 5.2.0 to 8.0.3
- [Changelog](https://github.com/kpdecker/jsdiff/blob/master/release-notes.md)
- [Commits](https://github.com/kpdecker/jsdiff/compare/v5.2.0...v8.0.3)

---
updated-dependencies:
- dependency-name: diff
  dependency-version: 8.0.3
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-14 22:23:10 +00:00
Adam Jones
6b36e3c223 chore: update licensing to Apache 2.0 for new contributions 2026-01-12 22:50:22 +00:00
dependabot[bot]
737ce98e4a Bump @modelcontextprotocol/sdk
Bumps the npm_and_yarn group with 1 update in the / directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).


Updates `@modelcontextprotocol/sdk` from 1.24.0 to 1.25.2
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/1.24.0...v1.25.2)

---
updated-dependencies:
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.25.2
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-07 16:49:05 +00:00
tomonacci
1ae217d74d Remove only trailing slashes (#3183) 2026-01-05 18:42:10 +00:00
Ola Hungerford
968acc2ec9 fix(filesystem): return string in structuredContent to match outputSchema (#3113)
* fix(filesystem): return string in structuredContent to match outputSchema

The directory_tree, move_file, and list_directory_with_sizes tools were
returning an array in structuredContent.content, but outputSchema declares
content as z.string(). This caused MCP error -32602 validation failures.

Changed structuredContent from { content: [contentBlock] } to { content: text }
to match the declared outputSchema and be consistent with other filesystem
tools like list_directory and search_files.

Fixes #3110, #3106, #3093

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(filesystem): add integration tests for structuredContent schema compliance

Adds tests to verify that directory_tree, list_directory_with_sizes, and
move_file tools return structuredContent.content as a string (matching
outputSchema) rather than an array.

These tests prevent regression of issues #3110, #3106, #3093.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: adam jones <domdomegg+git@gmail.com>
2025-12-11 13:50:27 +00:00
Stefan Dirkse
e6933ca98b Fix: Changed structuredContent output to match outputSchema (#3099) 2025-12-11 13:48:04 +00:00
dependabot[bot]
1c654a4e7d chore(deps): bump @modelcontextprotocol/sdk
Bumps the npm_and_yarn group with 1 update in the / directory: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk).


Updates `@modelcontextprotocol/sdk` from 1.23.0 to 1.24.0
- [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/typescript-sdk/compare/1.23.0...1.24.0)

---
updated-dependencies:
- dependency-name: "@modelcontextprotocol/sdk"
  dependency-version: 1.24.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-02 17:40:23 +00:00
adam jones
d9929014d5 Add mcpName and repository fields for MCP registry (#3068)
Adds metadata required for registering servers in the MCP registry:

- NPM servers (everything, filesystem, memory, sequentialthinking):
  Added mcpName and repository fields to package.json

- PyPI servers (fetch, git, time):
  Added mcp-name comment to README.md

Part of #3047
2025-11-26 14:29:36 +00:00
dependabot[bot]
c017f44ee2 chore(deps): bump glob in the npm_and_yarn group across 1 directory (#3076)
Bumps the npm_and_yarn group with 1 update in the / directory: [glob](https://github.com/isaacs/node-glob).


Updates `glob` from 10.4.5 to 10.5.0
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v10.4.5...v10.5.0)

---
updated-dependencies:
- dependency-name: glob
  dependency-version: 10.5.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-26 13:18:16 +00:00
adam jones
3154518344 Update @modelcontextprotocol/sdk to 1.23.0 in TypeScript servers (#3065)
Update the SDK from ^1.19.1 to ^1.23.0 in all TypeScript reference servers:
- everything
- filesystem
- memory
- sequentialthinking

Also update everything server for SDK breaking changes:
- Update zod to ^3.25.0 (zod v4 compatibility)
- Fix ToolInput/ToolOutput types to use Tool["inputSchema"] instead of
  inferring from zod schemas
- Fix result.content handling to support array format

Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
2025-11-26 12:32:37 +00:00
Adam Jones
350ffeec01 Fix VS Code MCP documentation URLs
Update links to point to the new location at /docs/copilot/customization/mcp-servers
2025-11-25 22:11:56 +00:00
Valeriy Pavlovich
84c2824f03 # feat(filesystem): add ToolAnnotations hints to filesystem tools (#3045)
**Files touched**

- [src/filesystem/index.ts](../blob/HEAD/src/filesystem/index.ts) — add `annotations` metadata to each tool definition
- [src/filesystem/README.md](../blob/HEAD/src/filesystem/README.md) — document ToolAnnotations mapping for all filesystem tools

## Description

This change adds MCP `ToolAnnotations` (`readOnlyHint`, `idempotentHint`, `destructiveHint`) to all filesystem tools and documents the mapping in the filesystem README. MCP clients can now accurately distinguish read‑only vs. write tools, understand which operations are safe to retry, and highlight potentially destructive actions.

## Server Details

- **Server**: filesystem
- **Area**: tools (metadata returned via `listTools` / `ListToolsRequest`) and server docs

## Motivation and Context

Previously, the filesystem server did not expose ToolAnnotations, so many clients (e.g. ChatGPT Apps) conservatively treated filesystem tools as generic write operations. This led to:

- READ operations being surfaced with WRITE badges and confirmation prompts.
- No way for clients to know which write tools are idempotent or potentially destructive.

This PR aligns the implementation with `servers#2988` and updates the README to clearly document the semantics of each tool. Read‑only operations no longer need to be treated as writes, and destructive/idempotent behavior is explicit for UI and retry logic.

## How Has This Been Tested?

- `npm run build --workspace @modelcontextprotocol/server-filesystem`
- `npm test --workspaces --if-present`

## Breaking Changes

None.

## Types of changes

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

## Checklist

- [x] I have read the [MCP Protocol Documentation](https://modelcontextprotocol.io)
- [x] My changes follows MCP security best practices
- [x] I have updated the server's README accordingly
- [x] I have tested this with an LLM client
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [ ] I have documented all environment variables and configuration options

## Additional context

None.

Co-authored-by: Valeriy_Pavlovich <vp@strato.space>
2025-11-24 15:58:15 +00:00
Adam Jones
3f2ddb0479 fix: simplify output schemas for text-only tools and add structuredContent
For text-only tool responses, simplify outputSchemas from complex nested
arrays to simple { content: z.string() } format. All tool responses now
include structuredContent matching their outputSchema, fixing MCP protocol
violations when tools had output schemas but no structured content.

This applies to both filesystem and everything servers.
2025-11-20 21:44:36 +00:00
adam jones
55c3a31690 fix(filesystem): address review feedback from #3016 (#3031)
Address two items from Camila's review:

1. Use blob type for non-image/non-audio media files, restoring the
   original behavior. This matches the previous implementation which
   used blob as the fallback for unknown binary types. Use type
   assertion to satisfy the SDK's type constraints.

2. Reuse ReadTextFileArgsSchema.shape in the deprecated read_file tool
   instead of redefining the schema inline.
2025-11-20 20:29:22 +00:00
adam jones
4dc24cf349 fix(filesystem): convert to modern TypeScript SDK APIs (#3016)
* fix(filesystem): convert to modern TypeScript SDK APIs

Convert the filesystem server to use the modern McpServer API instead
of the low-level Server API.

Key changes:
- Replace Server with McpServer from @modelcontextprotocol/sdk/server/mcp.js
- Convert all 13 tools to use registerTool() instead of manual request handlers
- Use Zod schemas directly in inputSchema/outputSchema
- Add structuredContent to all tool responses
- Fix type literals to use 'as const' assertions
- Update roots protocol handling to use server.server.* pattern
- Fix tsconfig to exclude vitest.config.ts

Tools converted:
- read_file (deprecated)
- read_text_file
- read_media_file
- read_multiple_files
- write_file
- edit_file
- create_directory
- list_directory
- list_directory_with_sizes
- directory_tree
- move_file
- search_files
- get_file_info
- list_allowed_directories

The modern API provides:
- Less boilerplate code
- Better type safety with Zod
- More declarative tool registration
- Cleaner, more maintainable code

* fix: use default import for minimatch

minimatch v10+ uses default export instead of named export

* fix(filesystem): use named import for minimatch

The minimatch module doesn't have a default export, so we need to use
the named import syntax instead.

Fixes TypeScript compilation error:
error TS2613: Module has no default export. Did you mean to use
'import { minimatch } from "minimatch"' instead?
2025-11-20 17:00:04 +00:00
Sanghee Son
bd39b09e4c fix: exclude test files from filesystem build
test files were being compiled into dist during build,
causing issues in docker environments. added exclude
pattern to tsconfig to skip __tests__ directory.

fixes #2928
2025-10-31 16:33:22 +09:00
olaservo
c3b26fad30 Fix platform-dependent relative path test in filesystem
The test was expecting forward slashes to always be converted to backslashes, but normalizePath() only does this on Windows (process.platform === 'win32'). On Linux/Unix, forward slashes are preserved.

Improved the fix by:
1. Removing relative path assertion from the "as is" test since it doesn't match intent
2. Adding a dedicated test that validates platform-specific behavior naturally without mocking
3. Using the actual platform instead of unreliable Object.defineProperty mocking

This approach is more reliable and clearly documents expected behavior per platform.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 21:27:13 -07:00
olaservo
bbbc0c6381 Fix TypeScript error in filesystem tests by adding missing afterEach import
The afterEach function was used in the test file but not imported from vitest, causing a build failure. This was introduced in PR #2851.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 21:06:25 -07:00
Ola Hungerford
d2eb945c4d Merge pull request #2851 from olaservo/fix-wsl-path-conversion
Resolve filesystem issue where WSL paths are incorrectly converted to Windows format
2025-10-28 18:56:58 -07:00
Ola Hungerford
ed4b36b6d5 Merge branch 'main' into fix-wsl-path-conversion 2025-10-19 11:45:07 -07:00
olaservo
b666e7f246 Migrate sequentialthinking and filesystem servers from Jest to Vitest
- Replace Jest dependencies with Vitest and @vitest/coverage-v8
- Update test scripts to use 'vitest run --coverage'
- Create vitest.config.ts for both servers with node environment and coverage settings
- Update all test files:
  - Change imports from '@jest/globals' to 'vitest'
  - Replace jest.mock() with vi.mock()
  - Replace jest.fn() with vi.fn()
  - Update mock clearing/restoring to use vi methods
- Remove jest.config.cjs files
- All 151 tests passing (24 in sequentialthinking, 127 in filesystem)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 11:21:58 -07:00
olaservo
c9b0135aa5 fix: preserve WSL paths and improve path normalization logic 2025-10-12 19:59:22 -07:00
olaservo
f6fbfc4c5e Merge remote-tracking branch 'upstream/main' into add-sequentialthinking-tests-update-sdk 2025-10-12 18:09:41 -07:00
olaservo
f03a4eda56 Merge remote-tracking branch 'upstream/main' 2025-10-12 18:07:29 -07:00
olaservo
072e53322b Add tests for sequential thinking and update typescript sdk versions 2025-10-07 23:01:42 -07:00
多吃点
097fdab463 docs: Fix duplicate directory_tree tool entry in API documentation 2025-09-13 13:00:02 +08:00
claude[bot]
29c9f8c58e fix: resolve relative paths against allowed directories instead of process.cwd()
Fixes issue where relative paths were incorrectly resolved against process.cwd(),
causing "Access denied - path outside allowed directories" errors when the MCP
server's working directory was outside the configured allowed directories.

The fix implements intelligent path resolution that:
1. First tries to resolve relative paths against each allowed directory
2. Validates the resulting path is within allowed directories
3. Falls back to the first allowed directory if no valid resolution is found
4. Maintains backward compatibility by falling back to process.cwd() when no allowed directories are configured

Resolves #2526

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
2025-08-24 02:44:31 +00:00
Sebastien Rosset (serosset)
b647cb3019 Add documentation for the read_multiple_files action. 2025-08-23 10:51:51 -07:00
Finn Andersen
fd886fac9c Support glob pattern in search_files tool (#745)
Co-authored-by: Adam Jones <adamj+git@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Adam Jones <adamj@anthropic.com>
2025-08-23 07:37:53 +01:00
Enrico Ballardini
d381cf1ffd feat(directory_tree): add excludePatterns support & documentation (#623)
- Update documentation with directory_tree declaration
- Add excludePatterns parameter to DirectoryTreeArgsSchema
- Implement pattern exclusion in buildTree function using minimatch
- Pass excludePatterns through recursive calls
- Support both simple and glob patterns for exclusion
- Maintain consistent behavior with search_files implementation

* Add tests and fix implementation

---------

Co-authored-by: Ola Hungerford <olahungerford@gmail.com>
Co-authored-by: Adam Jones <adamj+git@anthropic.com>
Co-authored-by: Adam Jones <adamj@anthropic.com>
2025-08-23 07:19:01 +01:00
Michael Casazza
46368832ef Windows filesystem MCP enhancements (#543)
* fix: comprehensive Windows path handling improvements

- Add path-utils module for consistent path handling
- Handle Windows paths with spaces via proper quoting
- Support Unix-style Windows paths (/c/path)
- Support WSL paths (/mnt/c/path)
- Add comprehensive test coverage
- Fix path normalization for all path formats

Closes #447

* tested locally and working now

* Add filesystem path utils and tests

* Ensure Windows drive letters are capitalized in normalizePath

* adding test for gh pr comment

* pushing jest and windows testing config

* last commit? fixing comments on PR

* Fix bin and bump sdk

* Remove redundant commonjs version of path-utils and import from ts version

* Remove copying cjs file

* Remove copying run-server

* Remove complex args parsing and do other cleanup

* Add missing tools details to Readme

* Move utility functions from index to lib

* Add more tests and handle very small and very large files edge cases

* Finish refactoring and include original security fix comments

* On Windows, also check for drive root

* Check symlink support on restricted Windows environments

* Fix tests

* Bump SDK and package version

* Clean up

---------

Co-authored-by: olaservo <olahungerford@gmail.com>
Co-authored-by: adam jones <adamj+git@anthropic.com>
2025-08-18 18:23:40 +01:00
Ola Hungerford
7e1d9d9ede fix: clarify list_allowed_directories description to mention subdirectory access (#2571)
The tool description was ambiguous about subdirectory access within allowed directories.
Updated the description to explicitly state that subdirectories are also accessible.

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
2025-08-17 23:32:33 +01:00
claude[bot]
54f9c6968e fix: remove incorrect resources claim from filesystem server README
The filesystem server does not actually implement MCP Resources capability
but the README incorrectly claimed it provides 'file://system' resource interface.

Fixes #399

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
2025-08-17 16:38:29 +00:00
Ola Hungerford
1028b32573 Merge pull request #2328 from kunalbabre/main
docs: Update VS Code installation instructions to use mcp.json for issue  #2320
2025-08-07 07:28:32 -07:00
Sampath Vuyyuru
a688cca947 Update src/filesystem/README.md
Fix broken link to Roots
2025-07-26 18:09:30 +00:00
cliffhall
704275818f Replace read_file tool with deprecation notice in description, which is functionally just an alias for read_text_file 2025-07-25 16:01:05 -04:00
cliffhall
471ac89f55 Update SDK version 2025-07-24 14:37:49 -04:00