opc-agent 2.0.2 → 3.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 +603 -545
- package/dist/channels/voice.d.ts +59 -0
- package/dist/channels/voice.js +351 -1
- package/dist/cli.js +284 -5
- package/dist/core/agent.d.ts +9 -0
- package/dist/core/agent.js +49 -0
- package/dist/core/collaboration.d.ts +89 -0
- package/dist/core/collaboration.js +201 -0
- package/dist/deploy/index.d.ts +40 -0
- package/dist/deploy/index.js +261 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +47 -3
- package/dist/mcp/servers/calculator-mcp.d.ts +3 -0
- package/dist/mcp/servers/calculator-mcp.js +65 -0
- package/dist/mcp/servers/crypto-mcp.d.ts +3 -0
- package/dist/mcp/servers/crypto-mcp.js +108 -0
- package/dist/mcp/servers/database-mcp.d.ts +3 -0
- package/dist/mcp/servers/database-mcp.js +73 -0
- package/dist/mcp/servers/datetime-mcp.d.ts +3 -0
- package/dist/mcp/servers/datetime-mcp.js +71 -0
- package/dist/mcp/servers/filesystem.d.ts +3 -0
- package/dist/mcp/servers/filesystem.js +101 -0
- package/dist/mcp/servers/github-mcp.d.ts +3 -0
- package/dist/mcp/servers/github-mcp.js +60 -0
- package/dist/mcp/servers/index.d.ts +21 -0
- package/dist/mcp/servers/index.js +50 -0
- package/dist/mcp/servers/json-mcp.d.ts +3 -0
- package/dist/mcp/servers/json-mcp.js +126 -0
- package/dist/mcp/servers/memory-mcp.d.ts +3 -0
- package/dist/mcp/servers/memory-mcp.js +60 -0
- package/dist/mcp/servers/regex-mcp.d.ts +3 -0
- package/dist/mcp/servers/regex-mcp.js +56 -0
- package/dist/mcp/servers/web-mcp.d.ts +3 -0
- package/dist/mcp/servers/web-mcp.js +51 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.js +4 -1
- package/dist/memory/seed-loader.d.ts +51 -0
- package/dist/memory/seed-loader.js +200 -0
- package/dist/schema/oad.d.ts +292 -12
- package/dist/schema/oad.js +12 -1
- package/dist/security/guardrails.d.ts +50 -0
- package/dist/security/guardrails.js +197 -0
- package/dist/studio/server.d.ts +31 -1
- package/dist/studio/server.js +154 -3
- package/dist/studio-ui/index.html +1278 -662
- package/dist/tools/integrations/calendar.d.ts +3 -0
- package/dist/tools/integrations/calendar.js +73 -0
- package/dist/tools/integrations/code-exec.d.ts +3 -0
- package/dist/tools/integrations/code-exec.js +42 -0
- package/dist/tools/integrations/csv-analyzer.d.ts +3 -0
- package/dist/tools/integrations/csv-analyzer.js +142 -0
- package/dist/tools/integrations/database.d.ts +3 -0
- package/dist/tools/integrations/database.js +44 -0
- package/dist/tools/integrations/email-send.d.ts +3 -0
- package/dist/tools/integrations/email-send.js +104 -0
- package/dist/tools/integrations/git-tool.d.ts +3 -0
- package/dist/tools/integrations/git-tool.js +49 -0
- package/dist/tools/integrations/github-tool.d.ts +3 -0
- package/dist/tools/integrations/github-tool.js +77 -0
- package/dist/tools/integrations/image-gen.d.ts +3 -0
- package/dist/tools/integrations/image-gen.js +58 -0
- package/dist/tools/integrations/index.d.ts +30 -0
- package/dist/tools/integrations/index.js +107 -0
- package/dist/tools/integrations/jira.d.ts +3 -0
- package/dist/tools/integrations/jira.js +85 -0
- package/dist/tools/integrations/notion.d.ts +3 -0
- package/dist/tools/integrations/notion.js +71 -0
- package/dist/tools/integrations/npm-tool.d.ts +3 -0
- package/dist/tools/integrations/npm-tool.js +49 -0
- package/dist/tools/integrations/pdf-reader.d.ts +3 -0
- package/dist/tools/integrations/pdf-reader.js +91 -0
- package/dist/tools/integrations/slack.d.ts +3 -0
- package/dist/tools/integrations/slack.js +67 -0
- package/dist/tools/integrations/summarizer.d.ts +3 -0
- package/dist/tools/integrations/summarizer.js +49 -0
- package/dist/tools/integrations/translator.d.ts +3 -0
- package/dist/tools/integrations/translator.js +48 -0
- package/dist/tools/integrations/trello.d.ts +3 -0
- package/dist/tools/integrations/trello.js +60 -0
- package/dist/tools/integrations/vector-search.d.ts +3 -0
- package/dist/tools/integrations/vector-search.js +44 -0
- package/dist/tools/integrations/web-scraper.d.ts +3 -0
- package/dist/tools/integrations/web-scraper.js +48 -0
- package/dist/tools/integrations/web-search.d.ts +3 -0
- package/dist/tools/integrations/web-search.js +60 -0
- package/dist/tools/integrations/webhook.d.ts +3 -0
- package/dist/tools/integrations/webhook.js +39 -0
- package/dist/ui/components.d.ts +10 -0
- package/dist/ui/components.js +123 -0
- package/package.json +1 -1
- package/src/channels/voice.ts +365 -0
- package/src/cli.ts +294 -6
- package/src/core/agent.ts +56 -0
- package/src/core/collaboration.ts +275 -0
- package/src/deploy/index.ts +255 -0
- package/src/index.ts +21 -1
- package/src/mcp/servers/calculator-mcp.ts +65 -0
- package/src/mcp/servers/crypto-mcp.ts +73 -0
- package/src/mcp/servers/database-mcp.ts +72 -0
- package/src/mcp/servers/datetime-mcp.ts +69 -0
- package/src/mcp/servers/filesystem.ts +66 -0
- package/src/mcp/servers/github-mcp.ts +58 -0
- package/src/mcp/servers/index.ts +63 -0
- package/src/mcp/servers/json-mcp.ts +102 -0
- package/src/mcp/servers/memory-mcp.ts +56 -0
- package/src/mcp/servers/regex-mcp.ts +53 -0
- package/src/mcp/servers/web-mcp.ts +49 -0
- package/src/memory/index.ts +3 -0
- package/src/memory/seed-loader.ts +212 -0
- package/src/schema/oad.ts +13 -0
- package/src/security/guardrails.ts +248 -0
- package/src/studio/server.ts +166 -4
- package/src/studio-ui/index.html +1278 -662
- package/src/tools/integrations/calendar.ts +73 -0
- package/src/tools/integrations/code-exec.ts +39 -0
- package/src/tools/integrations/csv-analyzer.ts +92 -0
- package/src/tools/integrations/database.ts +44 -0
- package/src/tools/integrations/email-send.ts +76 -0
- package/src/tools/integrations/git-tool.ts +42 -0
- package/src/tools/integrations/github-tool.ts +76 -0
- package/src/tools/integrations/image-gen.ts +56 -0
- package/src/tools/integrations/index.ts +92 -0
- package/src/tools/integrations/jira.ts +83 -0
- package/src/tools/integrations/notion.ts +71 -0
- package/src/tools/integrations/npm-tool.ts +48 -0
- package/src/tools/integrations/pdf-reader.ts +58 -0
- package/src/tools/integrations/slack.ts +65 -0
- package/src/tools/integrations/summarizer.ts +49 -0
- package/src/tools/integrations/translator.ts +48 -0
- package/src/tools/integrations/trello.ts +60 -0
- package/src/tools/integrations/vector-search.ts +42 -0
- package/src/tools/integrations/web-scraper.ts +47 -0
- package/src/tools/integrations/web-search.ts +58 -0
- package/src/tools/integrations/webhook.ts +38 -0
- package/src/ui/components.ts +127 -0
- package/tests/brain-seed-extended.test.ts +490 -0
- package/tests/brain-seed.test.ts +239 -0
- package/tests/collaboration.test.ts +319 -0
- package/tests/deploy-and-dag.test.ts +196 -0
- package/tests/guardrails.test.ts +177 -0
- package/tests/integrations.test.ts +249 -0
- package/tests/mcp-servers.test.ts +260 -0
- package/tests/voice-enhanced.test.ts +169 -0
- package/dist/dtv/data.d.ts +0 -18
- package/dist/dtv/data.js +0 -25
- package/dist/dtv/trust.d.ts +0 -19
- package/dist/dtv/trust.js +0 -40
- package/dist/dtv/value.d.ts +0 -23
- package/dist/dtv/value.js +0 -38
- package/dist/marketplace/index.d.ts +0 -34
- package/dist/marketplace/index.js +0 -202
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCalculatorServer = createCalculatorServer;
|
|
4
|
+
const UNITS = {
|
|
5
|
+
length: { m: 1, km: 1000, cm: 0.01, mm: 0.001, in: 0.0254, ft: 0.3048, yd: 0.9144, mi: 1609.344 },
|
|
6
|
+
weight: { kg: 1, g: 0.001, mg: 0.000001, lb: 0.453592, oz: 0.0283495, ton: 1000 },
|
|
7
|
+
temperature: {}, // special
|
|
8
|
+
};
|
|
9
|
+
function convertTemp(value, from, to) {
|
|
10
|
+
let celsius = from === 'C' ? value : from === 'F' ? (value - 32) * 5 / 9 : value - 273.15;
|
|
11
|
+
return to === 'C' ? celsius : to === 'F' ? celsius * 9 / 5 + 32 : celsius + 273.15;
|
|
12
|
+
}
|
|
13
|
+
function createCalculatorServer() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'calculator',
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
tools: [
|
|
18
|
+
{
|
|
19
|
+
name: 'calc_evaluate',
|
|
20
|
+
description: 'Evaluate a mathematical expression (safe eval with Math functions)',
|
|
21
|
+
inputSchema: { type: 'object', properties: { expression: { type: 'string', description: 'Math expression, e.g. "sqrt(16) + pow(2,3)"' } }, required: ['expression'] },
|
|
22
|
+
handler: async (args) => {
|
|
23
|
+
const safe = args.expression.replace(/[^0-9+\-*/().,%\s]/g, (m) => {
|
|
24
|
+
const allowed = ['Math', 'PI', 'E', 'sqrt', 'pow', 'abs', 'sin', 'cos', 'tan', 'log', 'log2', 'log10', 'ceil', 'floor', 'round', 'min', 'max', 'random'];
|
|
25
|
+
return allowed.some(a => m.includes(a)) ? m : '';
|
|
26
|
+
});
|
|
27
|
+
const fn = new Function('Math', `"use strict"; return (${args.expression})`);
|
|
28
|
+
const result = fn(Math);
|
|
29
|
+
return { expression: args.expression, result };
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'calc_convert',
|
|
34
|
+
description: 'Convert between units (length, weight, temperature)',
|
|
35
|
+
inputSchema: { type: 'object', properties: { value: { type: 'number' }, from: { type: 'string' }, to: { type: 'string' }, category: { type: 'string', enum: ['length', 'weight', 'temperature'] } }, required: ['value', 'from', 'to'] },
|
|
36
|
+
handler: async (args) => {
|
|
37
|
+
if (['C', 'F', 'K'].includes(args.from) && ['C', 'F', 'K'].includes(args.to)) {
|
|
38
|
+
return { value: args.value, from: args.from, to: args.to, result: convertTemp(args.value, args.from, args.to) };
|
|
39
|
+
}
|
|
40
|
+
for (const [, units] of Object.entries(UNITS)) {
|
|
41
|
+
if (units[args.from] && units[args.to]) {
|
|
42
|
+
const base = args.value * units[args.from];
|
|
43
|
+
return { value: args.value, from: args.from, to: args.to, result: base / units[args.to] };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Cannot convert ${args.from} to ${args.to}`);
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'calc_percentage',
|
|
51
|
+
description: 'Calculate percentages: what is X% of Y, X is what % of Y, % change',
|
|
52
|
+
inputSchema: { type: 'object', properties: { operation: { type: 'string', enum: ['of', 'is_what_percent', 'change'] }, x: { type: 'number' }, y: { type: 'number' } }, required: ['operation', 'x', 'y'] },
|
|
53
|
+
handler: async (args) => {
|
|
54
|
+
switch (args.operation) {
|
|
55
|
+
case 'of': return { result: (args.x / 100) * args.y, description: `${args.x}% of ${args.y}` };
|
|
56
|
+
case 'is_what_percent': return { result: (args.x / args.y) * 100, description: `${args.x} is ${((args.x / args.y) * 100).toFixed(2)}% of ${args.y}` };
|
|
57
|
+
case 'change': return { result: ((args.y - args.x) / args.x) * 100, description: `Change from ${args.x} to ${args.y}` };
|
|
58
|
+
default: throw new Error('Unknown operation');
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=calculator-mcp.js.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createCryptoServer = createCryptoServer;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
function createCryptoServer() {
|
|
39
|
+
return {
|
|
40
|
+
name: 'crypto',
|
|
41
|
+
version: '1.0.0',
|
|
42
|
+
tools: [
|
|
43
|
+
{
|
|
44
|
+
name: 'crypto_hash',
|
|
45
|
+
description: 'Generate hash of input text (md5, sha1, sha256, sha512)',
|
|
46
|
+
inputSchema: { type: 'object', properties: { text: { type: 'string' }, algorithm: { type: 'string', enum: ['md5', 'sha1', 'sha256', 'sha512'], default: 'sha256' } }, required: ['text'] },
|
|
47
|
+
handler: async (args) => {
|
|
48
|
+
const hash = crypto.createHash(args.algorithm || 'sha256').update(args.text).digest('hex');
|
|
49
|
+
return { hash, algorithm: args.algorithm || 'sha256' };
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'crypto_hmac',
|
|
54
|
+
description: 'Generate HMAC signature',
|
|
55
|
+
inputSchema: { type: 'object', properties: { text: { type: 'string' }, key: { type: 'string' }, algorithm: { type: 'string', default: 'sha256' } }, required: ['text', 'key'] },
|
|
56
|
+
handler: async (args) => {
|
|
57
|
+
const hmac = crypto.createHmac(args.algorithm || 'sha256', args.key).update(args.text).digest('hex');
|
|
58
|
+
return { hmac, algorithm: args.algorithm || 'sha256' };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'crypto_random',
|
|
63
|
+
description: 'Generate random bytes, UUID, or random number',
|
|
64
|
+
inputSchema: { type: 'object', properties: { type: { type: 'string', enum: ['bytes', 'uuid', 'number'], default: 'uuid' }, length: { type: 'number', default: 32 }, min: { type: 'number' }, max: { type: 'number' } }, required: [] },
|
|
65
|
+
handler: async (args) => {
|
|
66
|
+
switch (args.type || 'uuid') {
|
|
67
|
+
case 'bytes': return { value: crypto.randomBytes(args.length || 32).toString('hex') };
|
|
68
|
+
case 'uuid': return { value: crypto.randomUUID() };
|
|
69
|
+
case 'number': {
|
|
70
|
+
const min = args.min ?? 0;
|
|
71
|
+
const max = args.max ?? 100;
|
|
72
|
+
return { value: min + Math.floor(Math.random() * (max - min + 1)) };
|
|
73
|
+
}
|
|
74
|
+
default: throw new Error('Unknown type');
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'crypto_encrypt',
|
|
80
|
+
description: 'Encrypt text with AES-256-GCM',
|
|
81
|
+
inputSchema: { type: 'object', properties: { text: { type: 'string' }, password: { type: 'string' } }, required: ['text', 'password'] },
|
|
82
|
+
handler: async (args) => {
|
|
83
|
+
const key = crypto.scryptSync(args.password, 'opc-salt', 32);
|
|
84
|
+
const iv = crypto.randomBytes(16);
|
|
85
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
86
|
+
let encrypted = cipher.update(args.text, 'utf8', 'hex');
|
|
87
|
+
encrypted += cipher.final('hex');
|
|
88
|
+
const tag = cipher.getAuthTag().toString('hex');
|
|
89
|
+
return { encrypted, iv: iv.toString('hex'), tag };
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'crypto_decrypt',
|
|
94
|
+
description: 'Decrypt AES-256-GCM encrypted text',
|
|
95
|
+
inputSchema: { type: 'object', properties: { encrypted: { type: 'string' }, password: { type: 'string' }, iv: { type: 'string' }, tag: { type: 'string' } }, required: ['encrypted', 'password', 'iv', 'tag'] },
|
|
96
|
+
handler: async (args) => {
|
|
97
|
+
const key = crypto.scryptSync(args.password, 'opc-salt', 32);
|
|
98
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, Buffer.from(args.iv, 'hex'));
|
|
99
|
+
decipher.setAuthTag(Buffer.from(args.tag, 'hex'));
|
|
100
|
+
let decrypted = decipher.update(args.encrypted, 'hex', 'utf8');
|
|
101
|
+
decrypted += decipher.final('utf8');
|
|
102
|
+
return { decrypted };
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=crypto-mcp.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDatabaseServer = createDatabaseServer;
|
|
4
|
+
function createDatabaseServer() {
|
|
5
|
+
const tables = new Map();
|
|
6
|
+
return {
|
|
7
|
+
name: 'database',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
tools: [
|
|
10
|
+
{
|
|
11
|
+
name: 'db_create_table',
|
|
12
|
+
description: 'Create a table with specified columns',
|
|
13
|
+
inputSchema: { type: 'object', properties: { table: { type: 'string' }, columns: { type: 'array', items: { type: 'string' } } }, required: ['table', 'columns'] },
|
|
14
|
+
handler: async (args) => {
|
|
15
|
+
tables.set(args.table, { columns: args.columns, rows: [] });
|
|
16
|
+
return { created: args.table, columns: args.columns };
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'db_insert',
|
|
21
|
+
description: 'Insert a row into a table',
|
|
22
|
+
inputSchema: { type: 'object', properties: { table: { type: 'string' }, values: { type: 'object' } }, required: ['table', 'values'] },
|
|
23
|
+
handler: async (args) => {
|
|
24
|
+
const t = tables.get(args.table);
|
|
25
|
+
if (!t)
|
|
26
|
+
throw new Error(`Table ${args.table} not found`);
|
|
27
|
+
const row = t.columns.map(c => args.values[c] ?? null);
|
|
28
|
+
t.rows.push(row);
|
|
29
|
+
return { inserted: true, rowIndex: t.rows.length - 1 };
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'db_query',
|
|
34
|
+
description: 'Query a table with optional where clause',
|
|
35
|
+
inputSchema: { type: 'object', properties: { table: { type: 'string' }, where: { type: 'object' }, limit: { type: 'number' } }, required: ['table'] },
|
|
36
|
+
handler: async (args) => {
|
|
37
|
+
const t = tables.get(args.table);
|
|
38
|
+
if (!t)
|
|
39
|
+
throw new Error(`Table ${args.table} not found`);
|
|
40
|
+
let results = t.rows.map(row => {
|
|
41
|
+
const obj = {};
|
|
42
|
+
t.columns.forEach((c, i) => obj[c] = row[i]);
|
|
43
|
+
return obj;
|
|
44
|
+
});
|
|
45
|
+
if (args.where) {
|
|
46
|
+
results = results.filter(row => Object.entries(args.where).every(([k, v]) => row[k] === v));
|
|
47
|
+
}
|
|
48
|
+
if (args.limit)
|
|
49
|
+
results = results.slice(0, args.limit);
|
|
50
|
+
return { rows: results, count: results.length };
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'db_list_tables',
|
|
55
|
+
description: 'List all tables',
|
|
56
|
+
inputSchema: { type: 'object', properties: {} },
|
|
57
|
+
handler: async () => {
|
|
58
|
+
return { tables: Array.from(tables.entries()).map(([name, t]) => ({ name, columns: t.columns, rowCount: t.rows.length })) };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'db_drop_table',
|
|
63
|
+
description: 'Drop a table',
|
|
64
|
+
inputSchema: { type: 'object', properties: { table: { type: 'string' } }, required: ['table'] },
|
|
65
|
+
handler: async (args) => {
|
|
66
|
+
const existed = tables.delete(args.table);
|
|
67
|
+
return { dropped: existed };
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=database-mcp.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDateTimeServer = createDateTimeServer;
|
|
4
|
+
const TIMEZONE_OFFSETS = {
|
|
5
|
+
'UTC': 0, 'GMT': 0, 'EST': -5, 'EDT': -4, 'CST': -6, 'CDT': -5,
|
|
6
|
+
'MST': -7, 'MDT': -6, 'PST': -8, 'PDT': -7, 'JST': 9, 'KST': 9,
|
|
7
|
+
'CST8': 8, 'IST': 5.5, 'CET': 1, 'CEST': 2, 'AEST': 10, 'AEDT': 11,
|
|
8
|
+
'Asia/Shanghai': 8, 'Asia/Tokyo': 9, 'America/New_York': -4,
|
|
9
|
+
'America/Los_Angeles': -7, 'Europe/London': 1, 'Europe/Berlin': 2,
|
|
10
|
+
};
|
|
11
|
+
function createDateTimeServer() {
|
|
12
|
+
return {
|
|
13
|
+
name: 'datetime',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
tools: [
|
|
16
|
+
{
|
|
17
|
+
name: 'dt_now',
|
|
18
|
+
description: 'Get current date/time in a timezone',
|
|
19
|
+
inputSchema: { type: 'object', properties: { timezone: { type: 'string', default: 'UTC' }, format: { type: 'string', enum: ['iso', 'unix', 'human'], default: 'iso' } } },
|
|
20
|
+
handler: async (args) => {
|
|
21
|
+
const offset = TIMEZONE_OFFSETS[args.timezone || 'UTC'] ?? 0;
|
|
22
|
+
const now = new Date(Date.now() + offset * 3600000);
|
|
23
|
+
const fmt = args.format || 'iso';
|
|
24
|
+
return {
|
|
25
|
+
iso: now.toISOString(),
|
|
26
|
+
unix: Math.floor(now.getTime() / 1000),
|
|
27
|
+
human: now.toUTCString(),
|
|
28
|
+
timezone: args.timezone || 'UTC',
|
|
29
|
+
offset,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'dt_diff',
|
|
35
|
+
description: 'Calculate difference between two dates',
|
|
36
|
+
inputSchema: { type: 'object', properties: { from: { type: 'string' }, to: { type: 'string' }, unit: { type: 'string', enum: ['days', 'hours', 'minutes', 'seconds'], default: 'days' } }, required: ['from', 'to'] },
|
|
37
|
+
handler: async (args) => {
|
|
38
|
+
const d1 = new Date(args.from).getTime();
|
|
39
|
+
const d2 = new Date(args.to).getTime();
|
|
40
|
+
const diffMs = d2 - d1;
|
|
41
|
+
const divisors = { seconds: 1000, minutes: 60000, hours: 3600000, days: 86400000 };
|
|
42
|
+
const unit = args.unit || 'days';
|
|
43
|
+
return { from: args.from, to: args.to, difference: diffMs / divisors[unit], unit };
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'dt_add',
|
|
48
|
+
description: 'Add duration to a date',
|
|
49
|
+
inputSchema: { type: 'object', properties: { date: { type: 'string' }, amount: { type: 'number' }, unit: { type: 'string', enum: ['days', 'hours', 'minutes', 'seconds'] } }, required: ['date', 'amount', 'unit'] },
|
|
50
|
+
handler: async (args) => {
|
|
51
|
+
const d = new Date(args.date);
|
|
52
|
+
const ms = { seconds: 1000, minutes: 60000, hours: 3600000, days: 86400000 };
|
|
53
|
+
const result = new Date(d.getTime() + args.amount * ms[args.unit]);
|
|
54
|
+
return { original: args.date, result: result.toISOString(), added: `${args.amount} ${args.unit}` };
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'dt_parse',
|
|
59
|
+
description: 'Parse a date string and return components',
|
|
60
|
+
inputSchema: { type: 'object', properties: { date: { type: 'string' } }, required: ['date'] },
|
|
61
|
+
handler: async (args) => {
|
|
62
|
+
const d = new Date(args.date);
|
|
63
|
+
if (isNaN(d.getTime()))
|
|
64
|
+
throw new Error('Invalid date');
|
|
65
|
+
return { iso: d.toISOString(), year: d.getFullYear(), month: d.getMonth() + 1, day: d.getDate(), dayOfWeek: d.toLocaleDateString('en', { weekday: 'long' }), unix: Math.floor(d.getTime() / 1000) };
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=datetime-mcp.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createFilesystemServer = createFilesystemServer;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
function createFilesystemServer(rootDir = process.cwd()) {
|
|
40
|
+
const resolve = (p) => {
|
|
41
|
+
const resolved = path.resolve(rootDir, p);
|
|
42
|
+
if (!resolved.startsWith(path.resolve(rootDir)))
|
|
43
|
+
throw new Error('Path traversal not allowed');
|
|
44
|
+
return resolved;
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
name: 'filesystem',
|
|
48
|
+
version: '1.0.0',
|
|
49
|
+
tools: [
|
|
50
|
+
{
|
|
51
|
+
name: 'fs_read',
|
|
52
|
+
description: 'Read file contents as UTF-8 text',
|
|
53
|
+
inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path relative to root' } }, required: ['path'] },
|
|
54
|
+
handler: async (args) => {
|
|
55
|
+
return { content: fs.readFileSync(resolve(args.path), 'utf-8') };
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'fs_write',
|
|
60
|
+
description: 'Write content to a file (creates directories as needed)',
|
|
61
|
+
inputSchema: { type: 'object', properties: { path: { type: 'string' }, content: { type: 'string' } }, required: ['path', 'content'] },
|
|
62
|
+
handler: async (args) => {
|
|
63
|
+
const target = resolve(args.path);
|
|
64
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
65
|
+
fs.writeFileSync(target, args.content, 'utf-8');
|
|
66
|
+
return { written: target };
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'fs_list',
|
|
71
|
+
description: 'List files and directories',
|
|
72
|
+
inputSchema: { type: 'object', properties: { path: { type: 'string', default: '.' }, recursive: { type: 'boolean', default: false } }, required: [] },
|
|
73
|
+
handler: async (args) => {
|
|
74
|
+
const dir = resolve(args.path || '.');
|
|
75
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
76
|
+
const result = entries.map(e => ({ name: e.name, type: e.isDirectory() ? 'directory' : 'file' }));
|
|
77
|
+
return { entries: result };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'fs_stat',
|
|
82
|
+
description: 'Get file/directory metadata',
|
|
83
|
+
inputSchema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] },
|
|
84
|
+
handler: async (args) => {
|
|
85
|
+
const stat = fs.statSync(resolve(args.path));
|
|
86
|
+
return { size: stat.size, isFile: stat.isFile(), isDirectory: stat.isDirectory(), modified: stat.mtime.toISOString() };
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'fs_delete',
|
|
91
|
+
description: 'Delete a file',
|
|
92
|
+
inputSchema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] },
|
|
93
|
+
handler: async (args) => {
|
|
94
|
+
fs.unlinkSync(resolve(args.path));
|
|
95
|
+
return { deleted: true };
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGitHubServer = createGitHubServer;
|
|
4
|
+
function createGitHubServer(token) {
|
|
5
|
+
const headers = {
|
|
6
|
+
'Accept': 'application/vnd.github.v3+json',
|
|
7
|
+
'User-Agent': 'opc-mcp-github/1.0',
|
|
8
|
+
};
|
|
9
|
+
if (token)
|
|
10
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
11
|
+
const ghFetch = async (path, opts = {}) => {
|
|
12
|
+
const res = await fetch(`https://api.github.com${path}`, { ...opts, headers: { ...headers, ...opts.headers } });
|
|
13
|
+
if (!res.ok)
|
|
14
|
+
throw new Error(`GitHub API ${res.status}: ${await res.text()}`);
|
|
15
|
+
return res.json();
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
name: 'github',
|
|
19
|
+
version: '1.0.0',
|
|
20
|
+
tools: [
|
|
21
|
+
{
|
|
22
|
+
name: 'github_get_repo',
|
|
23
|
+
description: 'Get repository information',
|
|
24
|
+
inputSchema: { type: 'object', properties: { owner: { type: 'string' }, repo: { type: 'string' } }, required: ['owner', 'repo'] },
|
|
25
|
+
handler: async (args) => ghFetch(`/repos/${args.owner}/${args.repo}`),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'github_list_issues',
|
|
29
|
+
description: 'List repository issues',
|
|
30
|
+
inputSchema: { type: 'object', properties: { owner: { type: 'string' }, repo: { type: 'string' }, state: { type: 'string', enum: ['open', 'closed', 'all'], default: 'open' } }, required: ['owner', 'repo'] },
|
|
31
|
+
handler: async (args) => ghFetch(`/repos/${args.owner}/${args.repo}/issues?state=${args.state || 'open'}`),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'github_create_issue',
|
|
35
|
+
description: 'Create a new issue',
|
|
36
|
+
inputSchema: { type: 'object', properties: { owner: { type: 'string' }, repo: { type: 'string' }, title: { type: 'string' }, body: { type: 'string' } }, required: ['owner', 'repo', 'title'] },
|
|
37
|
+
handler: async (args) => ghFetch(`/repos/${args.owner}/${args.repo}/issues`, { method: 'POST', body: JSON.stringify({ title: args.title, body: args.body }), headers: { 'Content-Type': 'application/json' } }),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'github_search_repos',
|
|
41
|
+
description: 'Search GitHub repositories',
|
|
42
|
+
inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
|
|
43
|
+
handler: async (args) => ghFetch(`/search/repositories?q=${encodeURIComponent(args.query)}`),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'github_get_file',
|
|
47
|
+
description: 'Get file contents from a repository',
|
|
48
|
+
inputSchema: { type: 'object', properties: { owner: { type: 'string' }, repo: { type: 'string' }, path: { type: 'string' }, ref: { type: 'string' } }, required: ['owner', 'repo', 'path'] },
|
|
49
|
+
handler: async (args) => {
|
|
50
|
+
const q = args.ref ? `?ref=${args.ref}` : '';
|
|
51
|
+
const data = await ghFetch(`/repos/${args.owner}/${args.repo}/contents/${args.path}${q}`);
|
|
52
|
+
if (data.content)
|
|
53
|
+
data.decoded = Buffer.from(data.content, 'base64').toString('utf-8');
|
|
54
|
+
return data;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=github-mcp.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MCPServerConfig } from '../../protocols/mcp/types';
|
|
2
|
+
import { createFilesystemServer } from './filesystem';
|
|
3
|
+
import { createGitHubServer } from './github-mcp';
|
|
4
|
+
import { createDatabaseServer } from './database-mcp';
|
|
5
|
+
import { createWebServer } from './web-mcp';
|
|
6
|
+
import { createMemoryServer } from './memory-mcp';
|
|
7
|
+
import { createCalculatorServer } from './calculator-mcp';
|
|
8
|
+
import { createDateTimeServer } from './datetime-mcp';
|
|
9
|
+
import { createJsonServer } from './json-mcp';
|
|
10
|
+
import { createRegexServer } from './regex-mcp';
|
|
11
|
+
import { createCryptoServer } from './crypto-mcp';
|
|
12
|
+
export interface MCPServerInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
version: string;
|
|
16
|
+
toolCount: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function getMCPServer(name: string): MCPServerConfig;
|
|
19
|
+
export declare function listMCPServers(): MCPServerInfo[];
|
|
20
|
+
export { createFilesystemServer, createGitHubServer, createDatabaseServer, createWebServer, createMemoryServer, createCalculatorServer, createDateTimeServer, createJsonServer, createRegexServer, createCryptoServer, };
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCryptoServer = exports.createRegexServer = exports.createJsonServer = exports.createDateTimeServer = exports.createCalculatorServer = exports.createMemoryServer = exports.createWebServer = exports.createDatabaseServer = exports.createGitHubServer = exports.createFilesystemServer = void 0;
|
|
4
|
+
exports.getMCPServer = getMCPServer;
|
|
5
|
+
exports.listMCPServers = listMCPServers;
|
|
6
|
+
const filesystem_1 = require("./filesystem");
|
|
7
|
+
Object.defineProperty(exports, "createFilesystemServer", { enumerable: true, get: function () { return filesystem_1.createFilesystemServer; } });
|
|
8
|
+
const github_mcp_1 = require("./github-mcp");
|
|
9
|
+
Object.defineProperty(exports, "createGitHubServer", { enumerable: true, get: function () { return github_mcp_1.createGitHubServer; } });
|
|
10
|
+
const database_mcp_1 = require("./database-mcp");
|
|
11
|
+
Object.defineProperty(exports, "createDatabaseServer", { enumerable: true, get: function () { return database_mcp_1.createDatabaseServer; } });
|
|
12
|
+
const web_mcp_1 = require("./web-mcp");
|
|
13
|
+
Object.defineProperty(exports, "createWebServer", { enumerable: true, get: function () { return web_mcp_1.createWebServer; } });
|
|
14
|
+
const memory_mcp_1 = require("./memory-mcp");
|
|
15
|
+
Object.defineProperty(exports, "createMemoryServer", { enumerable: true, get: function () { return memory_mcp_1.createMemoryServer; } });
|
|
16
|
+
const calculator_mcp_1 = require("./calculator-mcp");
|
|
17
|
+
Object.defineProperty(exports, "createCalculatorServer", { enumerable: true, get: function () { return calculator_mcp_1.createCalculatorServer; } });
|
|
18
|
+
const datetime_mcp_1 = require("./datetime-mcp");
|
|
19
|
+
Object.defineProperty(exports, "createDateTimeServer", { enumerable: true, get: function () { return datetime_mcp_1.createDateTimeServer; } });
|
|
20
|
+
const json_mcp_1 = require("./json-mcp");
|
|
21
|
+
Object.defineProperty(exports, "createJsonServer", { enumerable: true, get: function () { return json_mcp_1.createJsonServer; } });
|
|
22
|
+
const regex_mcp_1 = require("./regex-mcp");
|
|
23
|
+
Object.defineProperty(exports, "createRegexServer", { enumerable: true, get: function () { return regex_mcp_1.createRegexServer; } });
|
|
24
|
+
const crypto_mcp_1 = require("./crypto-mcp");
|
|
25
|
+
Object.defineProperty(exports, "createCryptoServer", { enumerable: true, get: function () { return crypto_mcp_1.createCryptoServer; } });
|
|
26
|
+
const SERVERS = [
|
|
27
|
+
{ name: 'filesystem', description: 'Read/write/list files in a sandboxed directory', factory: () => (0, filesystem_1.createFilesystemServer)() },
|
|
28
|
+
{ name: 'github', description: 'GitHub API — repos, issues, files via fetch', factory: () => (0, github_mcp_1.createGitHubServer)() },
|
|
29
|
+
{ name: 'database', description: 'In-memory SQL-like database with tables and queries', factory: () => (0, database_mcp_1.createDatabaseServer)() },
|
|
30
|
+
{ name: 'web', description: 'Web fetch, text extraction, and search', factory: () => (0, web_mcp_1.createWebServer)() },
|
|
31
|
+
{ name: 'memory', description: 'Key-value memory store with tags and search', factory: () => (0, memory_mcp_1.createMemoryServer)() },
|
|
32
|
+
{ name: 'calculator', description: 'Math evaluation, unit conversion, percentages', factory: () => (0, calculator_mcp_1.createCalculatorServer)() },
|
|
33
|
+
{ name: 'datetime', description: 'Time zones, date math, parsing, and formatting', factory: () => (0, datetime_mcp_1.createDateTimeServer)() },
|
|
34
|
+
{ name: 'json', description: 'JSON path query, transform, validate, and diff', factory: () => (0, json_mcp_1.createJsonServer)() },
|
|
35
|
+
{ name: 'regex', description: 'Regex test, match, replace, and split', factory: () => (0, regex_mcp_1.createRegexServer)() },
|
|
36
|
+
{ name: 'crypto', description: 'Hash, HMAC, encrypt/decrypt, random generation', factory: () => (0, crypto_mcp_1.createCryptoServer)() },
|
|
37
|
+
];
|
|
38
|
+
function getMCPServer(name) {
|
|
39
|
+
const entry = SERVERS.find(s => s.name === name);
|
|
40
|
+
if (!entry)
|
|
41
|
+
throw new Error(`MCP server '${name}' not found. Available: ${SERVERS.map(s => s.name).join(', ')}`);
|
|
42
|
+
return entry.factory();
|
|
43
|
+
}
|
|
44
|
+
function listMCPServers() {
|
|
45
|
+
return SERVERS.map(s => {
|
|
46
|
+
const config = s.factory();
|
|
47
|
+
return { name: s.name, description: s.description, version: config.version, toolCount: config.tools?.length || 0 };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.js.map
|