kadins-personal-mcp 1.0.0 → 1.0.1

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,88 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const name = "file_search";
4
- export const description = "Search for files by name, content, or pattern in a directory";
5
- export const parameters = {
6
- pattern: z.string().describe("The pattern to search for (file name or content)"),
7
- directory: z.string().describe("The directory to search in").optional().default("."),
8
- searchInContent: z.boolean().describe("Whether to search in file content (true) or just filenames (false)").optional().default(false)
9
- };
10
- export const handler = async (params: { pattern: string; directory: string; searchInContent: boolean }) => {
11
- try {
12
- const fs = await import("fs");
13
- const path = await import("path");
14
-
15
- const searchDir = params.directory || ".";
16
- const resolvedDir = path.resolve(searchDir);
17
-
18
- // Check if the directory is within the current working directory to prevent path traversal
19
- const cwd = process.cwd();
20
- if (!resolvedDir.startsWith(cwd)) {
21
- return {
22
- content: [{ type: "text", text: "Error: Directory traversal is not allowed" }]
23
- };
24
- }
25
-
26
- if (!fs.existsSync(resolvedDir)) {
27
- return {
28
- content: [{ type: "text", text: `Error: Directory does not exist: ${resolvedDir}` }]
29
- };
30
- }
31
-
32
- if (!fs.statSync(resolvedDir).isDirectory()) {
33
- return {
34
- content: [{ type: "text", text: `Error: Path is not a directory: ${resolvedDir}` }]
35
- };
36
- }
37
-
38
- const results: string[] = [];
39
-
40
- function searchRecursive(dir: string) {
41
- const items = fs.readdirSync(dir);
42
-
43
- for (const item of items) {
44
- const itemPath = path.join(dir, item);
45
- const stat = fs.statSync(itemPath);
46
-
47
- if (stat.isDirectory()) {
48
- // Skip node_modules and other common directories that shouldn't be searched
49
- if (item !== "node_modules" && !item.startsWith(".")) {
50
- searchRecursive(itemPath);
51
- }
52
- } else {
53
- // Check filename match
54
- if (item.includes(params.pattern)) {
55
- results.push(itemPath);
56
- }
57
- // Check content match if requested
58
- else if (params.searchInContent) {
59
- try {
60
- const content = fs.readFileSync(itemPath, "utf-8");
61
- if (content.includes(params.pattern)) {
62
- results.push(itemPath);
63
- }
64
- } catch (e) {
65
- // Skip binary files or files that can't be read
66
- }
67
- }
68
- }
69
- }
70
- }
71
-
72
- searchRecursive(resolvedDir);
73
-
74
- if (results.length === 0) {
75
- return {
76
- content: [{ type: "text", text: `No files found matching pattern: ${params.pattern}` }]
77
- };
78
- }
79
-
80
- return {
81
- content: [{ type: "text", text: `Found ${results.length} file(s):\n${results.join("\n")}` }]
82
- };
83
- } catch (error) {
84
- return {
85
- content: [{ type: "text", text: `Error searching files: ${(error as Error).message}` }]
86
- };
87
- }
88
- };
@@ -1,50 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const name = "file_write";
4
- export const description = "Write content to a file (with safety checks to prevent overwrites)";
5
- export const parameters = {
6
- path: z.string().describe("The path to the file to write"),
7
- content: z.string().describe("The content to write to the file"),
8
- overwrite: z.boolean().describe("Whether to overwrite an existing file").optional().default(false)
9
- };
10
- export const handler = async (params: { path: string; content: string; overwrite: boolean }) => {
11
- try {
12
- const fs = await import("fs");
13
- const path = await import("path");
14
-
15
- // Resolve the path relative to the current working directory
16
- const resolvedPath = path.resolve(params.path);
17
-
18
- // Check if the path is within the current working directory to prevent path traversal
19
- const cwd = process.cwd();
20
- if (!resolvedPath.startsWith(cwd)) {
21
- return {
22
- content: [{ type: "text", text: "Error: Path traversal is not allowed" }]
23
- };
24
- }
25
-
26
- // Check if file exists and overwrite is not allowed
27
- if (fs.existsSync(resolvedPath) && !params.overwrite) {
28
- return {
29
- content: [{ type: "text", text: `Error: File already exists at ${params.path}. Use overwrite=true to overwrite.` }]
30
- };
31
- }
32
-
33
- // Create directory if it doesn't exist
34
- const dir = path.dirname(resolvedPath);
35
- if (!fs.existsSync(dir)) {
36
- fs.mkdirSync(dir, { recursive: true });
37
- }
38
-
39
- // Write the content to the file
40
- fs.writeFileSync(resolvedPath, params.content, "utf-8");
41
-
42
- return {
43
- content: [{ type: "text", text: `Successfully wrote ${params.content.length} characters to ${params.path}` }]
44
- };
45
- } catch (error) {
46
- return {
47
- content: [{ type: "text", text: `Error writing file: ${(error as Error).message}` }]
48
- };
49
- }
50
- };
package/tools/readFile.ts DELETED
@@ -1,39 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const name = "read_file";
4
- export const description = "Read the contents of a file";
5
- export const parameters = {
6
- path: z.string().describe("The path to the file to read")
7
- };
8
- export const handler = async (params: { path: string }) => {
9
- try {
10
- const fs = await import("fs");
11
- const path = await import("path");
12
-
13
- // Resolve the path relative to the current working directory
14
- const resolvedPath = path.resolve(params.path);
15
-
16
- // Check if the path is within the current working directory to prevent path traversal
17
- const cwd = process.cwd();
18
- if (!resolvedPath.startsWith(cwd)) {
19
- return {
20
- content: [{ type: "text", text: "Error: Path traversal is not allowed" }]
21
- };
22
- }
23
-
24
- if (!fs.existsSync(resolvedPath)) {
25
- return {
26
- content: [{ type: "text", text: `Error: File does not exist: ${params.path}` }]
27
- };
28
- }
29
-
30
- const content = fs.readFileSync(resolvedPath, "utf-8");
31
- return {
32
- content: [{ type: "text", text: content }]
33
- };
34
- } catch (error) {
35
- return {
36
- content: [{ type: "text", text: `Error reading file: ${error.message}` }]
37
- };
38
- }
39
- };
@@ -1,38 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const name = "run_command";
4
- export const description = "Execute a shell command on the system";
5
- export const parameters = {
6
- command: z.string().describe("The shell command to execute")
7
- };
8
- export const handler = async (params: { command: string }) => {
9
- try {
10
- // Dynamically import child_process
11
- const { exec } = await import("child_process");
12
- const util = await import("util");
13
-
14
- // Use util.promisify to convert exec to a promise-based function
15
- const execPromise = util.promisify(exec);
16
-
17
- // Execute the command with a timeout for safety
18
- const { stdout, stderr } = await Promise.race([
19
- execPromise(params.command),
20
- new Promise((_, reject) =>
21
- setTimeout(() => reject(new Error('Command timed out after 10 seconds')), 10000)
22
- )
23
- ]);
24
-
25
- // Return both stdout and stderr
26
- return {
27
- content: [
28
- { type: "text", text: `Command: ${params.command}\n\nOutput:\n${stdout || stderr || 'Command executed successfully with no output'}` }
29
- ]
30
- };
31
- } catch (error) {
32
- return {
33
- content: [
34
- { type: "text", text: `Error executing command: ${params.command}\n\nError: ${(error as Error).message}` }
35
- ]
36
- };
37
- }
38
- };
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "Node16",
4
- "moduleResolution": "Node16",
5
- "esModuleInterop": true,
6
- "isolatedModules": true,
7
- "outDir": "./dist",
8
- "rootDir": "./src"
9
- },
10
- "exclude": ["node_modules", "dist"],
11
- "include": ["src/**/*", "package.json"]
12
- }