feat: Add filesystem as an example (#52)
This commit is contained in:
parent
85de8638db
commit
167a20c9ba
1 changed files with 139 additions and 0 deletions
32
examples/file-system-node/server/index.js
Normal file
32
examples/file-system-node/server/index.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Entry point for the Filesystem MCP server extension
|
||||
* This wraps the @modelcontextprotocol/server-filesystem package
|
||||
*/
|
||||
|
||||
// Get allowed directories from command line arguments
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
// Use dynamic require since we need CommonJS compatibility
|
||||
const loadServer = async () => {
|
||||
try {
|
||||
// Save original argv
|
||||
const originalArgv = process.argv;
|
||||
|
||||
// The filesystem server expects directories as command line arguments
|
||||
process.argv = [process.argv[0], process.argv[1], ...args];
|
||||
|
||||
// Dynamically import the ESM module
|
||||
await import('@modelcontextprotocol/server-filesystem/dist/index.js');
|
||||
|
||||
// Restore original argv
|
||||
process.argv = originalArgv;
|
||||
} catch (error) {
|
||||
console.error('Failed to load @modelcontextprotocol/server-filesystem:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
// Execute the async function
|
||||
loadServer();
|
||||
Loading…
Reference in a new issue