create-mcp-use-app 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +0,0 @@
1
- {
2
- "name": "my-mcp-server",
3
- "type": "module",
4
- "version": "1.0.0",
5
- "description": "MCP server: my-mcp-server",
6
- "author": "",
7
- "license": "MIT",
8
- "keywords": ["mcp", "server", "ai", "tools"],
9
- "main": "dist/server.js",
10
- "scripts": {
11
- "build": "tsc",
12
- "dev": "tsx src/server.ts",
13
- "start": "node dist/server.js"
14
- },
15
- "dependencies": {
16
- "mcp-use": "latest"
17
- },
18
- "devDependencies": {
19
- "@types/node": "^20.0.0",
20
- "tsx": "^4.0.0",
21
- "typescript": "^5.0.0"
22
- }
23
- }
@@ -1,67 +0,0 @@
1
- import { create } from 'mcp-use/server'
2
-
3
- // Create an MCP server
4
- const mcp = create('my-mcp-server', {
5
- version: '1.0.0',
6
- description: 'A simple MCP server',
7
- })
8
-
9
- // Define a resource
10
- mcp.resource({
11
- uri: 'info://server',
12
- name: 'Server Information',
13
- description: 'Basic server information',
14
- mimeType: 'application/json',
15
- fn: async () => {
16
- return JSON.stringify({
17
- name: 'my-mcp-server',
18
- version: '1.0.0',
19
- timestamp: new Date().toISOString(),
20
- status: 'running',
21
- }, null, 2)
22
- },
23
- })
24
-
25
- // Define a tool
26
- mcp.tool({
27
- name: 'echo',
28
- description: 'Echo back the input message',
29
- inputs: [
30
- {
31
- name: 'message',
32
- type: 'string',
33
- description: 'Message to echo back',
34
- required: true,
35
- },
36
- ],
37
- fn: async ({ message }: { message: string }) => {
38
- return `Echo: ${message}`
39
- },
40
- })
41
-
42
- // Define a prompt
43
- mcp.prompt({
44
- name: 'greeting',
45
- description: 'Generate a personalized greeting',
46
- args: [
47
- {
48
- name: 'name',
49
- type: 'string',
50
- description: 'Name to greet',
51
- required: true,
52
- },
53
- ],
54
- fn: async ({ name }: { name: string }) => {
55
- return `Hello, ${name}! Welcome to the MCP server.`
56
- },
57
- })
58
-
59
- console.log('🚀 Starting MCP server...')
60
- console.log('📋 Server: my-mcp-server v1.0.0')
61
- console.log('📦 Resources: info://server')
62
- console.log('🛠️ Tools: echo')
63
- console.log('💬 Prompts: greeting')
64
- console.log('✅ Server ready!')
65
-
66
- // Start the server
67
- mcp.serve().catch(console.error)
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "rootDir": "./src",
5
- "module": "ESNext",
6
- "moduleResolution": "node",
7
- "allowJs": true,
8
- "strict": true,
9
- "declaration": true,
10
- "declarationMap": true,
11
- "outDir": "./dist",
12
- "sourceMap": true,
13
- "allowSyntheticDefaultImports": true,
14
- "esModuleInterop": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "skipLibCheck": true
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist"]
20
- }
@@ -1,139 +0,0 @@
1
- # Filesystem MCP Server
2
-
3
- A filesystem MCP server created with `create-mcp-app` that provides file and directory operations.
4
-
5
- ## Features
6
-
7
- - **📁 Directory Listing**: List files and directories
8
- - **📄 File Reading**: Read file contents
9
- - **ℹ️ File Information**: Get detailed file stats
10
- - **🎯 File Templates**: Access files by template
11
-
12
- ## Getting Started
13
-
14
- ### Development
15
-
16
- ```bash
17
- # Install dependencies
18
- npm install
19
-
20
- # Run in development mode
21
- npm run dev
22
- ```
23
-
24
- ### Production
25
-
26
- ```bash
27
- # Build the server
28
- npm run build
29
-
30
- # Run the built server
31
- npm start
32
- ```
33
-
34
- ## Available Tools
35
-
36
- ### `read-file`
37
-
38
- Read the contents of a file.
39
-
40
- **Parameters:**
41
-
42
- - `path` (string, required): Path to the file to read
43
-
44
- **Example:**
45
-
46
- ```json
47
- {
48
- "path": "README.md"
49
- }
50
- ```
51
-
52
- ### `list-directory`
53
-
54
- List files and directories in a path.
55
-
56
- **Parameters:**
57
-
58
- - `path` (string, required): Directory path to list
59
- - `include-hidden` (boolean, optional): Include hidden files
60
-
61
- **Example:**
62
-
63
- ```json
64
- {
65
- "path": "./src",
66
- "include-hidden": false
67
- }
68
- ```
69
-
70
- ### `file-info`
71
-
72
- Get detailed information about a file or directory.
73
-
74
- **Parameters:**
75
-
76
- - `path` (string, required): Path to the file or directory
77
-
78
- **Example:**
79
-
80
- ```json
81
- {
82
- "path": "package.json"
83
- }
84
- ```
85
-
86
- ## Available Resources
87
-
88
- ### `fs://current`
89
-
90
- Lists the contents of the current directory.
91
-
92
- ## Available Templates
93
-
94
- ### `file://{filename}`
95
-
96
- Template for accessing files by name.
97
-
98
- **Example:** `file://README.md` will read the README.md file.
99
-
100
- ## Security Considerations
101
-
102
- ⚠️ **Important**: This server provides full filesystem access. In production:
103
-
104
- 1. **Restrict access** to specific directories
105
- 2. **Validate paths** to prevent directory traversal attacks
106
- 3. **Set appropriate permissions** for the server process
107
- 4. **Use authentication** if exposing over network
108
-
109
- ## Customization
110
-
111
- Edit `src/server.ts` to customize the filesystem operations:
112
-
113
- ```typescript
114
- // Add path validation
115
- function validatePath(path: string) {
116
- const resolved = resolve(path)
117
- const allowedDir = resolve('./allowed-directory')
118
- return resolved.startsWith(allowedDir)
119
- }
120
-
121
- // Add custom file operations
122
- mcp.tool({
123
- name: 'search-files',
124
- description: 'Search for files by pattern',
125
- inputs: [
126
- { name: 'pattern', type: 'string', required: true },
127
- { name: 'directory', type: 'string', required: true }
128
- ],
129
- fn: async ({ pattern, directory }) => {
130
- // Implement file search logic
131
- }
132
- })
133
- ```
134
-
135
- ## Learn More
136
-
137
- - [MCP Documentation](https://modelcontextprotocol.io)
138
- - [mcp-use Documentation](https://docs.mcp-use.io)
139
- - [Node.js File System API](https://nodejs.org/api/fs.html)
@@ -1,23 +0,0 @@
1
- {
2
- "name": "my-mcp-server",
3
- "type": "module",
4
- "version": "1.0.0",
5
- "description": "MCP server: my-mcp-server",
6
- "author": "",
7
- "license": "MIT",
8
- "keywords": ["mcp", "server", "filesystem", "ai", "tools"],
9
- "main": "dist/server.js",
10
- "scripts": {
11
- "build": "tsc",
12
- "dev": "tsx src/server.ts",
13
- "start": "node dist/server.js"
14
- },
15
- "dependencies": {
16
- "mcp-use": "latest"
17
- },
18
- "devDependencies": {
19
- "@types/node": "^20.0.0",
20
- "tsx": "^4.0.0",
21
- "typescript": "^5.0.0"
22
- }
23
- }
@@ -1,155 +0,0 @@
1
- import { readdir, readFile, stat } from 'node:fs/promises'
2
- import { join } from 'node:path'
3
- import { create } from 'mcp-use/server'
4
-
5
- // Create a filesystem MCP server
6
- const mcp = create('filesystem-server', {
7
- version: '1.0.0',
8
- description: 'A filesystem MCP server for file operations',
9
- })
10
-
11
- // Resource for current directory listing
12
- mcp.resource({
13
- uri: 'fs://current',
14
- name: 'Current Directory',
15
- description: 'Contents of the current directory',
16
- mimeType: 'text/plain',
17
- fn: async () => {
18
- try {
19
- const files = await readdir('.')
20
- return files.join('\n')
21
- }
22
- catch (error) {
23
- return `Error reading directory: ${error instanceof Error ? error.message : 'Unknown error'}`
24
- }
25
- },
26
- })
27
-
28
- // Tool for reading files
29
- mcp.tool({
30
- name: 'read-file',
31
- description: 'Read the contents of a file',
32
- inputs: [
33
- {
34
- name: 'path',
35
- type: 'string',
36
- description: 'Path to the file to read',
37
- required: true,
38
- },
39
- ],
40
- fn: async ({ path }: { path: string }) => {
41
- try {
42
- const content = await readFile(path, 'utf-8')
43
- return `Contents of ${path}:\n\n${content}`
44
- }
45
- catch (error) {
46
- return `Error reading file ${path}: ${error instanceof Error ? error.message : 'File not found'}`
47
- }
48
- },
49
- })
50
-
51
- // Tool for listing directory contents
52
- mcp.tool({
53
- name: 'list-directory',
54
- description: 'List files and directories in a path',
55
- inputs: [
56
- {
57
- name: 'path',
58
- type: 'string',
59
- description: 'Directory path to list',
60
- required: true,
61
- },
62
- {
63
- name: 'include-hidden',
64
- type: 'boolean',
65
- description: 'Include hidden files (starting with .)',
66
- required: false,
67
- },
68
- ],
69
- fn: async ({ path, includeHidden = false }: { path: string, includeHidden?: boolean }) => {
70
- try {
71
- const files = await readdir(path)
72
- const filteredFiles = includeHidden
73
- ? files
74
- : files.filter(file => !file.startsWith('.'))
75
-
76
- const fileInfo = await Promise.all(
77
- filteredFiles.map(async (file) => {
78
- const fullPath = join(path, file)
79
- const stats = await stat(fullPath)
80
- const type = stats.isDirectory() ? '[DIR]' : '[FILE]'
81
- const size = stats.isFile() ? ` (${stats.size} bytes)` : ''
82
- return `${type} ${file}${size}`
83
- }),
84
- )
85
-
86
- return `Contents of ${path}:\n\n${fileInfo.join('\n')}`
87
- }
88
- catch (error) {
89
- return `Error listing directory ${path}: ${error instanceof Error ? error.message : 'Directory not found'}`
90
- }
91
- },
92
- })
93
-
94
- // Tool for getting file information
95
- mcp.tool({
96
- name: 'file-info',
97
- description: 'Get detailed information about a file or directory',
98
- inputs: [
99
- {
100
- name: 'path',
101
- type: 'string',
102
- description: 'Path to the file or directory',
103
- required: true,
104
- },
105
- ],
106
- fn: async ({ path }: { path: string }) => {
107
- try {
108
- const stats = await stat(path)
109
- const info = {
110
- name: path,
111
- type: stats.isDirectory() ? 'directory' : 'file',
112
- size: stats.size,
113
- created: stats.birthtime.toISOString(),
114
- modified: stats.mtime.toISOString(),
115
- permissions: {
116
- readable: true, // Assume readable if we can stat
117
- writable: true, // Would need additional checks
118
- executable: !!(stats.mode & 0o111),
119
- },
120
- }
121
-
122
- return `File Information for ${path}:\n\n${JSON.stringify(info, null, 2)}`
123
- }
124
- catch (error) {
125
- return `Error getting file info for ${path}: ${error instanceof Error ? error.message : 'File not found'}`
126
- }
127
- },
128
- })
129
-
130
- // Template for file access
131
- mcp.template({
132
- uriTemplate: 'file://{filename}',
133
- name: 'File Template',
134
- description: 'Template for accessing files by name',
135
- mimeType: 'text/plain',
136
- fn: async ({ filename }: { filename: string }) => {
137
- try {
138
- const content = await readFile(filename, 'utf-8')
139
- return `Contents of ${filename}:\n\n${content}`
140
- }
141
- catch (error) {
142
- return `Error reading file ${filename}: ${error instanceof Error ? error.message : 'File not found'}`
143
- }
144
- },
145
- })
146
-
147
- console.log('🚀 Starting Filesystem MCP Server...')
148
- console.log('📋 Server: filesystem-server v1.0.0')
149
- console.log('📦 Resources: fs://current')
150
- console.log('🛠️ Tools: read-file, list-directory, file-info')
151
- console.log('🎯 Templates: file://{filename}')
152
- console.log('✅ Server ready!')
153
-
154
- // Start the server
155
- mcp.serve().catch(console.error)
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "rootDir": "./src",
5
- "module": "ESNext",
6
- "moduleResolution": "node",
7
- "allowJs": true,
8
- "strict": true,
9
- "declaration": true,
10
- "declarationMap": true,
11
- "outDir": "./dist",
12
- "sourceMap": true,
13
- "allowSyntheticDefaultImports": true,
14
- "esModuleInterop": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "skipLibCheck": true
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist"]
20
- }