@autonomys/auto-mcp-servers 0.1.1-alpha.8 → 0.1.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.
- package/README.md +101 -95
- package/dist/auto-drive/handlers.d.ts +14 -0
- package/dist/auto-drive/handlers.d.ts.map +1 -0
- package/dist/auto-drive/handlers.js +117 -0
- package/dist/auto-drive/index.d.ts.map +1 -1
- package/dist/auto-drive/index.js +21 -109
- package/dist/bin/auto-drive.js +0 -0
- package/dist/bin/main.js +11 -11
- package/package.json +42 -42
- package/src/auto-drive/handlers.ts +110 -0
- package/src/auto-drive/index.ts +57 -123
- package/src/bin/auto-drive.ts +14 -14
- package/src/bin/main.ts +45 -45
- package/src/index.ts +2 -2
- package/tsconfig.json +10 -10
package/README.md
CHANGED
|
@@ -1,95 +1,101 @@
|
|
|
1
|
-
# Autonomys MCP Servers
|
|
2
|
-
|
|
3
|
-
This package provides Model Context Protocol (MCP) servers for Autonomys services. These servers expose Autonomys SDK functionality as MCP tools that can be used with Claude Desktop and other MCP clients, or integrated into agent frameworks.
|
|
4
|
-
|
|
5
|
-
## Available Servers
|
|
6
|
-
|
|
7
|
-
### Auto Drive Server
|
|
8
|
-
|
|
9
|
-
The Auto Drive server exposes functionality from the `@autonomys/auto-drive` package as MCP tools.
|
|
10
|
-
|
|
11
|
-
#### Tools
|
|
12
|
-
|
|
13
|
-
The Auto Drive server provides the following tools:
|
|
14
|
-
|
|
15
|
-
- `
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
# Autonomys MCP Servers
|
|
2
|
+
|
|
3
|
+
This package provides Model Context Protocol (MCP) servers for Autonomys services. These servers expose Autonomys SDK functionality as MCP tools that can be used with Claude Desktop and other MCP clients, or integrated into agent frameworks.
|
|
4
|
+
|
|
5
|
+
## Available Servers
|
|
6
|
+
|
|
7
|
+
### Auto Drive Server
|
|
8
|
+
|
|
9
|
+
The Auto Drive server exposes functionality from the `@autonomys/auto-drive` package as MCP tools.
|
|
10
|
+
|
|
11
|
+
#### Tools
|
|
12
|
+
|
|
13
|
+
The Auto Drive server provides the following tools:
|
|
14
|
+
|
|
15
|
+
- `upload-object`: Upload an object (as JSON data) to the Autonomys network.
|
|
16
|
+
- `download-object`: Download a text-based object (`text/*` or `application/json`) from the Autonomys network using its CID.
|
|
17
|
+
- `search-objects`: Search for objects on the Autonomys network by name or CID fragment. Returns a JSON object containing an array of results, each including the object's name, CID, type, size, and mimeType (for files).
|
|
18
|
+
|
|
19
|
+
More servers and tools will be coming soon!
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### With Claude Desktop
|
|
24
|
+
|
|
25
|
+
1. Install Claude Desktop
|
|
26
|
+
2. Edit your `claude_desktop_config.json` file:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"auto-drive": {
|
|
32
|
+
"command": "npx",
|
|
33
|
+
"args": ["-y", "@autonomys/auto-mcp-servers", "auto-drive"],
|
|
34
|
+
"env": {
|
|
35
|
+
"AUTO_DRIVE_API_KEY": "your-api-key",
|
|
36
|
+
"ENCRYPTION_PASSWORD": "my-password (optional)",
|
|
37
|
+
"NETWORK": "mainnet or taurus (optional, defaults to mainnet)"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
4. Restart Claude Desktop
|
|
45
|
+
|
|
46
|
+
### In Agent Frameworks
|
|
47
|
+
|
|
48
|
+
You can use these MCP servers as tools with agent frameworks such as LangChain.
|
|
49
|
+
|
|
50
|
+
1. Install the Auto Drive server into your project:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install @autonomys/auto-mcp-servers
|
|
54
|
+
# or
|
|
55
|
+
yarn add @autonomys/auto-mcp-servers
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
2. Use the Auto Drive server as a tool in your agent project:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
|
|
62
|
+
import {
|
|
63
|
+
StdioClientTransport,
|
|
64
|
+
StdioServerParameters,
|
|
65
|
+
} from '@modelcontextprotocol/sdk/client/stdio.js'
|
|
66
|
+
import { loadMcpTools } from '@langchain/mcp-adapters'
|
|
67
|
+
import { StructuredToolInterface } from '@langchain/core/tools'
|
|
68
|
+
import { ChatOpenAI } from '@langchain/openai'
|
|
69
|
+
|
|
70
|
+
// Create Auto Drive tools with a single function
|
|
71
|
+
const createAutoDriveTools = async (apiKey: string): Promise<StructuredToolInterface[]> => {
|
|
72
|
+
// Set up transport for Auto Drive server
|
|
73
|
+
const transport = new StdioClientTransport({
|
|
74
|
+
command: process.execPath,
|
|
75
|
+
args: ['node_modules/.bin/auto-drive-server'],
|
|
76
|
+
env: { AUTO_DRIVE_API_KEY: apiKey },
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// Initialize client and connect
|
|
80
|
+
const client = new Client({ name: 'auto-drive', version: '0.0.1' })
|
|
81
|
+
client.connect(transport)
|
|
82
|
+
|
|
83
|
+
// Load MCP tools
|
|
84
|
+
return await loadMcpTools('auto-drive', client)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Create tools with your API key
|
|
88
|
+
const tools = await createAutoDriveTools('your-api-key')
|
|
89
|
+
|
|
90
|
+
// Initialize the ChatOpenAI model
|
|
91
|
+
const model = new ChatOpenAI({ modelName: 'gpt-4o' })
|
|
92
|
+
|
|
93
|
+
const result = await model
|
|
94
|
+
.bindTools(tools)
|
|
95
|
+
.invoke('Upload a profound thought to the Autonomys network')
|
|
96
|
+
console.log(result)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare const createAutoDriveHandlers: (apiKey: string, network: "taurus" | "mainnet", encryptionPassword?: string) => {
|
|
3
|
+
uploadObjectHandler: ({ filename, data, }: {
|
|
4
|
+
filename: string;
|
|
5
|
+
data: Record<string, any>;
|
|
6
|
+
}) => Promise<CallToolResult>;
|
|
7
|
+
downloadObjectHandler: ({ cid }: {
|
|
8
|
+
cid: string;
|
|
9
|
+
}) => Promise<CallToolResult>;
|
|
10
|
+
searchObjectsHandler: ({ query }: {
|
|
11
|
+
query: string;
|
|
12
|
+
}) => Promise<CallToolResult>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/auto-drive/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAEnE,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,EACd,SAAS,QAAQ,GAAG,SAAS,EAC7B,qBAAqB,MAAM;+CAWtB;QACD,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC1B,KAAG,OAAO,CAAC,cAAc,CAAC;qCAIY;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,cAAc,CAAC;sCAsExC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,cAAc,CAAC;CActF,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
11
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
+
var m = o[Symbol.asyncIterator], i;
|
|
13
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
14
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
15
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
|
+
};
|
|
17
|
+
import { createAutoDriveApi } from '@autonomys/auto-drive';
|
|
18
|
+
export const createAutoDriveHandlers = (apiKey, network, encryptionPassword) => {
|
|
19
|
+
const autoDriveApi = createAutoDriveApi({ apiKey, network });
|
|
20
|
+
const uploadOptions = encryptionPassword
|
|
21
|
+
? { password: encryptionPassword }
|
|
22
|
+
: undefined;
|
|
23
|
+
return {
|
|
24
|
+
uploadObjectHandler: (_a) => __awaiter(void 0, [_a], void 0, function* ({ filename, data, }) {
|
|
25
|
+
const cid = yield autoDriveApi.uploadObjectAsJSON({ data }, filename, uploadOptions);
|
|
26
|
+
return { content: [{ type: 'text', text: `Object uploaded successfully with ${cid}` }] };
|
|
27
|
+
}),
|
|
28
|
+
downloadObjectHandler: (_a) => __awaiter(void 0, [_a], void 0, function* ({ cid }) {
|
|
29
|
+
var _b, e_1, _c, _d;
|
|
30
|
+
try {
|
|
31
|
+
// Get object summary to determine type and metadata
|
|
32
|
+
const summaries = yield autoDriveApi.searchByNameOrCID(cid);
|
|
33
|
+
if (!summaries || summaries.length === 0) {
|
|
34
|
+
throw new Error(`Object not found for CID: ${cid}`);
|
|
35
|
+
}
|
|
36
|
+
const summary = summaries[0];
|
|
37
|
+
// Handle folders
|
|
38
|
+
if (summary.type === 'folder') {
|
|
39
|
+
return {
|
|
40
|
+
isError: true,
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: `Error: CID ${cid} points to a folder, which cannot be downloaded directly with this tool.`,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const mimeType = summary.mimeType || 'application/octet-stream';
|
|
50
|
+
const filename = summary.name || `download-${cid}`;
|
|
51
|
+
// Handle only text-based types
|
|
52
|
+
if (mimeType.startsWith('text/') || mimeType === 'application/json') {
|
|
53
|
+
const stream = yield autoDriveApi.downloadFile(cid, encryptionPassword);
|
|
54
|
+
let fileBuffer = Buffer.alloc(0);
|
|
55
|
+
try {
|
|
56
|
+
for (var _e = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _e = true) {
|
|
57
|
+
_d = stream_1_1.value;
|
|
58
|
+
_e = false;
|
|
59
|
+
const chunk = _d;
|
|
60
|
+
fileBuffer = Buffer.concat([fileBuffer, chunk]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
+
finally {
|
|
65
|
+
try {
|
|
66
|
+
if (!_e && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
|
|
67
|
+
}
|
|
68
|
+
finally { if (e_1) throw e_1.error; }
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const text = fileBuffer.toString('utf-8');
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: 'text', text }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
console.error(`Failed to decode text content for ${filename} (${mimeType})`, e);
|
|
78
|
+
return {
|
|
79
|
+
isError: true,
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: `Error: Failed to decode file content for ${filename} as UTF-8 text.`,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// For all other types, return an error
|
|
90
|
+
return {
|
|
91
|
+
isError: true,
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: 'text',
|
|
95
|
+
text: `Error: File type \'${mimeType}\' is not supported for direct download in this client. Only text/* and application/json are supported.`,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error(`Failed to download object with CID ${cid}:`, error);
|
|
102
|
+
const errorMessage = error.message || 'Unknown error occurred during download.';
|
|
103
|
+
return {
|
|
104
|
+
isError: true,
|
|
105
|
+
content: [{ type: 'text', text: `Error downloading object: ${errorMessage}` }],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
searchObjectsHandler: (_a) => __awaiter(void 0, [_a], void 0, function* ({ query }) {
|
|
110
|
+
const summaries = yield autoDriveApi.searchByNameOrCID(query);
|
|
111
|
+
const results = summaries.map((s) => (Object.assign({ name: s.name, cid: s.headCid, type: s.type, size: s.size }, (s.type === 'file' && { mimeType: s.mimeType }))));
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: 'text', text: JSON.stringify({ results }, null, 2) }],
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auto-drive/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auto-drive/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAgBnE,eAAO,MAAM,eAAe,WAA0D,CAAA"}
|
package/dist/auto-drive/index.js
CHANGED
|
@@ -7,122 +7,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var
|
|
11
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
-
var m = o[Symbol.asyncIterator], i;
|
|
13
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
14
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
15
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
|
-
};
|
|
17
|
-
import { createAutoDriveApi } from '@autonomys/auto-drive';
|
|
10
|
+
var _a;
|
|
18
11
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
19
12
|
import { z } from 'zod';
|
|
20
|
-
|
|
13
|
+
import { createAutoDriveHandlers } from './handlers.js';
|
|
14
|
+
const AUTO_DRIVE_API_KEY = (_a = process.env.AUTO_DRIVE_API_KEY) !== null && _a !== void 0 ? _a : (() => {
|
|
15
|
+
throw new Error('AUTO_DRIVE_API_KEY environment variable is not set');
|
|
16
|
+
})();
|
|
21
17
|
const NETWORK = process.env.NETWORK === 'taurus' ? 'taurus' : 'mainnet';
|
|
22
18
|
const ENCRYPTION_PASSWORD = process.env.ENCRYPTION_PASSWORD;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const autoDriveApi = createAutoDriveApi({ network: NETWORK, apiKey: AUTO_DRIVE_API_KEY });
|
|
27
|
-
export const autoDriveServer = new McpServer({ name: 'Auto Drive', version: '0.1.1' });
|
|
28
|
-
autoDriveServer.tool('upload-object', 'Upload an object permanently to Auto Drive, any objects uploaded here will be permanently available onchain. This is useful for storing data that you want to keep forever.', {
|
|
19
|
+
const { uploadObjectHandler, downloadObjectHandler, searchObjectsHandler } = createAutoDriveHandlers(AUTO_DRIVE_API_KEY, NETWORK, ENCRYPTION_PASSWORD);
|
|
20
|
+
export const autoDriveServer = new McpServer({ name: 'Auto Drive', version: '0.1.2' });
|
|
21
|
+
autoDriveServer.tool('upload-object', 'Upload an object permanently to the Autonomys Network using Auto Drive, any objects uploaded here will be permanently available onchain. This is useful for storing data that you want to keep forever.', {
|
|
29
22
|
filename: z.string().describe('The filename to save the object as.'),
|
|
30
|
-
data: z.record(z.string(), z.any()).describe(`
|
|
31
|
-
Data you want to permanently store onchain saved as a JSON object with any key-value pairs.
|
|
32
|
-
The keys are strings that describe the type of data being stored.
|
|
33
|
-
The values are the actual data being stored.
|
|
23
|
+
data: z.record(z.string(), z.any()).describe(`
|
|
24
|
+
Data you want to permanently store onchain saved as a JSON object with any key-value pairs.
|
|
25
|
+
The keys are strings that describe the type of data being stored.
|
|
26
|
+
The values are the actual data being stored.
|
|
34
27
|
`),
|
|
35
|
-
}, (_a,
|
|
36
|
-
|
|
37
|
-
throw new Error('AUTO_DRIVE_API_KEY environment variable is not set');
|
|
38
|
-
}
|
|
39
|
-
const cid = yield autoDriveApi.uploadObjectAsJSON({ data }, filename, uploadOptions);
|
|
40
|
-
return { content: [{ type: 'text', text: `Object uploaded successfully with ${cid}` }] };
|
|
28
|
+
}, (_a, _extra_1) => __awaiter(void 0, [_a, _extra_1], void 0, function* ({ filename, data }, _extra) {
|
|
29
|
+
return yield uploadObjectHandler({ filename, data });
|
|
41
30
|
}));
|
|
42
|
-
autoDriveServer.tool('download-object', 'Download a text-based object (text/*, application/json) from Auto Drive using its Content Identifier (CID).', {
|
|
31
|
+
autoDriveServer.tool('download-object', 'Download a text-based object (text/*, application/json) from the Autonomys Network using Auto Drive using its Content Identifier (CID).', {
|
|
43
32
|
cid: z.string().describe('The Content Identifier (CID) of the object to download.'),
|
|
44
33
|
}, (_a, _extra_1) => __awaiter(void 0, [_a, _extra_1], void 0, function* ({ cid }, _extra) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const summaries = yield autoDriveApi.searchByNameOrCID(cid);
|
|
52
|
-
if (!summaries || summaries.length === 0) {
|
|
53
|
-
throw new Error(`Object not found for CID: ${cid}`);
|
|
54
|
-
}
|
|
55
|
-
const summary = summaries[0];
|
|
56
|
-
// Handle folders
|
|
57
|
-
if (summary.type === 'folder') {
|
|
58
|
-
return {
|
|
59
|
-
isError: true,
|
|
60
|
-
content: [
|
|
61
|
-
{
|
|
62
|
-
type: 'text',
|
|
63
|
-
text: `Error: CID ${cid} points to a folder, which cannot be downloaded directly with this tool.`,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// It's a file, check MIME type
|
|
69
|
-
const mimeType = summary.mimeType || 'application/octet-stream';
|
|
70
|
-
const filename = summary.name || `download-${cid}`;
|
|
71
|
-
// Handle only text-based types
|
|
72
|
-
if (mimeType.startsWith('text/') || mimeType === 'application/json') {
|
|
73
|
-
const stream = yield autoDriveApi.downloadFile(cid, ENCRYPTION_PASSWORD);
|
|
74
|
-
let fileBuffer = Buffer.alloc(0);
|
|
75
|
-
try {
|
|
76
|
-
for (var _e = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _e = true) {
|
|
77
|
-
_d = stream_1_1.value;
|
|
78
|
-
_e = false;
|
|
79
|
-
const chunk = _d;
|
|
80
|
-
fileBuffer = Buffer.concat([fileBuffer, chunk]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
84
|
-
finally {
|
|
85
|
-
try {
|
|
86
|
-
if (!_e && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
|
|
87
|
-
}
|
|
88
|
-
finally { if (e_1) throw e_1.error; }
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
const text = fileBuffer.toString('utf-8');
|
|
92
|
-
return {
|
|
93
|
-
content: [{ type: 'text', text }],
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
console.error(`Failed to decode text content for ${filename} (${mimeType})`, e);
|
|
98
|
-
return {
|
|
99
|
-
isError: true,
|
|
100
|
-
content: [
|
|
101
|
-
{
|
|
102
|
-
type: 'text',
|
|
103
|
-
text: `Error: Failed to decode file content for ${filename} as UTF-8 text.`,
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// For all other types, return an error
|
|
110
|
-
return {
|
|
111
|
-
isError: true,
|
|
112
|
-
content: [
|
|
113
|
-
{
|
|
114
|
-
type: 'text',
|
|
115
|
-
text: `Error: File type \'${mimeType}\' is not supported for direct download in this client. Only text/* and application/json are supported.`,
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error(`Failed to download object with CID ${cid}:`, error);
|
|
122
|
-
const errorMessage = error.message || 'Unknown error occurred during download.';
|
|
123
|
-
return {
|
|
124
|
-
isError: true,
|
|
125
|
-
content: [{ type: 'text', text: `Error downloading object: ${errorMessage}` }],
|
|
126
|
-
};
|
|
127
|
-
}
|
|
34
|
+
return yield downloadObjectHandler({ cid });
|
|
35
|
+
}));
|
|
36
|
+
autoDriveServer.tool('search-objects', 'Search for objects on the Autonomys Network using Auto Drive by name or CID.', {
|
|
37
|
+
query: z.string().describe('The name or CID fragment to search for.'),
|
|
38
|
+
}, (_a, _extra_1) => __awaiter(void 0, [_a, _extra_1], void 0, function* ({ query }, _extra) {
|
|
39
|
+
return yield searchObjectsHandler({ query });
|
|
128
40
|
}));
|
package/dist/bin/auto-drive.js
CHANGED
|
File without changes
|
package/dist/bin/main.js
CHANGED
|
@@ -11,17 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
12
12
|
import { autoDriveServer } from '../auto-drive/index.js';
|
|
13
13
|
const showHelp = () => {
|
|
14
|
-
console.log(`
|
|
15
|
-
Usage: auto-mcp-servers [server-name]
|
|
16
|
-
|
|
17
|
-
Available servers:
|
|
18
|
-
auto-drive Start the Auto Drive MCP server
|
|
19
|
-
|
|
20
|
-
Environment variables:
|
|
21
|
-
For Auto Drive server:
|
|
22
|
-
AUTO_DRIVE_API_KEY API key for Auto Drive (required)
|
|
23
|
-
NETWORK 'mainnet' (default) or 'taurus'
|
|
24
|
-
ENCRYPTION_PASSWORD Password for encryption (optional)
|
|
14
|
+
console.log(`
|
|
15
|
+
Usage: auto-mcp-servers [server-name]
|
|
16
|
+
|
|
17
|
+
Available servers:
|
|
18
|
+
auto-drive Start the Auto Drive MCP server
|
|
19
|
+
|
|
20
|
+
Environment variables:
|
|
21
|
+
For Auto Drive server:
|
|
22
|
+
AUTO_DRIVE_API_KEY API key for Auto Drive (required)
|
|
23
|
+
NETWORK 'mainnet' (default) or 'taurus'
|
|
24
|
+
ENCRYPTION_PASSWORD Password for encryption (optional)
|
|
25
25
|
`);
|
|
26
26
|
process.exit(1);
|
|
27
27
|
};
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@autonomys/auto-mcp-servers",
|
|
3
|
-
"packageManager": "yarn@4.7.0",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"description": "Autonomys Network MCP servers",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/autonomys/auto-sdk"
|
|
9
|
-
},
|
|
10
|
-
"author": {
|
|
11
|
-
"name": "Autonomys",
|
|
12
|
-
"url": "https://www.autonomys.xyz"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/autonomys/auto-sdk/issues"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"type": "module",
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"bin": {
|
|
21
|
-
"auto-drive-server": "./dist/bin/auto-drive.js",
|
|
22
|
-
"auto-mcp-servers": "./dist/bin/main.js"
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
26
|
-
"prepublishOnly": "npm run build
|
|
27
|
-
},
|
|
28
|
-
"keywords": [
|
|
29
|
-
"mcp",
|
|
30
|
-
"server"
|
|
31
|
-
],
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@autonomys/auto-drive": "^1.4.18",
|
|
34
|
-
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
35
|
-
"zod": "^3.24.2"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/node": "22.14.0",
|
|
39
|
-
"ts-node": "^10.9.1",
|
|
40
|
-
"typescript": "^5.0.2"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@autonomys/auto-mcp-servers",
|
|
3
|
+
"packageManager": "yarn@4.7.0",
|
|
4
|
+
"version": "0.1.2",
|
|
5
|
+
"description": "Autonomys Network MCP servers",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/autonomys/auto-sdk"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Autonomys",
|
|
12
|
+
"url": "https://www.autonomys.xyz"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/autonomys/auto-sdk/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"bin": {
|
|
21
|
+
"auto-drive-server": "./dist/bin/auto-drive.js",
|
|
22
|
+
"auto-mcp-servers": "./dist/bin/main.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"mcp",
|
|
30
|
+
"server"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@autonomys/auto-drive": "^1.4.18",
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
35
|
+
"zod": "^3.24.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "22.14.0",
|
|
39
|
+
"ts-node": "^10.9.1",
|
|
40
|
+
"typescript": "^5.0.2"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createAutoDriveApi, UploadFileOptions } from '@autonomys/auto-drive'
|
|
2
|
+
|
|
3
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js'
|
|
4
|
+
|
|
5
|
+
export const createAutoDriveHandlers = (
|
|
6
|
+
apiKey: string,
|
|
7
|
+
network: 'taurus' | 'mainnet',
|
|
8
|
+
encryptionPassword?: string,
|
|
9
|
+
) => {
|
|
10
|
+
const autoDriveApi = createAutoDriveApi({ apiKey, network })
|
|
11
|
+
const uploadOptions: UploadFileOptions | undefined = encryptionPassword
|
|
12
|
+
? { password: encryptionPassword }
|
|
13
|
+
: undefined
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
uploadObjectHandler: async ({
|
|
17
|
+
filename,
|
|
18
|
+
data,
|
|
19
|
+
}: {
|
|
20
|
+
filename: string
|
|
21
|
+
data: Record<string, any>
|
|
22
|
+
}): Promise<CallToolResult> => {
|
|
23
|
+
const cid = await autoDriveApi.uploadObjectAsJSON({ data }, filename, uploadOptions)
|
|
24
|
+
return { content: [{ type: 'text', text: `Object uploaded successfully with ${cid}` }] }
|
|
25
|
+
},
|
|
26
|
+
downloadObjectHandler: async ({ cid }: { cid: string }): Promise<CallToolResult> => {
|
|
27
|
+
try {
|
|
28
|
+
// Get object summary to determine type and metadata
|
|
29
|
+
const summaries = await autoDriveApi.searchByNameOrCID(cid)
|
|
30
|
+
if (!summaries || summaries.length === 0) {
|
|
31
|
+
throw new Error(`Object not found for CID: ${cid}`)
|
|
32
|
+
}
|
|
33
|
+
const summary = summaries[0]
|
|
34
|
+
|
|
35
|
+
// Handle folders
|
|
36
|
+
if (summary.type === 'folder') {
|
|
37
|
+
return {
|
|
38
|
+
isError: true,
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: `Error: CID ${cid} points to a folder, which cannot be downloaded directly with this tool.`,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const mimeType = summary.mimeType || 'application/octet-stream'
|
|
49
|
+
const filename = summary.name || `download-${cid}`
|
|
50
|
+
|
|
51
|
+
// Handle only text-based types
|
|
52
|
+
if (mimeType.startsWith('text/') || mimeType === 'application/json') {
|
|
53
|
+
const stream = await autoDriveApi.downloadFile(cid, encryptionPassword)
|
|
54
|
+
let fileBuffer = Buffer.alloc(0)
|
|
55
|
+
for await (const chunk of stream) {
|
|
56
|
+
fileBuffer = Buffer.concat([fileBuffer, chunk])
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const text = fileBuffer.toString('utf-8')
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: 'text', text }],
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(`Failed to decode text content for ${filename} (${mimeType})`, e)
|
|
65
|
+
return {
|
|
66
|
+
isError: true,
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
text: `Error: Failed to decode file content for ${filename} as UTF-8 text.`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// For all other types, return an error
|
|
78
|
+
return {
|
|
79
|
+
isError: true,
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: `Error: File type \'${mimeType}\' is not supported for direct download in this client. Only text/* and application/json are supported.`,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
}
|
|
87
|
+
} catch (error: any) {
|
|
88
|
+
console.error(`Failed to download object with CID ${cid}:`, error)
|
|
89
|
+
const errorMessage = error.message || 'Unknown error occurred during download.'
|
|
90
|
+
return {
|
|
91
|
+
isError: true,
|
|
92
|
+
content: [{ type: 'text', text: `Error downloading object: ${errorMessage}` }],
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
searchObjectsHandler: async ({ query }: { query: string }): Promise<CallToolResult> => {
|
|
97
|
+
const summaries = await autoDriveApi.searchByNameOrCID(query)
|
|
98
|
+
const results = summaries.map((s) => ({
|
|
99
|
+
name: s.name,
|
|
100
|
+
cid: s.headCid,
|
|
101
|
+
type: s.type,
|
|
102
|
+
size: s.size,
|
|
103
|
+
...(s.type === 'file' && { mimeType: s.mimeType }),
|
|
104
|
+
}))
|
|
105
|
+
return {
|
|
106
|
+
content: [{ type: 'text', text: JSON.stringify({ results }, null, 2) }],
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
}
|
package/src/auto-drive/index.ts
CHANGED
|
@@ -1,123 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const AUTO_DRIVE_API_KEY =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
autoDriveServer.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const summary = summaries[0]
|
|
60
|
-
|
|
61
|
-
// Handle folders
|
|
62
|
-
if (summary.type === 'folder') {
|
|
63
|
-
return {
|
|
64
|
-
isError: true,
|
|
65
|
-
content: [
|
|
66
|
-
{
|
|
67
|
-
type: 'text',
|
|
68
|
-
text: `Error: CID ${cid} points to a folder, which cannot be downloaded directly with this tool.`,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// It's a file, check MIME type
|
|
75
|
-
const mimeType = summary.mimeType || 'application/octet-stream'
|
|
76
|
-
const filename = summary.name || `download-${cid}`
|
|
77
|
-
|
|
78
|
-
// Handle only text-based types
|
|
79
|
-
if (mimeType.startsWith('text/') || mimeType === 'application/json') {
|
|
80
|
-
const stream = await autoDriveApi.downloadFile(cid, ENCRYPTION_PASSWORD)
|
|
81
|
-
let fileBuffer = Buffer.alloc(0)
|
|
82
|
-
for await (const chunk of stream) {
|
|
83
|
-
fileBuffer = Buffer.concat([fileBuffer, chunk])
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const text = fileBuffer.toString('utf-8')
|
|
87
|
-
return {
|
|
88
|
-
content: [{ type: 'text', text }],
|
|
89
|
-
}
|
|
90
|
-
} catch (e) {
|
|
91
|
-
console.error(`Failed to decode text content for ${filename} (${mimeType})`, e)
|
|
92
|
-
return {
|
|
93
|
-
isError: true,
|
|
94
|
-
content: [
|
|
95
|
-
{
|
|
96
|
-
type: 'text',
|
|
97
|
-
text: `Error: Failed to decode file content for ${filename} as UTF-8 text.`,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// For all other types, return an error
|
|
105
|
-
return {
|
|
106
|
-
isError: true,
|
|
107
|
-
content: [
|
|
108
|
-
{
|
|
109
|
-
type: 'text',
|
|
110
|
-
text: `Error: File type \'${mimeType}\' is not supported for direct download in this client. Only text/* and application/json are supported.`,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
}
|
|
114
|
-
} catch (error: any) {
|
|
115
|
-
console.error(`Failed to download object with CID ${cid}:`, error)
|
|
116
|
-
const errorMessage = error.message || 'Unknown error occurred during download.'
|
|
117
|
-
return {
|
|
118
|
-
isError: true,
|
|
119
|
-
content: [{ type: 'text', text: `Error downloading object: ${errorMessage}` }],
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
)
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { createAutoDriveHandlers } from './handlers.js'
|
|
5
|
+
|
|
6
|
+
const AUTO_DRIVE_API_KEY =
|
|
7
|
+
process.env.AUTO_DRIVE_API_KEY ??
|
|
8
|
+
(() => {
|
|
9
|
+
throw new Error('AUTO_DRIVE_API_KEY environment variable is not set')
|
|
10
|
+
})()
|
|
11
|
+
const NETWORK = process.env.NETWORK === 'taurus' ? 'taurus' : 'mainnet'
|
|
12
|
+
const ENCRYPTION_PASSWORD = process.env.ENCRYPTION_PASSWORD
|
|
13
|
+
|
|
14
|
+
const { uploadObjectHandler, downloadObjectHandler, searchObjectsHandler } =
|
|
15
|
+
createAutoDriveHandlers(AUTO_DRIVE_API_KEY, NETWORK, ENCRYPTION_PASSWORD)
|
|
16
|
+
|
|
17
|
+
export const autoDriveServer = new McpServer({ name: 'Auto Drive', version: '0.1.2' })
|
|
18
|
+
|
|
19
|
+
autoDriveServer.tool(
|
|
20
|
+
'upload-object',
|
|
21
|
+
'Upload an object permanently to the Autonomys Network using Auto Drive, any objects uploaded here will be permanently available onchain. This is useful for storing data that you want to keep forever.',
|
|
22
|
+
{
|
|
23
|
+
filename: z.string().describe('The filename to save the object as.'),
|
|
24
|
+
data: z.record(z.string(), z.any()).describe(
|
|
25
|
+
`
|
|
26
|
+
Data you want to permanently store onchain saved as a JSON object with any key-value pairs.
|
|
27
|
+
The keys are strings that describe the type of data being stored.
|
|
28
|
+
The values are the actual data being stored.
|
|
29
|
+
`,
|
|
30
|
+
),
|
|
31
|
+
} as any,
|
|
32
|
+
async ({ filename, data }, _extra): Promise<CallToolResult> => {
|
|
33
|
+
return await uploadObjectHandler({ filename, data })
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
autoDriveServer.tool(
|
|
38
|
+
'download-object',
|
|
39
|
+
'Download a text-based object (text/*, application/json) from the Autonomys Network using Auto Drive using its Content Identifier (CID).',
|
|
40
|
+
{
|
|
41
|
+
cid: z.string().describe('The Content Identifier (CID) of the object to download.'),
|
|
42
|
+
} as any,
|
|
43
|
+
async ({ cid }, _extra): Promise<CallToolResult> => {
|
|
44
|
+
return await downloadObjectHandler({ cid })
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
autoDriveServer.tool(
|
|
49
|
+
'search-objects',
|
|
50
|
+
'Search for objects on the Autonomys Network using Auto Drive by name or CID.',
|
|
51
|
+
{
|
|
52
|
+
query: z.string().describe('The name or CID fragment to search for.'),
|
|
53
|
+
} as any,
|
|
54
|
+
async ({ query }, _extra): Promise<CallToolResult> => {
|
|
55
|
+
return await searchObjectsHandler({ query })
|
|
56
|
+
},
|
|
57
|
+
)
|
package/src/bin/auto-drive.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
4
|
-
import { autoDriveServer } from '../index.js'
|
|
5
|
-
|
|
6
|
-
const main = async () => {
|
|
7
|
-
const transport = new StdioServerTransport()
|
|
8
|
-
await autoDriveServer.connect(transport)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
main().catch((error) => {
|
|
12
|
-
console.error('Failed to start Auto Drive server:', error)
|
|
13
|
-
process.exit(1)
|
|
14
|
-
})
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
4
|
+
import { autoDriveServer } from '../index.js'
|
|
5
|
+
|
|
6
|
+
const main = async () => {
|
|
7
|
+
const transport = new StdioServerTransport()
|
|
8
|
+
await autoDriveServer.connect(transport)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
main().catch((error) => {
|
|
12
|
+
console.error('Failed to start Auto Drive server:', error)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
})
|
package/src/bin/main.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
4
|
-
import { autoDriveServer } from '../auto-drive/index.js'
|
|
5
|
-
|
|
6
|
-
const showHelp = () => {
|
|
7
|
-
console.log(`
|
|
8
|
-
Usage: auto-mcp-servers [server-name]
|
|
9
|
-
|
|
10
|
-
Available servers:
|
|
11
|
-
auto-drive Start the Auto Drive MCP server
|
|
12
|
-
|
|
13
|
-
Environment variables:
|
|
14
|
-
For Auto Drive server:
|
|
15
|
-
AUTO_DRIVE_API_KEY API key for Auto Drive (required)
|
|
16
|
-
NETWORK 'mainnet' (default) or 'taurus'
|
|
17
|
-
ENCRYPTION_PASSWORD Password for encryption (optional)
|
|
18
|
-
`)
|
|
19
|
-
process.exit(1)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const main = async () => {
|
|
23
|
-
const serverName = process.argv[2] || 'auto-drive'
|
|
24
|
-
const transport = new StdioServerTransport()
|
|
25
|
-
|
|
26
|
-
switch (serverName) {
|
|
27
|
-
case 'auto-drive':
|
|
28
|
-
await autoDriveServer.connect(transport)
|
|
29
|
-
break
|
|
30
|
-
case 'help':
|
|
31
|
-
case '--help':
|
|
32
|
-
case '-h':
|
|
33
|
-
showHelp()
|
|
34
|
-
break
|
|
35
|
-
default:
|
|
36
|
-
console.error(`Unknown server: ${serverName}`)
|
|
37
|
-
showHelp()
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
main().catch((error) => {
|
|
43
|
-
console.error(`Failed to start MCP server:`, error)
|
|
44
|
-
process.exit(1)
|
|
45
|
-
})
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
4
|
+
import { autoDriveServer } from '../auto-drive/index.js'
|
|
5
|
+
|
|
6
|
+
const showHelp = () => {
|
|
7
|
+
console.log(`
|
|
8
|
+
Usage: auto-mcp-servers [server-name]
|
|
9
|
+
|
|
10
|
+
Available servers:
|
|
11
|
+
auto-drive Start the Auto Drive MCP server
|
|
12
|
+
|
|
13
|
+
Environment variables:
|
|
14
|
+
For Auto Drive server:
|
|
15
|
+
AUTO_DRIVE_API_KEY API key for Auto Drive (required)
|
|
16
|
+
NETWORK 'mainnet' (default) or 'taurus'
|
|
17
|
+
ENCRYPTION_PASSWORD Password for encryption (optional)
|
|
18
|
+
`)
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const main = async () => {
|
|
23
|
+
const serverName = process.argv[2] || 'auto-drive'
|
|
24
|
+
const transport = new StdioServerTransport()
|
|
25
|
+
|
|
26
|
+
switch (serverName) {
|
|
27
|
+
case 'auto-drive':
|
|
28
|
+
await autoDriveServer.connect(transport)
|
|
29
|
+
break
|
|
30
|
+
case 'help':
|
|
31
|
+
case '--help':
|
|
32
|
+
case '-h':
|
|
33
|
+
showHelp()
|
|
34
|
+
break
|
|
35
|
+
default:
|
|
36
|
+
console.error(`Unknown server: ${serverName}`)
|
|
37
|
+
showHelp()
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main().catch((error) => {
|
|
43
|
+
console.error(`Failed to start MCP server:`, error)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Export servers
|
|
2
|
-
export { autoDriveServer } from './auto-drive/index.js'
|
|
1
|
+
// Export servers
|
|
2
|
+
export { autoDriveServer } from './auto-drive/index.js'
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Bundler",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src"
|
|
8
|
-
},
|
|
9
|
-
"include": ["src/**/*"]
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src"
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"]
|
|
10
|
+
}
|