@j0hanz/filesystem-context-mcp 1.0.0

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.
Files changed (146) hide show
  1. package/README.md +369 -0
  2. package/dist/__tests__/errors.test.d.ts +2 -0
  3. package/dist/__tests__/errors.test.d.ts.map +1 -0
  4. package/dist/__tests__/errors.test.js +88 -0
  5. package/dist/__tests__/errors.test.js.map +1 -0
  6. package/dist/__tests__/file-operations.test.d.ts +2 -0
  7. package/dist/__tests__/file-operations.test.d.ts.map +1 -0
  8. package/dist/__tests__/file-operations.test.js +230 -0
  9. package/dist/__tests__/file-operations.test.js.map +1 -0
  10. package/dist/__tests__/lib/errors.test.d.ts +2 -0
  11. package/dist/__tests__/lib/errors.test.d.ts.map +1 -0
  12. package/dist/__tests__/lib/errors.test.js +156 -0
  13. package/dist/__tests__/lib/errors.test.js.map +1 -0
  14. package/dist/__tests__/lib/file-operations.test.d.ts +2 -0
  15. package/dist/__tests__/lib/file-operations.test.d.ts.map +1 -0
  16. package/dist/__tests__/lib/file-operations.test.js +417 -0
  17. package/dist/__tests__/lib/file-operations.test.js.map +1 -0
  18. package/dist/__tests__/lib/fs-helpers.test.d.ts +2 -0
  19. package/dist/__tests__/lib/fs-helpers.test.d.ts.map +1 -0
  20. package/dist/__tests__/lib/fs-helpers.test.js +183 -0
  21. package/dist/__tests__/lib/fs-helpers.test.js.map +1 -0
  22. package/dist/__tests__/lib/path-validation.test.d.ts +2 -0
  23. package/dist/__tests__/lib/path-validation.test.d.ts.map +1 -0
  24. package/dist/__tests__/lib/path-validation.test.js +103 -0
  25. package/dist/__tests__/lib/path-validation.test.js.map +1 -0
  26. package/dist/__tests__/path-validation.test.d.ts +2 -0
  27. package/dist/__tests__/path-validation.test.d.ts.map +1 -0
  28. package/dist/__tests__/path-validation.test.js +92 -0
  29. package/dist/__tests__/path-validation.test.js.map +1 -0
  30. package/dist/config/types.d.ts +222 -0
  31. package/dist/config/types.d.ts.map +1 -0
  32. package/dist/config/types.js +23 -0
  33. package/dist/config/types.js.map +1 -0
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +50 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/lib/constants.d.ts +16 -0
  39. package/dist/lib/constants.d.ts.map +1 -0
  40. package/dist/lib/constants.js +335 -0
  41. package/dist/lib/constants.js.map +1 -0
  42. package/dist/lib/errors.d.ts +33 -0
  43. package/dist/lib/errors.d.ts.map +1 -0
  44. package/dist/lib/errors.js +205 -0
  45. package/dist/lib/errors.js.map +1 -0
  46. package/dist/lib/file-operations.d.ts +69 -0
  47. package/dist/lib/file-operations.d.ts.map +1 -0
  48. package/dist/lib/file-operations.js +1003 -0
  49. package/dist/lib/file-operations.js.map +1 -0
  50. package/dist/lib/formatters.d.ts +30 -0
  51. package/dist/lib/formatters.d.ts.map +1 -0
  52. package/dist/lib/formatters.js +204 -0
  53. package/dist/lib/formatters.js.map +1 -0
  54. package/dist/lib/fs-helpers.d.ts +29 -0
  55. package/dist/lib/fs-helpers.d.ts.map +1 -0
  56. package/dist/lib/fs-helpers.js +295 -0
  57. package/dist/lib/fs-helpers.js.map +1 -0
  58. package/dist/lib/path-utils.d.ts +12 -0
  59. package/dist/lib/path-utils.d.ts.map +1 -0
  60. package/dist/lib/path-utils.js +34 -0
  61. package/dist/lib/path-utils.js.map +1 -0
  62. package/dist/lib/path-validation.d.ts +31 -0
  63. package/dist/lib/path-validation.d.ts.map +1 -0
  64. package/dist/lib/path-validation.js +181 -0
  65. package/dist/lib/path-validation.js.map +1 -0
  66. package/dist/lib/roots-utils.d.ts +7 -0
  67. package/dist/lib/roots-utils.d.ts.map +1 -0
  68. package/dist/lib/roots-utils.js +39 -0
  69. package/dist/lib/roots-utils.js.map +1 -0
  70. package/dist/lib/types.d.ts +6 -0
  71. package/dist/lib/types.d.ts.map +1 -0
  72. package/dist/lib/types.js +2 -0
  73. package/dist/lib/types.js.map +1 -0
  74. package/dist/schemas/common.d.ts +41 -0
  75. package/dist/schemas/common.d.ts.map +1 -0
  76. package/dist/schemas/common.js +21 -0
  77. package/dist/schemas/common.js.map +1 -0
  78. package/dist/schemas/index.d.ts +3 -0
  79. package/dist/schemas/index.d.ts.map +1 -0
  80. package/dist/schemas/index.js +5 -0
  81. package/dist/schemas/index.js.map +1 -0
  82. package/dist/schemas/inputs.d.ts +72 -0
  83. package/dist/schemas/inputs.d.ts.map +1 -0
  84. package/dist/schemas/inputs.js +326 -0
  85. package/dist/schemas/inputs.js.map +1 -0
  86. package/dist/schemas/outputs.d.ts +476 -0
  87. package/dist/schemas/outputs.d.ts.map +1 -0
  88. package/dist/schemas/outputs.js +181 -0
  89. package/dist/schemas/outputs.js.map +1 -0
  90. package/dist/server.d.ts +5 -0
  91. package/dist/server.d.ts.map +1 -0
  92. package/dist/server.js +83 -0
  93. package/dist/server.js.map +1 -0
  94. package/dist/tools/analyze-directory.d.ts +3 -0
  95. package/dist/tools/analyze-directory.d.ts.map +1 -0
  96. package/dist/tools/analyze-directory.js +57 -0
  97. package/dist/tools/analyze-directory.js.map +1 -0
  98. package/dist/tools/directory-tree.d.ts +3 -0
  99. package/dist/tools/directory-tree.d.ts.map +1 -0
  100. package/dist/tools/directory-tree.js +47 -0
  101. package/dist/tools/directory-tree.js.map +1 -0
  102. package/dist/tools/get-file-info.d.ts +3 -0
  103. package/dist/tools/get-file-info.d.ts.map +1 -0
  104. package/dist/tools/get-file-info.js +44 -0
  105. package/dist/tools/get-file-info.js.map +1 -0
  106. package/dist/tools/index.d.ts +3 -0
  107. package/dist/tools/index.d.ts.map +1 -0
  108. package/dist/tools/index.js +23 -0
  109. package/dist/tools/index.js.map +1 -0
  110. package/dist/tools/list-allowed-dirs.d.ts +3 -0
  111. package/dist/tools/list-allowed-dirs.d.ts.map +1 -0
  112. package/dist/tools/list-allowed-dirs.js +23 -0
  113. package/dist/tools/list-allowed-dirs.js.map +1 -0
  114. package/dist/tools/list-directory.d.ts +3 -0
  115. package/dist/tools/list-directory.d.ts.map +1 -0
  116. package/dist/tools/list-directory.js +60 -0
  117. package/dist/tools/list-directory.js.map +1 -0
  118. package/dist/tools/read-file.d.ts +3 -0
  119. package/dist/tools/read-file.d.ts.map +1 -0
  120. package/dist/tools/read-file.js +55 -0
  121. package/dist/tools/read-file.js.map +1 -0
  122. package/dist/tools/read-media-file.d.ts +3 -0
  123. package/dist/tools/read-media-file.d.ts.map +1 -0
  124. package/dist/tools/read-media-file.js +48 -0
  125. package/dist/tools/read-media-file.js.map +1 -0
  126. package/dist/tools/read-multiple-files.d.ts +3 -0
  127. package/dist/tools/read-multiple-files.d.ts.map +1 -0
  128. package/dist/tools/read-multiple-files.js +53 -0
  129. package/dist/tools/read-multiple-files.js.map +1 -0
  130. package/dist/tools/search-content.d.ts +3 -0
  131. package/dist/tools/search-content.d.ts.map +1 -0
  132. package/dist/tools/search-content.js +67 -0
  133. package/dist/tools/search-content.js.map +1 -0
  134. package/dist/tools/search-files.d.ts +3 -0
  135. package/dist/tools/search-files.d.ts.map +1 -0
  136. package/dist/tools/search-files.js +51 -0
  137. package/dist/tools/search-files.js.map +1 -0
  138. package/dist/utils/index.d.ts +2 -0
  139. package/dist/utils/index.d.ts.map +1 -0
  140. package/dist/utils/index.js +2 -0
  141. package/dist/utils/index.js.map +1 -0
  142. package/dist/utils/response-helpers.d.ts +22 -0
  143. package/dist/utils/response-helpers.d.ts.map +1 -0
  144. package/dist/utils/response-helpers.js +24 -0
  145. package/dist/utils/response-helpers.js.map +1 -0
  146. package/package.json +61 -0
