Skip to content

Update file server example to support relative paths #119

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

Merged
merged 3 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/dart_mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Update workflow example to show thinking spinner and input and output token
usage.
- Update file system example to support relative paths.

## 0.2.0

Expand Down
3 changes: 2 additions & 1 deletion pkgs/dart_mcp/example/file_system_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ final class SimpleFileSystemServer extends MCPServer
/// Returns `null` if [path] is valid.
Future<CallToolResult?> _checkAllowedPath(String path) async {
for (var root in await roots) {
if (root.uri == path || p.isWithin(root.uri, path)) {
final resolvedPath = Uri.parse(root.uri).resolve(path).toString();
if (root.uri == resolvedPath || p.isWithin(root.uri, resolvedPath)) {
return null;
}
}
Expand Down