@echosaw/mcp-server 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.
- package/README.md +117 -0
- package/bin/echosaw-mcp.ts +4 -0
- package/dist/bin/echosaw-mcp.d.ts +3 -0
- package/dist/bin/echosaw-mcp.d.ts.map +1 -0
- package/dist/bin/echosaw-mcp.js +6 -0
- package/dist/bin/echosaw-mcp.js.map +1 -0
- package/dist/src/echosaw-client.d.ts +25 -0
- package/dist/src/echosaw-client.d.ts.map +1 -0
- package/dist/src/echosaw-client.js +161 -0
- package/dist/src/echosaw-client.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +71 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/tools/check-status.d.ts +19 -0
- package/dist/src/tools/check-status.d.ts.map +1 -0
- package/dist/src/tools/check-status.js +48 -0
- package/dist/src/tools/check-status.js.map +1 -0
- package/dist/src/tools/download-file.d.ts +19 -0
- package/dist/src/tools/download-file.d.ts.map +1 -0
- package/dist/src/tools/download-file.js +28 -0
- package/dist/src/tools/download-file.js.map +1 -0
- package/dist/src/tools/get-results.d.ts +19 -0
- package/dist/src/tools/get-results.d.ts.map +1 -0
- package/dist/src/tools/get-results.js +28 -0
- package/dist/src/tools/get-results.js.map +1 -0
- package/dist/src/tools/submit-file.d.ts +25 -0
- package/dist/src/tools/submit-file.d.ts.map +1 -0
- package/dist/src/tools/submit-file.js +99 -0
- package/dist/src/tools/submit-file.js.map +1 -0
- package/dist/src/tools/submit-url.d.ts +25 -0
- package/dist/src/tools/submit-url.d.ts.map +1 -0
- package/dist/src/tools/submit-url.js +41 -0
- package/dist/src/tools/submit-url.js.map +1 -0
- package/dist/src/types.d.ts +41 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +27 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +23 -0
- package/src/echosaw-client.ts +169 -0
- package/src/index.ts +80 -0
- package/src/tools/check-status.ts +46 -0
- package/src/tools/download-file.ts +25 -0
- package/src/tools/get-results.ts +25 -0
- package/src/tools/submit-file.ts +68 -0
- package/src/tools/submit-url.ts +42 -0
- package/src/types.ts +60 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { submitAnalysis, uploadFile } from '../echosaw-client.js';
|
|
4
|
+
import { buildResponse, buildErrorResponse, McpToolResponse, AnalyzeMediaData } from '../types.js';
|
|
5
|
+
|
|
6
|
+
const EXTENSION_CONTENT_TYPE_MAP: Record<string, string> = {
|
|
7
|
+
'.mp4': 'video/mp4',
|
|
8
|
+
'.mov': 'video/quicktime',
|
|
9
|
+
'.avi': 'video/x-msvideo',
|
|
10
|
+
'.webm': 'video/webm',
|
|
11
|
+
'.mkv': 'video/x-matroska',
|
|
12
|
+
'.mp3': 'audio/mpeg',
|
|
13
|
+
'.wav': 'audio/wav',
|
|
14
|
+
'.flac': 'audio/flac',
|
|
15
|
+
'.aac': 'audio/aac',
|
|
16
|
+
'.ogg': 'audio/ogg',
|
|
17
|
+
'.m4a': 'audio/mp4',
|
|
18
|
+
'.jpg': 'image/jpeg',
|
|
19
|
+
'.jpeg': 'image/jpeg',
|
|
20
|
+
'.png': 'image/png',
|
|
21
|
+
'.gif': 'image/gif',
|
|
22
|
+
'.webp': 'image/webp',
|
|
23
|
+
'.bmp': 'image/bmp',
|
|
24
|
+
'.tiff': 'image/tiff',
|
|
25
|
+
'.tif': 'image/tiff',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const submitFileToolDefinition = {
|
|
29
|
+
name: 'echosaw_analyze_media',
|
|
30
|
+
description: 'Upload an audio, video, or image file to Echosaw for asynchronous media analysis. Returns a job ID used to track processing and retrieve results.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object' as const,
|
|
33
|
+
properties: {
|
|
34
|
+
filePath: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Absolute path to the media file on disk',
|
|
37
|
+
},
|
|
38
|
+
mediaType: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'One of: video, audio, image',
|
|
41
|
+
enum: ['video', 'audio', 'image'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['filePath', 'mediaType'],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export async function handleSubmitFile(args: { filePath: string; mediaType: string }): Promise<McpToolResponse<AnalyzeMediaData | null>> {
|
|
49
|
+
const { filePath, mediaType } = args;
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(filePath)) {
|
|
52
|
+
return buildErrorResponse('echosaw_analyze_media', `File not found at path: ${filePath}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const originalFilename = path.basename(filePath);
|
|
56
|
+
const stats = fs.statSync(filePath);
|
|
57
|
+
const fileSize = stats.size;
|
|
58
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
59
|
+
const contentType = EXTENSION_CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
60
|
+
|
|
61
|
+
const result = await submitAnalysis(mediaType, originalFilename, fileSize, contentType);
|
|
62
|
+
await uploadFile(result.uploadUrl, filePath, contentType);
|
|
63
|
+
|
|
64
|
+
return buildResponse('echosaw_analyze_media', { mediaId: result.mediaId, jobId: result.jobId }, {
|
|
65
|
+
message: 'File submitted for analysis.',
|
|
66
|
+
nextAction: { tool: 'echosaw_check_job_status', description: 'Check processing status' },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { submitUrl } from '../echosaw-client.js';
|
|
2
|
+
import { buildResponse, buildErrorResponse, McpToolResponse, AnalyzeMediaData } from '../types.js';
|
|
3
|
+
|
|
4
|
+
export const submitUrlToolDefinition = {
|
|
5
|
+
name: 'echosaw_analyze_media_url',
|
|
6
|
+
description: 'Submit a publicly accessible or authorized media URL to Echosaw for asynchronous analysis without uploading the file directly. Returns a job ID used to track processing and retrieve results.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object' as const,
|
|
9
|
+
properties: {
|
|
10
|
+
url: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'HTTP(S) URL of the media file',
|
|
13
|
+
},
|
|
14
|
+
mediaType: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'One of: video, audio, image',
|
|
17
|
+
enum: ['video', 'audio', 'image'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['url', 'mediaType'],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export async function handleSubmitUrl(args: { url: string; mediaType: string }): Promise<McpToolResponse<AnalyzeMediaData | null>> {
|
|
25
|
+
const { url, mediaType } = args;
|
|
26
|
+
|
|
27
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
28
|
+
return buildErrorResponse('echosaw_analyze_media_url', 'URL must start with http:// or https://');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Derive filename from URL path
|
|
32
|
+
const parsed = new URL(url);
|
|
33
|
+
const pathSegments = parsed.pathname.split('/').filter(Boolean);
|
|
34
|
+
const originalFilename = pathSegments.length > 0 ? pathSegments[pathSegments.length - 1] : undefined;
|
|
35
|
+
|
|
36
|
+
const result = await submitUrl(url, mediaType, originalFilename);
|
|
37
|
+
|
|
38
|
+
return buildResponse('echosaw_analyze_media_url', { mediaId: result.mediaId, jobId: result.jobId }, {
|
|
39
|
+
message: 'URL submitted. Echosaw is downloading and processing the file.',
|
|
40
|
+
nextAction: { tool: 'echosaw_check_job_status', description: 'Check processing status' },
|
|
41
|
+
});
|
|
42
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const RESPONSE_VERSION = '1.0';
|
|
2
|
+
|
|
3
|
+
export interface McpToolResponse<T = unknown> {
|
|
4
|
+
success: boolean;
|
|
5
|
+
tool: string;
|
|
6
|
+
responseVersion: string;
|
|
7
|
+
data: T;
|
|
8
|
+
message?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
nextAction?: { tool: string; description: string };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AnalyzeMediaData {
|
|
14
|
+
mediaId: string;
|
|
15
|
+
jobId: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface JobStatusData {
|
|
19
|
+
mediaId: string;
|
|
20
|
+
status: string;
|
|
21
|
+
createdAt: string | null;
|
|
22
|
+
updatedAt: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AnalysisResultsData {
|
|
26
|
+
mediaId: string;
|
|
27
|
+
report: unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DownloadReportData {
|
|
31
|
+
mediaId: string;
|
|
32
|
+
downloadUrl: string;
|
|
33
|
+
expiresIn: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Lightweight validation helper — asserts required fields are present
|
|
37
|
+
export function buildResponse<T>(
|
|
38
|
+
tool: string,
|
|
39
|
+
data: T,
|
|
40
|
+
opts?: { message?: string; nextAction?: { tool: string; description: string } }
|
|
41
|
+
): McpToolResponse<T> {
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
tool,
|
|
45
|
+
responseVersion: RESPONSE_VERSION,
|
|
46
|
+
data,
|
|
47
|
+
...(opts?.message ? { message: opts.message } : {}),
|
|
48
|
+
...(opts?.nextAction ? { nextAction: opts.nextAction } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function buildErrorResponse(tool: string, error: string): McpToolResponse<null> {
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
tool,
|
|
56
|
+
responseVersion: RESPONSE_VERSION,
|
|
57
|
+
data: null,
|
|
58
|
+
error,
|
|
59
|
+
};
|
|
60
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": ".",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*", "bin/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|