package/dist/server.js ADDED
@@ -0,0 +1,83 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import { RootsListChangedNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
6
+ import { normalizePath } from './lib/path-utils.js';
7
+ import { getAllowedDirectories, getValidRootDirectories, setAllowedDirectories, } from './lib/path-validation.js';
8
+ import { registerAllTools } from './tools/index.js';
9
+ // Get version from package.json
10
+ const require = createRequire(import.meta.url);
11
+ const packageJson = require('../package.json');
12
+ const SERVER_VERSION = packageJson.version;
13
+ export async function parseArgs() {
14
+ const args = process.argv.slice(2);
15
+ // Allow empty args when roots protocol is available
16
+ if (args.length === 0) {
17
+ return [];
18
+ }
19
+ const validatedDirs = [];
20
+ for (const dir of args) {
21
+ const normalized = normalizePath(dir);
22
+ try {
23
+ const stats = await fs.stat(normalized);
24
+ if (!stats.isDirectory()) {
25
+ throw new Error(`Error: '${dir}' is not a directory`);
26
+ }
27
+ validatedDirs.push(normalized);
28
+ }
29
+ catch (error) {
30
+ if (error instanceof Error && error.message.startsWith('Error:')) {
31
+ throw error;
32
+ }
33
+ throw new Error(`Error: Cannot access directory '${dir}'`);
34
+ }
35
+ }
36
+ return validatedDirs;
37
+ }
38
+ async function updateRootsFromClient(server) {
39
+ try {
40
+ const rootsResult = await server.server.listRoots();
41
+ if (rootsResult.roots.length > 0) {
42
+ const validDirs = await getValidRootDirectories(rootsResult.roots);
43
+ if (validDirs.length > 0) {
44
+ const currentDirs = getAllowedDirectories();
45
+ const mergedDirs = [...new Set([...currentDirs, ...validDirs])];
46
+ setAllowedDirectories(mergedDirs);
47
+ console.error('Updated allowed directories from roots:', mergedDirs);
48
+ }
49
+ }
50
+ }
51
+ catch (error) {
52
+ const message = error instanceof Error ? error.message : String(error);
53
+ console.error('Roots protocol not available:', message);
54
+ }
55
+ }
56
+ export function createServer() {
57
+ const server = new McpServer({
58
+ name: 'filesystem-context-mcp',
59
+ version: SERVER_VERSION,
60
+ });
61
+ registerAllTools(server);
62
+ return server;
63
+ }
64
+ export async function startServer(server) {
65
+ const transport = new StdioServerTransport();
66
+ server.server.setNotificationHandler(RootsListChangedNotificationSchema, async () => {
67
+ console.error('Received roots/list_changed notification');
68
+ await updateRootsFromClient(server);
69
+ });
70
+ await server.connect(transport);
71
+ console.error('Server connected and ready');
72
+ // Try to update roots from client after connection
73
+ // We don't wait for this to complete, but we log a warning if no roots are found after a short delay
74
+ // This is a best-effort check for the user
75
+ void updateRootsFromClient(server).then(() => {
76
+ const dirs = getAllowedDirectories();
77
+ if (dirs.length === 0) {
78
+ console.error('Warning: No allowed directories configured.');
79
+ console.error('Either specify directories via CLI arguments or ensure client provides roots.');
80
+ }
81
+ });
82
+ }
83
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,gCAAgC;AAChC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AACtE,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,oDAAoD;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ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AAC,KAAK,CACX,+EAA+E,CAChF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAnalyzeDirectoryTool(server: McpServer): void;
3
+ //# sourceMappingURL=analyze-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-directory.d.ts","sourceRoot":"","sources":["../../src/tools/analyze-directory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsDpE"}
@@ -0,0 +1,57 @@
1
+ import * as nodePath from 'node:path';
2
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
3
+ import { analyzeDirectory } from '../lib/file-operations.js';
4
+ import { formatDirectoryAnalysis } from '../lib/formatters.js';
5
+ import { AnalyzeDirectoryInputSchema, AnalyzeDirectoryOutputSchema, } from '../schemas/index.js';
6
+ export function registerAnalyzeDirectoryTool(server) {
7
+ server.registerTool('analyze_directory', {
8
+ title: 'Analyze Directory',
9
+ description: 'Analyze a directory structure. Returns statistics including file counts, sizes, types, and lists of largest/recently modified files.',
10
+ inputSchema: AnalyzeDirectoryInputSchema,
11
+ outputSchema: AnalyzeDirectoryOutputSchema,
12
+ annotations: {
13
+ readOnlyHint: true,
14
+ idempotentHint: true,
15
+ },
16
+ }, async ({ path, maxDepth, topN, excludePatterns, includeHidden }) => {
17
+ try {
18
+ const result = await analyzeDirectory(path, {
19
+ maxDepth,
20
+ topN,
21
+ excludePatterns,
22
+ includeHidden,
23
+ });
24
+ const structured = {
25
+ ok: true,
26
+ path: result.analysis.path,
27
+ totalFiles: result.analysis.totalFiles,
28
+ totalDirectories: result.analysis.totalDirectories,
29
+ totalSize: result.analysis.totalSize,
30
+ fileTypes: result.analysis.fileTypes,
31
+ largestFiles: result.analysis.largestFiles.map((f) => ({
32
+ path: nodePath.relative(result.analysis.path, f.path),
33
+ size: f.size,
34
+ })),
35
+ recentlyModified: result.analysis.recentlyModified.map((f) => ({
36
+ path: nodePath.relative(result.analysis.path, f.path),
37
+ modified: f.modified.toISOString(),
38
+ })),
39
+ summary: {
40
+ truncated: result.summary.truncated,
41
+ skippedInaccessible: result.summary.skippedInaccessible,
42
+ skippedSymlinks: result.summary.skippedSymlinks,
43
+ },
44
+ };
45
+ return {
46
+ content: [
47
+ { type: 'text', text: formatDirectoryAnalysis(result.analysis) },
48
+ ],
49
+ structuredContent: structured,
50
+ };
51
+ }
52
+ catch (error) {
53
+ return createErrorResponse(error, ErrorCode.E_NOT_DIRECTORY, path);
54
+ }
55
+ });
56
+ }
57
+ //# sourceMappingURL=analyze-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-directory.js","sourceRoot":"","sources":["../../src/tools/analyze-directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAItC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,4BAA4B,CAAC,MAAiB;IAC5D,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,sIAAsI;QACxI,WAAW,EAAE,2BAA2B;QACxC,YAAY,EAAE,4BAA4B;QAC1C,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa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,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;iBACjE;gBACD,iBAAiB,EAAE,UAAU;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDirectoryTreeTool(server: McpServer): void;
3
+ //# sourceMappingURL=directory-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../src/tools/directory-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuDjE"}
@@ -0,0 +1,47 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { getDirectoryTree } from '../lib/file-operations.js';
3
+ import { formatTreeEntry } from '../lib/formatters.js';
4
+ import { DirectoryTreeInputSchema, DirectoryTreeOutputSchema, } from '../schemas/index.js';
5
+ export function registerDirectoryTreeTool(server) {
6
+ server.registerTool('directory_tree', {
7
+ title: 'Directory Tree',
8
+ description: 'Get a JSON tree structure of a directory. More efficient for AI parsing than flat file lists. Useful for understanding project structure.',
9
+ inputSchema: DirectoryTreeInputSchema,
10
+ outputSchema: DirectoryTreeOutputSchema,
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ idempotentHint: true,
14
+ },
15
+ }, async ({ path, maxDepth, excludePatterns, includeHidden, includeSize, maxFiles, }) => {
16
+ try {
17
+ const result = await getDirectoryTree(path, {
18
+ maxDepth,
19
+ excludePatterns,
20
+ includeHidden,
21
+ includeSize,
22
+ maxFiles,
23
+ });
24
+ const textOutput = formatTreeEntry(result.tree);
25
+ const structured = {
26
+ ok: true,
27
+ tree: result.tree,
28
+ summary: {
29
+ totalFiles: result.summary.totalFiles,
30
+ totalDirectories: result.summary.totalDirectories,
31
+ maxDepthReached: result.summary.maxDepthReached,
32
+ truncated: result.summary.truncated,
33
+ skippedInaccessible: result.summary.skippedInaccessible,
34
+ skippedSymlinks: result.summary.skippedSymlinks,
35
+ },
36
+ };
37
+ return {
38
+ content: [{ type: 'text', text: textOutput }],
39
+ structuredContent: structured,
40
+ };
41
+ }
42
+ catch (error) {
43
+ return createErrorResponse(error, ErrorCode.E_NOT_DIRECTORY, path);
44
+ }
45
+ });
46
+ }
47
+ //# sourceMappingURL=directory-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-tree.js","sourceRoot":"","sources":["../../src/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IACzD,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,2IAA2I;QAC7I,WAAW,EAAE,wBAAwB;QACrC,YAAY,EAAE,yBAAyB;QACvC,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EACL,IAAI,EACJ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,WAAW,EACX,QAAQ,GACT,EAAE,EAAE;QACH,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE;gBAC1C,QAAQ;gBACR,eAAe;gBACf,aAAa;gBACb,WAAW;gBACX,QAAQ;aACT,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEhD,MAAM,UAAU,GAAG;gBACjB,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE;oBACP,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;oBACrC,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB;oBACjD,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe;oBAC/C,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;oBACnC,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,mBAAmB;oBACvD,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe;iBAChD;aACF,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;gBAC7C,iBAAiB,EAAE,UAAU;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerGetFileInfoTool(server: McpServer): void;
3
+ //# sourceMappingURL=get-file-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-info.d.ts","sourceRoot":"","sources":["../../src/tools/get-file-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0C/D"}
@@ -0,0 +1,44 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { getFileInfo } from '../lib/file-operations.js';
3
+ import { formatFileInfo } from '../lib/formatters.js';
4
+ import { GetFileInfoInputSchema, GetFileInfoOutputSchema, } from '../schemas/index.js';
5
+ export function registerGetFileInfoTool(server) {
6
+ server.registerTool('get_file_info', {
7
+ title: 'Get File Info',
8
+ description: 'Get detailed metadata about a file or directory including size, timestamps, and permissions.',
9
+ inputSchema: GetFileInfoInputSchema,
10
+ outputSchema: GetFileInfoOutputSchema,
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ idempotentHint: true,
14
+ },
15
+ }, async ({ path }) => {
16
+ try {
17
+ const info = await getFileInfo(path);
18
+ const structured = {
19
+ ok: true,
20
+ info: {
21
+ name: info.name,
22
+ path: info.path,
23
+ type: info.type,
24
+ size: info.size,
25
+ created: info.created.toISOString(),
26
+ modified: info.modified.toISOString(),
27
+ accessed: info.accessed.toISOString(),
28
+ permissions: info.permissions,
29
+ isHidden: info.isHidden,
30
+ mimeType: info.mimeType,
31
+ symlinkTarget: info.symlinkTarget,
32
+ },
33
+ };
34
+ return {
35
+ content: [{ type: 'text', text: formatFileInfo(info) }],
36
+ structuredContent: structured,
37
+ };
38
+ }
39
+ catch (error) {
40
+ return createErrorResponse(error, ErrorCode.E_NOT_FOUND, path);
41
+ }
42
+ });
43
+ }
44
+ //# sourceMappingURL=get-file-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-info.js","sourceRoot":"","sources":["../../src/tools/get-file-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,sBAAsB,EACt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,IAAI,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAllTools(server: McpServer): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAazE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAWxD"}
@@ -0,0 +1,23 @@
1
+ import { registerAnalyzeDirectoryTool } from './analyze-directory.js';
2
+ import { registerDirectoryTreeTool } from './directory-tree.js';
3
+ import { registerGetFileInfoTool } from './get-file-info.js';
4
+ import { registerListAllowedDirectoriesTool } from './list-allowed-dirs.js';
5
+ import { registerListDirectoryTool } from './list-directory.js';
6
+ import { registerReadFileTool } from './read-file.js';
7
+ import { registerReadMediaFileTool } from './read-media-file.js';
8
+ import { registerReadMultipleFilesTool } from './read-multiple-files.js';
9
+ import { registerSearchContentTool } from './search-content.js';
10
+ import { registerSearchFilesTool } from './search-files.js';
11
+ export function registerAllTools(server) {
12
+ registerListAllowedDirectoriesTool(server);
13
+ registerListDirectoryTool(server);
14
+ registerSearchFilesTool(server);
15
+ registerReadFileTool(server);
16
+ registerReadMultipleFilesTool(server);
17
+ registerGetFileInfoTool(server);
18
+ registerSearchContentTool(server);
19
+ registerAnalyzeDirectoryTool(server);
20
+ registerDirectoryTreeTool(server);
21
+ registerReadMediaFileTool(server);
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAC3C,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACtC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACrC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerListAllowedDirectoriesTool(server: McpServer): void;
3
+ //# sourceMappingURL=list-allowed-dirs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-allowed-dirs.d.ts","sourceRoot":"","sources":["../../src/tools/list-allowed-dirs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuB1E"}
@@ -0,0 +1,23 @@
1
+ import { formatAllowedDirectories } from '../lib/formatters.js';
2
+ import { getAllowedDirectories } from '../lib/path-validation.js';
3
+ import { ListAllowedDirectoriesOutputSchema } from '../schemas/index.js';
4
+ export function registerListAllowedDirectoriesTool(server) {
5
+ server.registerTool('list_allowed_directories', {
6
+ title: 'List Allowed Directories',
7
+ description: 'List all directories that this server is allowed to access. Use this to understand the scope of available file operations.',
8
+ inputSchema: {},
9
+ outputSchema: ListAllowedDirectoriesOutputSchema,
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ },
14
+ }, () => {
15
+ const dirs = getAllowedDirectories();
16
+ const structured = { ok: true, allowedDirectories: dirs };
17
+ return {
18
+ content: [{ type: 'text', text: formatAllowedDirectories(dirs) }],
19
+ structuredContent: structured,
20
+ };
21
+ });
22
+ }
23
+ //# sourceMappingURL=list-allowed-dirs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-allowed-dirs.js","sourceRoot":"","sources":["../../src/tools/list-allowed-dirs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEzE,MAAM,UAAU,kCAAkC,CAAC,MAAiB;IAClE,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EACT,4HAA4H;QAC9H,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,kCAAkC;QAChD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,GAAG,EAAE;QACH,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC1D,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;YACjE,iBAAiB,EAAE,UAAU;SAC9B,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerListDirectoryTool(server: McpServer): void;
3
+ //# sourceMappingURL=list-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-directory.d.ts","sourceRoot":"","sources":["../../src/tools/list-directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkEjE"}
@@ -0,0 +1,60 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { listDirectory } from '../lib/file-operations.js';
3
+ import { formatDirectoryListing } from '../lib/formatters.js';
4
+ import { ListDirectoryInputSchema, ListDirectoryOutputSchema, } from '../schemas/index.js';
5
+ export function registerListDirectoryTool(server) {
6
+ server.registerTool('list_directory', {
7
+ title: 'List Directory',
8
+ description: 'List contents of a directory. Returns files and subdirectories with their types and sizes. Supports recursive listing.',
9
+ inputSchema: ListDirectoryInputSchema,
10
+ outputSchema: ListDirectoryOutputSchema,
11
+ annotations: {
12
+ readOnlyHint: true,
13
+ idempotentHint: true,
14
+ },
15
+ }, async ({ path, recursive, includeHidden, maxDepth, maxEntries, sortBy, includeSymlinkTargets, }) => {
16
+ try {
17
+ const result = await listDirectory(path, {
18
+ recursive,
19
+ includeHidden,
20
+ maxDepth,
21
+ maxEntries,
22
+ sortBy,
23
+ includeSymlinkTargets,
24
+ });
25
+ const structured = {
26
+ ok: true,
27
+ path: result.path,
28
+ entries: result.entries.map((e) => ({
29
+ name: e.relativePath,
30
+ type: e.type,
31
+ size: e.size,
32
+ modified: e.modified?.toISOString(),
33
+ symlinkTarget: e.symlinkTarget,
34
+ })),
35
+ summary: {
36
+ totalEntries: result.summary.totalEntries,
37
+ totalFiles: result.summary.totalFiles,
38
+ totalDirectories: result.summary.totalDirectories,
39
+ maxDepthReached: result.summary.maxDepthReached,
40
+ truncated: result.summary.truncated,
41
+ skippedInaccessible: result.summary.skippedInaccessible,
42
+ skippedSymlinks: result.summary.skippedSymlinks,
43
+ },
44
+ };
45
+ return {
46
+ content: [
47
+ {
48
+ type: 'text',
49
+ text: formatDirectoryListing(result.entries, result.path),
50
+ },
51
+ ],
52
+ structuredContent: structured,
53
+ };
54
+ }
55
+ catch (error) {
56
+ return createErrorResponse(error, ErrorCode.E_NOT_DIRECTORY, path);
57
+ }
58
+ });
59
+ }
60
+ //# sourceMappingURL=list-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-directory.js","sourceRoot":"","sources":["../../src/tools/list-directory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IACzD,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,wHAAwH;QAC1H,WAAW,EAAE,wBAAwB;QACrC,YAAY,EAAE,yBAAyB;QACvC,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EACL,IAAI,EACJ,SAAS,EACT,aAAa,EACb,QAAQ,EACR,UAAU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,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerReadFileTool(server: McpServer): void;
3
+ //# sourceMappingURL=read-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyD5D"}
@@ -0,0 +1,55 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { readFile } from '../lib/file-operations.js';
3
+ import { ReadFileInputSchema, ReadFileOutputSchema } from '../schemas/index.js';
4
+ export function registerReadFileTool(server) {
5
+ server.registerTool('read_file', {
6
+ title: 'Read File',
7
+ description: 'Read the contents of a file. Supports different encodings, reading specific line ranges, and efficient head/tail operations for large files.',
8
+ inputSchema: ReadFileInputSchema,
9
+ outputSchema: ReadFileOutputSchema,
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ },
14
+ }, async ({ path, encoding, maxSize, lineStart, lineEnd, head, tail }) => {
15
+ try {
16
+ const lineRange = lineStart !== undefined && lineEnd !== undefined
17
+ ? { start: lineStart, end: lineEnd }
18
+ : undefined;
19
+ const result = await readFile(path, {
20
+ encoding: encoding,
21
+ maxSize,
22
+ lineRange,
23
+ head,
24
+ tail,
25
+ });
26
+ let text = result.content;
27
+ if (result.truncated) {
28
+ if (result.totalLines) {
29
+ text += `\n\n[Showing requested lines. Total lines in file: ${result.totalLines}]`;
30
+ }
31
+ else if (head !== undefined) {
32
+ text += `\n\n[Showing first ${String(head)} lines]`;
33
+ }
34
+ else if (tail !== undefined) {
35
+ text += `\n\n[Showing last ${String(tail)} lines]`;
36
+ }
37
+ }
38
+ const structured = {
39
+ ok: true,
40
+ path,
41
+ content: result.content,
42
+ truncated: result.truncated,
43
+ totalLines: result.totalLines,
44
+ };
45
+ return {
46
+ content: [{ type: 'text', text }],
47
+ structuredContent: structured,
48
+ };
49
+ }
50
+ catch (error) {
51
+ return createErrorResponse(error, ErrorCode.E_NOT_FILE, path);
52
+ }
53
+ });
54
+ }
55
+ //# sourceMappingURL=read-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../src/tools/read-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhF,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,MAAM,CAAC,YAAY,CACjB,WAAW,EACX;QACE,KAAK,EAAE,WAAW;QAClB,WAAW,EACT,8IAA8I;QAChJ,WAAW,EAAE,mBAAmB;QAChC,YAAY,EAAE,oBAAoB;QAClC,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;QACpE,IAAI,CAAC;YACH,MAAM,SAAS,GACb,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;gBAC9C,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE;gBACpC,CAAC,CAAC,SAAS,CAAC;YAEhB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;gBAClC,QAAQ,EAAE,QAA0B;gBACpC,OAAO;gBACP,SAAS;gBACT,IAAI;gBACJ,IAAI;aACL,CAAC,CAAC;YAEH,IAAI,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC;YAC1B,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACrB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;oBACtB,IAAI,IAAI,sDAAsD,MAAM,CAAC,UAAU,GAAG,CAAC;gBACrF,CAAC;qBAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;oBAC9B,IAAI,IAAI,sBAAsB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;gBACtD,CAAC;qBAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;oBAC9B,IAAI,IAAI,qBAAqB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;gBACrD,CAAC;YACH,CAAC;YAED,MAAM,UAAU,GAAG;gBACjB,EAAE,EAAE,IAAI;gBACR,IAAI;gBACJ,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;gBACjC,iBAAiB,EAAE,UAAU;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerReadMediaFileTool(server: McpServer): void;
3
+ //# sourceMappingURL=read-media-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-media-file.d.ts","sourceRoot":"","sources":["../../src/tools/read-media-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsDjE"}
@@ -0,0 +1,48 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { readMediaFile } from '../lib/file-operations.js';
3
+ import { ReadMediaFileInputSchema, ReadMediaFileOutputSchema, } from '../schemas/index.js';
4
+ export function registerReadMediaFileTool(server) {
5
+ server.registerTool('read_media_file', {
6
+ title: 'Read Media File',
7
+ description: 'Read a binary/media file (image, audio, video, etc.) and return it as base64-encoded data with MIME type. Useful for images, fonts, and other non-text files.',
8
+ inputSchema: ReadMediaFileInputSchema,
9
+ outputSchema: ReadMediaFileOutputSchema,
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ },
14
+ }, async ({ path, maxSize }) => {
15
+ try {
16
+ const result = await readMediaFile(path, { maxSize });
17
+ // For text output, show summary not the full base64
18
+ const textLines = [
19
+ `File: ${result.path}`,
20
+ `MIME Type: ${result.mimeType}`,
21
+ `Size: ${result.size} bytes`,
22
+ ];
23
+ // Add dimensions if available
24
+ if (result.width !== undefined && result.height !== undefined) {
25
+ textLines.push(`Dimensions: ${result.width}x${result.height}`);
26
+ }
27
+ textLines.push(`Data: [base64 encoded, ${result.data.length} characters]`);
28
+ const textOutput = textLines.join('\n');
29
+ const structured = {
30
+ ok: true,
31
+ path: result.path,
32
+ mimeType: result.mimeType,
33
+ size: result.size,
34
+ data: result.data,
35
+ width: result.width,
36
+ height: result.height,
37
+ };
38
+ return {
39
+ content: [{ type: 'text', text: textOutput }],
40
+ structuredContent: structured,
41
+ };
42
+ }
43
+ catch (error) {
44
+ return createErrorResponse(error, ErrorCode.E_NOT_FILE, path);
45
+ }
46
+ });
47
+ }
48
+ //# sourceMappingURL=read-media-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-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B,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;gBAC7C,iBAAiB,EAAE,UAAU;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerReadMultipleFilesTool(server: McpServer): void;
3
+ //# sourceMappingURL=read-multiple-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-multiple-files.d.ts","sourceRoot":"","sources":["../../src/tools/read-multiple-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAyDrE"}
@@ -0,0 +1,53 @@
1
+ import { createErrorResponse, ErrorCode } from '../lib/errors.js';
2
+ import { readMultipleFiles } from '../lib/file-operations.js';
3
+ import { ReadMultipleFilesInputSchema, ReadMultipleFilesOutputSchema, } from '../schemas/index.js';
4
+ export function registerReadMultipleFilesTool(server) {
5
+ server.registerTool('read_multiple_files', {
6
+ title: 'Read Multiple Files',
7
+ description: 'Read the contents of multiple files in parallel. More efficient than reading files one by one. Individual file errors do not fail the entire operation.',
8
+ inputSchema: ReadMultipleFilesInputSchema,
9
+ outputSchema: ReadMultipleFilesOutputSchema,
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ },
14
+ }, async ({ paths, encoding, maxSize, head, tail }) => {
15
+ try {
16
+ const results = await readMultipleFiles(paths, {
17
+ encoding: encoding,
18
+ maxSize,
19
+ head,
20
+ tail,
21
+ });
22
+ const succeeded = results.filter((r) => r.content !== undefined).length;
23
+ const failed = results.filter((r) => r.error !== undefined).length;
24
+ // Format text output
25
+ const textParts = [];
26
+ for (const result of results) {
27
+ if (result.content !== undefined) {
28
+ textParts.push(`=== ${result.path} ===\n${result.content}`);
29
+ }
30
+ else {
31
+ textParts.push(`=== ${result.path} ===\n[Error: ${result.error ?? 'Unknown error'}]`);
32
+ }
33
+ }
34
+ const structured = {
35
+ ok: true,
36
+ results,
37
+ summary: {
38
+ total: results.length,
39
+ succeeded,
40
+ failed,
41
+ },
42
+ };
43
+ return {
44
+ content: [{ type: 'text', text: textParts.join('\n\n') }],
45
+ structuredContent: structured,
46
+ };
47
+ }
48
+ catch (error) {
49
+ return createErrorResponse(error, ErrorCode.E_UNKNOWN);
50
+ }
51
+ });
52
+ }
53
+ //# sourceMappingURL=read-multiple-files.js.map