opc-agent 2.1.0 → 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 +172 -1
- package/dist/core/agent.d.ts +4 -0
- package/dist/core/agent.js +35 -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/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 +176 -2
- package/src/core/agent.ts +38 -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/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/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
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.isValidEventType = exports.AGUI_EVENT_TYPES = exports.AGUIClient = exports.AGUIEventEmitter = exports.AGUIServer = exports.AgentEvaluator = exports.agentToMCPResources = exports.agentToMCPTools = exports.MCPServer = exports.JSON_RPC_ERRORS = exports.oadToAgentCard = exports.A2AClient = exports.A2AServer = exports.StudioServer = exports.AgentInstaller = exports.AgentPublisher = exports.AgentPackager = exports.MCPClient = exports.getBuiltinToolsByName = exports.getBuiltinTools = exports.cronMatches = exports.parseCron = exports.Scheduler = exports.SubAgentManager = exports.generateSpanId = exports.generateTraceId = exports.OTLPHttpExporter = exports.FileExporter = exports.ConsoleExporter = exports.Tracer = exports.DeepBrainExporter = exports.TraceConsoleExporter = exports.TraceCollector = exports.StreamableResponse = exports.StreamingManager = exports.ToolGateway = exports.ProcessWatcher = void 0;
|
|
3
|
+
exports.KnowledgeBase = exports.addMessages = exports.detectLocale = exports.getLocale = exports.setLocale = exports.t = exports.LazyLoader = exports.RequestBatcher = exports.ConnectionPool = exports.VersionManager = exports.WebhookChannel = exports.createVoiceProviders = exports.ElevenLabsTTSProvider = exports.OpenAITTSProvider = exports.EdgeTTSProvider = exports.DeepgramSTTProvider = exports.WhisperSTTProvider = exports.VoiceChannel = exports.HITLManager = exports.AgentCardRegistry = exports.AgentRegistry = exports.parseOADWorkflow = exports.WorkflowBuilder = exports.GraphWorkflowEngine = exports.WorkflowEngine = exports.Analytics = exports.KeyManager = exports.ApprovalManager = exports.Sandbox = exports.PluginManager = exports.createMCPTool = exports.MCPToolRegistry = exports.Room = exports.SUPPORTED_PROVIDERS = exports.createProvider = exports.DeepBrainMemoryStore = exports.InMemoryStore = exports.SkillRegistry = exports.BaseSkill = exports.WebSocketChannel = exports.TelegramChannel = exports.WebChannel = exports.BaseChannel = exports.OADSchema = exports.validateOAD = exports.loadOAD = exports.Logger = exports.truncateOutput = exports.AgentRuntime = exports.BaseAgent = void 0;
|
|
4
|
+
exports.loggerPlugin = exports.createRateLimitPlugin = exports.createAnalyticsPlugin = exports.createLoggingPlugin = exports.inputValidation = exports.APIKeyManager = exports.corsMiddleware = exports.securityHeaders = exports.detectInjection = exports.sanitizeInput = exports.formatErrorForUser = exports.wrapError = exports.TimeoutError = exports.SecurityError = exports.RateLimitError = exports.PluginError = exports.ChannelError = exports.ConfigError = exports.ValidationError = exports.ProviderError = exports.OPCError = exports.createTeacherConfig = exports.createDataAnalystConfig = exports.getSupportedLocales = exports.LLMCache = exports.RateLimiter = exports.AnalyticsEngine = exports.formatReport = exports.loadTestCases = exports.runTests = exports.parseSkillMarkdown = exports.skillToMarkdown = exports.SkillLearner = exports.DocumentSkill = exports.SchedulerSkill = exports.WebhookTriggerSkill = exports.HttpSkill = exports.TextAnalysisTool = exports.JsonTransformTool = exports.DateTimeTool = exports.CalculatorTool = exports.WeChatChannel = exports.SlackChannel = exports.EmailChannel = exports.compose = exports.AgentPipeline = exports.Orchestrator = exports.getActiveSessions = exports.createAuthMiddleware = exports.deployToHermes = void 0;
|
|
5
|
+
exports.SharedContext = exports.HierarchyPattern = exports.PipelinePattern = exports.VotingPattern = exports.DebatePattern = exports.isValidEventType = exports.AGUI_EVENT_TYPES = exports.AGUIClient = exports.AGUIEventEmitter = exports.AGUIServer = exports.AgentEvaluator = exports.agentToMCPResources = exports.agentToMCPTools = exports.MCPServer = exports.JSON_RPC_ERRORS = exports.oadToAgentCard = exports.A2AClient = exports.A2AServer = exports.StudioServer = exports.AgentInstaller = exports.AgentPublisher = exports.AgentPackager = exports.MCPClient = exports.getBuiltinToolsByName = exports.getBuiltinTools = exports.cronMatches = exports.parseCron = exports.Scheduler = exports.SubAgentManager = exports.generateSpanId = exports.generateTraceId = exports.OTLPHttpExporter = exports.FileExporter = exports.ConsoleExporter = exports.Tracer = exports.DeepBrainExporter = exports.TraceConsoleExporter = exports.TraceCollector = exports.StreamableResponse = exports.StreamingManager = exports.ToolGateway = exports.ProcessWatcher = exports.DiscordChannel = exports.FeishuChannel = exports.createGuardrailsFromConfig = exports.GuardrailManager = exports.createContentFilterPlugin = exports.contentFilterPlugin = exports.createEnhancedRateLimiterPlugin = exports.rateLimiterPlugin = void 0;
|
|
6
|
+
exports.getIntegrationTool = exports.getAllIntegrationTools = exports.TranslatorTool = exports.SummarizerTool = exports.CSVAnalyzerTool = exports.PDFReaderTool = exports.ImageGenerationTool = exports.NpmTool = exports.GitTool = exports.CodeExecutionTool = exports.VectorSearchTool = exports.DatabaseTool = exports.WebScraperTool = exports.WebSearchTool = exports.TrelloTool = exports.CalendarTool = exports.JiraTool = exports.GitHubTool = exports.NotionTool = exports.WebhookTool = exports.EmailSendTool = exports.SlackTool = exports.ConversationProtocol = void 0;
|
|
6
7
|
// OPC Agent — Open Agent Framework
|
|
7
8
|
var agent_1 = require("./core/agent");
|
|
8
9
|
Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return agent_1.BaseAgent; } });
|
|
@@ -65,6 +66,13 @@ var hitl_1 = require("./core/hitl");
|
|
|
65
66
|
Object.defineProperty(exports, "HITLManager", { enumerable: true, get: function () { return hitl_1.HITLManager; } });
|
|
66
67
|
var voice_1 = require("./channels/voice");
|
|
67
68
|
Object.defineProperty(exports, "VoiceChannel", { enumerable: true, get: function () { return voice_1.VoiceChannel; } });
|
|
69
|
+
var voice_2 = require("./channels/voice");
|
|
70
|
+
Object.defineProperty(exports, "WhisperSTTProvider", { enumerable: true, get: function () { return voice_2.WhisperSTTProvider; } });
|
|
71
|
+
Object.defineProperty(exports, "DeepgramSTTProvider", { enumerable: true, get: function () { return voice_2.DeepgramSTTProvider; } });
|
|
72
|
+
Object.defineProperty(exports, "EdgeTTSProvider", { enumerable: true, get: function () { return voice_2.EdgeTTSProvider; } });
|
|
73
|
+
Object.defineProperty(exports, "OpenAITTSProvider", { enumerable: true, get: function () { return voice_2.OpenAITTSProvider; } });
|
|
74
|
+
Object.defineProperty(exports, "ElevenLabsTTSProvider", { enumerable: true, get: function () { return voice_2.ElevenLabsTTSProvider; } });
|
|
75
|
+
Object.defineProperty(exports, "createVoiceProviders", { enumerable: true, get: function () { return voice_2.createVoiceProviders; } });
|
|
68
76
|
var webhook_1 = require("./channels/webhook");
|
|
69
77
|
Object.defineProperty(exports, "WebhookChannel", { enumerable: true, get: function () { return webhook_1.WebhookChannel; } });
|
|
70
78
|
var versioning_1 = require("./core/versioning");
|
|
@@ -169,6 +177,10 @@ Object.defineProperty(exports, "createEnhancedRateLimiterPlugin", { enumerable:
|
|
|
169
177
|
var content_filter_1 = require("./plugins/content-filter");
|
|
170
178
|
Object.defineProperty(exports, "contentFilterPlugin", { enumerable: true, get: function () { return content_filter_1.contentFilterPlugin; } });
|
|
171
179
|
Object.defineProperty(exports, "createContentFilterPlugin", { enumerable: true, get: function () { return content_filter_1.createContentFilterPlugin; } });
|
|
180
|
+
// v2.1.0 — Guardrails
|
|
181
|
+
var guardrails_1 = require("./security/guardrails");
|
|
182
|
+
Object.defineProperty(exports, "GuardrailManager", { enumerable: true, get: function () { return guardrails_1.GuardrailManager; } });
|
|
183
|
+
Object.defineProperty(exports, "createGuardrailsFromConfig", { enumerable: true, get: function () { return guardrails_1.createGuardrailsFromConfig; } });
|
|
172
184
|
// v1.1.0 modules
|
|
173
185
|
var feishu_1 = require("./channels/feishu");
|
|
174
186
|
Object.defineProperty(exports, "FeishuChannel", { enumerable: true, get: function () { return feishu_1.FeishuChannel; } });
|
|
@@ -240,4 +252,36 @@ Object.defineProperty(exports, "AGUIClient", { enumerable: true, get: function (
|
|
|
240
252
|
var agui_2 = require("./protocols/agui");
|
|
241
253
|
Object.defineProperty(exports, "AGUI_EVENT_TYPES", { enumerable: true, get: function () { return agui_2.AGUI_EVENT_TYPES; } });
|
|
242
254
|
Object.defineProperty(exports, "isValidEventType", { enumerable: true, get: function () { return agui_2.isValidEventType; } });
|
|
255
|
+
// v2.0.0 - Multi-agent collaboration patterns
|
|
256
|
+
var collaboration_1 = require("./core/collaboration");
|
|
257
|
+
Object.defineProperty(exports, "DebatePattern", { enumerable: true, get: function () { return collaboration_1.DebatePattern; } });
|
|
258
|
+
Object.defineProperty(exports, "VotingPattern", { enumerable: true, get: function () { return collaboration_1.VotingPattern; } });
|
|
259
|
+
Object.defineProperty(exports, "PipelinePattern", { enumerable: true, get: function () { return collaboration_1.PipelinePattern; } });
|
|
260
|
+
Object.defineProperty(exports, "HierarchyPattern", { enumerable: true, get: function () { return collaboration_1.HierarchyPattern; } });
|
|
261
|
+
Object.defineProperty(exports, "SharedContext", { enumerable: true, get: function () { return collaboration_1.SharedContext; } });
|
|
262
|
+
Object.defineProperty(exports, "ConversationProtocol", { enumerable: true, get: function () { return collaboration_1.ConversationProtocol; } });
|
|
263
|
+
// v2.0.0 - Pre-built tool integrations (20 tools)
|
|
264
|
+
var integrations_1 = require("./tools/integrations");
|
|
265
|
+
Object.defineProperty(exports, "SlackTool", { enumerable: true, get: function () { return integrations_1.SlackTool; } });
|
|
266
|
+
Object.defineProperty(exports, "EmailSendTool", { enumerable: true, get: function () { return integrations_1.EmailSendTool; } });
|
|
267
|
+
Object.defineProperty(exports, "WebhookTool", { enumerable: true, get: function () { return integrations_1.WebhookTool; } });
|
|
268
|
+
Object.defineProperty(exports, "NotionTool", { enumerable: true, get: function () { return integrations_1.NotionTool; } });
|
|
269
|
+
Object.defineProperty(exports, "GitHubTool", { enumerable: true, get: function () { return integrations_1.GitHubTool; } });
|
|
270
|
+
Object.defineProperty(exports, "JiraTool", { enumerable: true, get: function () { return integrations_1.JiraTool; } });
|
|
271
|
+
Object.defineProperty(exports, "CalendarTool", { enumerable: true, get: function () { return integrations_1.CalendarTool; } });
|
|
272
|
+
Object.defineProperty(exports, "TrelloTool", { enumerable: true, get: function () { return integrations_1.TrelloTool; } });
|
|
273
|
+
Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return integrations_1.WebSearchTool; } });
|
|
274
|
+
Object.defineProperty(exports, "WebScraperTool", { enumerable: true, get: function () { return integrations_1.WebScraperTool; } });
|
|
275
|
+
Object.defineProperty(exports, "DatabaseTool", { enumerable: true, get: function () { return integrations_1.DatabaseTool; } });
|
|
276
|
+
Object.defineProperty(exports, "VectorSearchTool", { enumerable: true, get: function () { return integrations_1.VectorSearchTool; } });
|
|
277
|
+
Object.defineProperty(exports, "CodeExecutionTool", { enumerable: true, get: function () { return integrations_1.CodeExecutionTool; } });
|
|
278
|
+
Object.defineProperty(exports, "GitTool", { enumerable: true, get: function () { return integrations_1.GitTool; } });
|
|
279
|
+
Object.defineProperty(exports, "NpmTool", { enumerable: true, get: function () { return integrations_1.NpmTool; } });
|
|
280
|
+
Object.defineProperty(exports, "ImageGenerationTool", { enumerable: true, get: function () { return integrations_1.ImageGenerationTool; } });
|
|
281
|
+
Object.defineProperty(exports, "PDFReaderTool", { enumerable: true, get: function () { return integrations_1.PDFReaderTool; } });
|
|
282
|
+
Object.defineProperty(exports, "CSVAnalyzerTool", { enumerable: true, get: function () { return integrations_1.CSVAnalyzerTool; } });
|
|
283
|
+
Object.defineProperty(exports, "SummarizerTool", { enumerable: true, get: function () { return integrations_1.SummarizerTool; } });
|
|
284
|
+
Object.defineProperty(exports, "TranslatorTool", { enumerable: true, get: function () { return integrations_1.TranslatorTool; } });
|
|
285
|
+
Object.defineProperty(exports, "getAllIntegrationTools", { enumerable: true, get: function () { return integrations_1.getAllIntegrationTools; } });
|
|
286
|
+
Object.defineProperty(exports, "getIntegrationTool", { enumerable: true, get: function () { return integrations_1.getIntegrationTool; } });
|
|
243
287
|
//# sourceMappingURL=index.js.map
|
|
@@ -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
|