flowmind 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +855 -0
  3. package/README_CN.md +854 -0
  4. package/bin/flowmind.js +464 -0
  5. package/core/adapters/api-doc-adapter.js +71 -0
  6. package/core/adapters/base-adapter.js +80 -0
  7. package/core/adapters/database-manager-adapter.js +60 -0
  8. package/core/adapters/database-query-adapter.js +51 -0
  9. package/core/adapters/knowledge-base-adapter.js +75 -0
  10. package/core/adapters/log-service-adapter.js +41 -0
  11. package/core/adapters/mcp-adapter.js +65 -0
  12. package/core/adapters/report-adapter.js +60 -0
  13. package/core/adapters/workflow-adapter.js +62 -0
  14. package/core/component-registry.js +281 -0
  15. package/core/component-types.js +63 -0
  16. package/core/config-manager.js +360 -0
  17. package/core/index.js +223 -0
  18. package/core/learning-engine.js +588 -0
  19. package/core/mcp-compatibility.js +150 -0
  20. package/core/providers/aliyun/dms-adapter.js +98 -0
  21. package/core/providers/aliyun/redis-adapter.js +88 -0
  22. package/core/providers/aliyun/sls-adapter.js +86 -0
  23. package/core/providers/friday/flow-adapter.js +85 -0
  24. package/core/providers/friday/report-adapter.js +83 -0
  25. package/core/providers/yapi/yapi-adapter.js +79 -0
  26. package/core/providers/yuque/yuque-adapter.js +90 -0
  27. package/core/scene-matcher.js +326 -0
  28. package/core/skill-loader.js +291 -0
  29. package/package.json +67 -0
  30. package/scripts/migrate-config.js +153 -0
  31. package/skills/api-sync/SKILL.md +203 -0
  32. package/skills/archive-change/SKILL.md +172 -0
  33. package/skills/auto-flow/SKILL.md +277 -0
  34. package/skills/code-review/SKILL.md +206 -0
  35. package/skills/code-review-audit/SKILL.md +150 -0
  36. package/skills/data-logic-validation/SKILL.md +162 -0
  37. package/skills/data-validation/SKILL.md +210 -0
  38. package/skills/git-review/SKILL.md +190 -0
  39. package/skills/learning-engine/SKILL.md +352 -0
  40. package/skills/learning-feedback/SKILL.md +174 -0
  41. package/skills/log-audit/SKILL.md +226 -0
  42. package/skills/project-review/SKILL.md +196 -0
  43. package/skills/requirement-analyst/SKILL.md +275 -0
  44. package/skills/resource-bind/SKILL.md +222 -0
  45. package/skills/sls-log-audit/SKILL.md +223 -0
  46. package/skills/yapi-sync-interface/SKILL.md +145 -0
  47. package/skills/yuque-sync-design/SKILL.md +157 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * FlowMind MCP Compatibility Layer
3
+ * Maps existing MCP server names to component types and providers.
4
+ * Ensures backward compatibility with existing configurations.
5
+ */
6
+
7
+ const { ComponentType } = require('./component-types');
8
+
9
+ /**
10
+ * Mapping from MCP server names to their component type and provider.
11
+ * This allows skills that reference MCP servers directly to work
12
+ * with the new component architecture.
13
+ */
14
+ const McpServerMapping = Object.freeze({
15
+ // Log Service
16
+ 'friday-sls-logs': {
17
+ type: ComponentType.LOG_SERVICE,
18
+ provider: 'aliyun-sls',
19
+ description: 'Alibaba Cloud SLS log queries'
20
+ },
21
+
22
+ // Database Manager
23
+ 'aliyun-dms-mcp-server': {
24
+ type: ComponentType.DATABASE_MANAGER,
25
+ provider: 'aliyun-dms',
26
+ description: 'Alibaba Cloud DMS database management'
27
+ },
28
+
29
+ // Database Query
30
+ 'friday-rds-redis-query': {
31
+ type: ComponentType.DATABASE_QUERY,
32
+ provider: 'aliyun-rds-query',
33
+ description: 'Direct database and Redis querying'
34
+ },
35
+
36
+ // Redis Monitor
37
+ 'friday-aliyun-sz-rds-redis': {
38
+ type: ComponentType.REDIS_MONITOR,
39
+ provider: 'aliyun-redis',
40
+ description: 'Alibaba Cloud Redis monitoring via Prometheus'
41
+ },
42
+
43
+ // API Documentation
44
+ 'aomi-yapi-mcp': {
45
+ type: ComponentType.API_DOC,
46
+ provider: 'yapi',
47
+ description: 'YApi API documentation management'
48
+ },
49
+
50
+ // Knowledge Base
51
+ 'aomi-yuque-mcp': {
52
+ type: ComponentType.KNOWLEDGE_BASE,
53
+ provider: 'yuque',
54
+ description: 'Yuque knowledge base management'
55
+ },
56
+
57
+ // Workflow
58
+ 'friday-auto-flow': {
59
+ type: ComponentType.WORKFLOW,
60
+ provider: 'friday-flow',
61
+ description: 'Friday automated workflow and pipeline management'
62
+ },
63
+
64
+ // Report
65
+ 'friday-auto-report': {
66
+ type: ComponentType.REPORT,
67
+ provider: 'friday-report',
68
+ description: 'Friday automated test and coverage reporting'
69
+ }
70
+ });
71
+
72
+ /**
73
+ * Reverse mapping: from (componentType, provider) to MCP server name.
74
+ */
75
+ const ProviderToMcp = Object.freeze({
76
+ 'logService:aliyun-sls': 'friday-sls-logs',
77
+ 'databaseManager:aliyun-dms': 'aliyun-dms-mcp-server',
78
+ 'databaseQuery:aliyun-rds-query': 'friday-rds-redis-query',
79
+ 'redisMonitor:aliyun-redis': 'friday-aliyun-sz-rds-redis',
80
+ 'apiDoc:yapi': 'aomi-yapi-mcp',
81
+ 'knowledgeBase:yuque': 'aomi-yuque-mcp',
82
+ 'workflow:friday-flow': 'friday-auto-flow',
83
+ 'report:friday-report': 'friday-auto-report'
84
+ });
85
+
86
+ class McpCompatibility {
87
+ /**
88
+ * Resolve an MCP server name to its component type and provider.
89
+ * @param {string} mcpServerName
90
+ * @returns {object|null} - { type, provider, description }
91
+ */
92
+ static resolve(mcpServerName) {
93
+ return McpServerMapping[mcpServerName] || null;
94
+ }
95
+
96
+ /**
97
+ * Get the MCP server name for a component type and provider.
98
+ * @param {string} componentType
99
+ * @param {string} provider
100
+ * @returns {string|null}
101
+ */
102
+ static getMcpServer(componentType, provider) {
103
+ const key = `${componentType}:${provider}`;
104
+ return ProviderToMcp[key] || null;
105
+ }
106
+
107
+ /**
108
+ * Get all known MCP server names.
109
+ * @returns {string[]}
110
+ */
111
+ static getAllMcpServers() {
112
+ return Object.keys(McpServerMapping);
113
+ }
114
+
115
+ /**
116
+ * Check if an MCP server name is known.
117
+ * @param {string} mcpServerName
118
+ * @returns {boolean}
119
+ */
120
+ static isKnown(mcpServerName) {
121
+ return mcpServerName in McpServerMapping;
122
+ }
123
+
124
+ /**
125
+ * Get the component type for an MCP server.
126
+ * @param {string} mcpServerName
127
+ * @returns {string|null}
128
+ */
129
+ static getType(mcpServerName) {
130
+ const mapping = McpServerMapping[mcpServerName];
131
+ return mapping ? mapping.type : null;
132
+ }
133
+
134
+ /**
135
+ * Get all mappings for a given component type.
136
+ * @param {string} componentType
137
+ * @returns {object[]}
138
+ */
139
+ static getByType(componentType) {
140
+ const results = [];
141
+ for (const [server, mapping] of Object.entries(McpServerMapping)) {
142
+ if (mapping.type === componentType) {
143
+ results.push({ mcpServer: server, ...mapping });
144
+ }
145
+ }
146
+ return results;
147
+ }
148
+ }
149
+
150
+ module.exports = McpCompatibility;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Aliyun DMS Database Manager Adapter
3
+ * Wraps the aliyun-dms-mcp-server MCP server for database management
4
+ */
5
+
6
+ const DatabaseManagerAdapter = require('../../adapters/database-manager-adapter');
7
+
8
+ class AliyunDmsAdapter extends DatabaseManagerAdapter {
9
+ constructor(config = {}) {
10
+ super('aliyun-dms', config);
11
+
12
+ // Register MCP tool mappings
13
+ this.registerTool('listInstances', 'listInstances');
14
+ this.registerTool('searchDatabase', 'searchDatabase');
15
+ this.registerTool('getDatabase', 'getDatabase');
16
+ this.registerTool('listTables', 'listTables');
17
+ this.registerTool('getTableDetailInfo', 'getTableDetailInfo');
18
+ this.registerTool('executeScript', 'executeScript');
19
+ this.registerTool('createDataChangeOrder', 'createDataChangeOrder');
20
+ this.registerTool('generateSql', 'generateSql');
21
+ this.registerTool('optimizeSql', 'optimizeSql');
22
+ this.registerTool('fixSql', 'fixSql');
23
+ }
24
+
25
+ get mcpServer() {
26
+ return 'aliyun-dms-mcp-server';
27
+ }
28
+
29
+ async listInstances(params) {
30
+ return {
31
+ mcpServer: this.mcpServer,
32
+ tool: this.resolveTool('listInstances'),
33
+ params: params || {}
34
+ };
35
+ }
36
+
37
+ async executeScript(params) {
38
+ return {
39
+ mcpServer: this.mcpServer,
40
+ tool: this.resolveTool('executeScript'),
41
+ params
42
+ };
43
+ }
44
+
45
+ async searchDatabase(searchKey) {
46
+ return {
47
+ mcpServer: this.mcpServer,
48
+ tool: this.resolveTool('searchDatabase'),
49
+ params: { search_key: searchKey }
50
+ };
51
+ }
52
+
53
+ async listTables(databaseId) {
54
+ return {
55
+ mcpServer: this.mcpServer,
56
+ tool: this.resolveTool('listTables'),
57
+ params: { database_id: databaseId }
58
+ };
59
+ }
60
+
61
+ async getTableDetail(tableGuid) {
62
+ return {
63
+ mcpServer: this.mcpServer,
64
+ tool: this.resolveTool('getTableDetailInfo'),
65
+ params: { table_guid: tableGuid }
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Generate SQL from natural language.
71
+ * @param {string} databaseId
72
+ * @param {string} question
73
+ * @returns {Promise<object>}
74
+ */
75
+ async generateSql(databaseId, question) {
76
+ return {
77
+ mcpServer: this.mcpServer,
78
+ tool: this.resolveTool('generateSql'),
79
+ params: { database_id: databaseId, question }
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Optimize a SQL statement.
85
+ * @param {string} databaseId
86
+ * @param {string} sql
87
+ * @returns {Promise<object>}
88
+ */
89
+ async optimizeSql(databaseId, sql) {
90
+ return {
91
+ mcpServer: this.mcpServer,
92
+ tool: this.resolveTool('optimizeSql'),
93
+ params: { database_id: databaseId, sql }
94
+ };
95
+ }
96
+ }
97
+
98
+ module.exports = AliyunDmsAdapter;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Aliyun Redis Monitor Adapter
3
+ * Wraps the friday-aliyun-sz-rds-redis MCP server for Redis monitoring via Prometheus
4
+ */
5
+
6
+ const McpAdapter = require('../../adapters/mcp-adapter');
7
+ const { ComponentType } = require('../../component-types');
8
+
9
+ class AliyunRedisAdapter extends McpAdapter {
10
+ constructor(config = {}) {
11
+ super('aliyun-redis', config);
12
+
13
+ // Register MCP tool mappings
14
+ this.registerTool('query', 'query');
15
+ this.registerTool('queryRange', 'queryRange');
16
+ this.registerTool('getLabelNames', 'getLabelNames');
17
+ this.registerTool('getLabelValues', 'getLabelValues');
18
+ this.registerTool('getSeries', 'getSeries');
19
+ this.registerTool('getMetadata', 'getMetadata');
20
+ }
21
+
22
+ get componentType() {
23
+ return ComponentType.REDIS_MONITOR;
24
+ }
25
+
26
+ get mcpServer() {
27
+ return 'friday-aliyun-sz-rds-redis';
28
+ }
29
+
30
+ /**
31
+ * Query Prometheus metrics at a point in time.
32
+ * @param {string} query - PromQL expression
33
+ * @param {string} time - Optional evaluation timestamp
34
+ * @returns {Promise<object>}
35
+ */
36
+ async query(query, time) {
37
+ return {
38
+ mcpServer: this.mcpServer,
39
+ tool: this.resolveTool('query'),
40
+ params: { query, time }
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Query Prometheus metrics over a time range.
46
+ * @param {string} query - PromQL expression
47
+ * @param {string} start
48
+ * @param {string} end
49
+ * @param {string} step
50
+ * @returns {Promise<object>}
51
+ */
52
+ async queryRange(query, start, end, step) {
53
+ return {
54
+ mcpServer: this.mcpServer,
55
+ tool: this.resolveTool('queryRange'),
56
+ params: { query, start, end, step }
57
+ };
58
+ }
59
+
60
+ /**
61
+ * Get available label names.
62
+ * @param {object} params
63
+ * @returns {Promise<object>}
64
+ */
65
+ async getLabelNames(params) {
66
+ return {
67
+ mcpServer: this.mcpServer,
68
+ tool: this.resolveTool('getLabelNames'),
69
+ params: params || {}
70
+ };
71
+ }
72
+
73
+ /**
74
+ * Get values for a specific label.
75
+ * @param {string} name - Label name
76
+ * @param {object} params
77
+ * @returns {Promise<object>}
78
+ */
79
+ async getLabelValues(name, params) {
80
+ return {
81
+ mcpServer: this.mcpServer,
82
+ tool: this.resolveTool('getLabelValues'),
83
+ params: { name, ...(params || {}) }
84
+ };
85
+ }
86
+ }
87
+
88
+ module.exports = AliyunRedisAdapter;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Aliyun SLS Log Service Adapter
3
+ * Wraps the friday-sls-logs MCP server for Alibaba Cloud SLS queries
4
+ */
5
+
6
+ const LogServiceAdapter = require('../../adapters/log-service-adapter');
7
+
8
+ class AliyunSlsAdapter extends LogServiceAdapter {
9
+ constructor(config = {}) {
10
+ super('aliyun-sls', config);
11
+
12
+ // Register MCP tool mappings
13
+ this.registerTool('queryLogs', 'queryLogs');
14
+ this.registerTool('listProject', 'listProject');
15
+ }
16
+
17
+ get mcpServer() {
18
+ return 'friday-sls-logs';
19
+ }
20
+
21
+ /**
22
+ * Get SLS endpoints from config.
23
+ * Falls back to default endpoints if not configured.
24
+ */
25
+ getEndpoints() {
26
+ if (this.config.config && this.config.config.endpoints) {
27
+ return this.config.config.endpoints;
28
+ }
29
+ return {
30
+ test: 'cn-shenzhen.log.aliyuncs.com',
31
+ prod: 'cn-hongkong.log.aliyuncs.com'
32
+ };
33
+ }
34
+
35
+ /**
36
+ * Get the endpoint for a given environment.
37
+ * @param {string} env - 'test', 'uat', 'gray', 'prod'
38
+ * @returns {string}
39
+ */
40
+ getEndpoint(env) {
41
+ const endpoints = this.getEndpoints();
42
+ // uat maps to test, gray maps to prod
43
+ const envMap = { uat: 'test', gray: 'prod' };
44
+ const mappedEnv = envMap[env] || env;
45
+ return endpoints[mappedEnv] || endpoints.test;
46
+ }
47
+
48
+ async queryLogs(params) {
49
+ return {
50
+ mcpServer: this.mcpServer,
51
+ tool: this.resolveTool('queryLogs'),
52
+ params
53
+ };
54
+ }
55
+
56
+ async listProjects() {
57
+ return {
58
+ mcpServer: this.mcpServer,
59
+ tool: this.resolveTool('listProject'),
60
+ params: {}
61
+ };
62
+ }
63
+
64
+ /**
65
+ * Build query parameters for SLS log query.
66
+ * @param {object} params
67
+ * @returns {object} MCP-compatible parameters
68
+ */
69
+ buildQueryParams(params) {
70
+ const { project, logstore, query, from, to, line = 100, env } = params;
71
+ const endpoint = this.getEndpoint(env || 'test');
72
+
73
+ return {
74
+ endpoint,
75
+ project: project || this.config.config?.defaultProject,
76
+ logstore: logstore || this.config.config?.defaultLogstore,
77
+ query: query || '',
78
+ from,
79
+ to,
80
+ line,
81
+ reverse: true
82
+ };
83
+ }
84
+ }
85
+
86
+ module.exports = AliyunSlsAdapter;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Friday Workflow Adapter
3
+ * Wraps the friday-auto-flow MCP server for workflow and pipeline management
4
+ */
5
+
6
+ const WorkflowAdapter = require('../../adapters/workflow-adapter');
7
+
8
+ class FridayFlowAdapter extends WorkflowAdapter {
9
+ constructor(config = {}) {
10
+ super('friday-flow', config);
11
+
12
+ // Register MCP tool mappings
13
+ this.registerTool('listPipelineGroups', 'flowListPipelineGroups');
14
+ this.registerTool('getPipelineGroup', 'flowGetPipelineGroup');
15
+ this.registerTool('listPipelineGroupPipelines', 'flowListPipelineGroupPipelines');
16
+ this.registerTool('listPipelines', 'flowListPipelines');
17
+ this.registerTool('getPipeline', 'flowGetPipeline');
18
+ this.registerTool('startPipelineRun', 'flowStartPipelineRun');
19
+ this.registerTool('startBatchPipelineRun', 'flowStartBatchPipelineRun');
20
+ this.registerTool('getPipelineRun', 'flowGetPipelineRun');
21
+ this.registerTool('listPipelineRuns', 'flowListPipelineRuns');
22
+ this.registerTool('stopPipelineRun', 'flowStopPipelineRun');
23
+ this.registerTool('retryPipelineJobRun', 'flowRetryPipelineJobRun');
24
+ this.registerTool('stopPipelineJobRun', 'flowStopPipelineJobRun');
25
+ this.registerTool('skipPipelineJobRun', 'flowSkipPipelineJobRun');
26
+ this.registerTool('logPipelineJobRun', 'flowLogPipelineJobRun');
27
+ this.registerTool('passPipelineValidate', 'flowPassPipelineValidate');
28
+ this.registerTool('refusePipelineValidate', 'flowRefusePipelineValidate');
29
+
30
+ // Order/task tools
31
+ this.registerTool('orderList', 'orderList');
32
+ this.registerTool('getOrderInfo', 'getOrderInfoByOrderId');
33
+ this.registerTool('getProcessJson', 'getProcessJson');
34
+ this.registerTool('demandPoolList', 'demandPoolList');
35
+ this.registerTool('getAllTaskList', 'getAllTaskList');
36
+ this.registerTool('getCurrentIterate', 'getCurrentIterate');
37
+ this.registerTool('iterateList', 'iterateList');
38
+ }
39
+
40
+ get mcpServer() {
41
+ return 'friday-auto-flow';
42
+ }
43
+
44
+ async listPipelineGroups(params) {
45
+ return {
46
+ mcpServer: this.mcpServer,
47
+ tool: this.resolveTool('listPipelineGroups'),
48
+ params: params || { perPage: '20', page: '1' }
49
+ };
50
+ }
51
+
52
+ async listPipelines(params) {
53
+ return {
54
+ mcpServer: this.mcpServer,
55
+ tool: this.resolveTool('listPipelines'),
56
+ params: params || {}
57
+ };
58
+ }
59
+
60
+ async startPipelineRun(pipelineId) {
61
+ return {
62
+ mcpServer: this.mcpServer,
63
+ tool: this.resolveTool('startPipelineRun'),
64
+ params: { pipelineId }
65
+ };
66
+ }
67
+
68
+ async getPipelineRun(pipelineId, runId) {
69
+ return {
70
+ mcpServer: this.mcpServer,
71
+ tool: this.resolveTool('getPipelineRun'),
72
+ params: { pipelineId, pipelineRunId: runId }
73
+ };
74
+ }
75
+
76
+ async listPipelineRuns(pipelineId, params) {
77
+ return {
78
+ mcpServer: this.mcpServer,
79
+ tool: this.resolveTool('listPipelineRuns'),
80
+ params: { pipelineId, ...(params || {}) }
81
+ };
82
+ }
83
+ }
84
+
85
+ module.exports = FridayFlowAdapter;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Friday Report Adapter
3
+ * Wraps the friday-auto-report MCP server for Jenkins builds and test reports
4
+ */
5
+
6
+ const ReportAdapter = require('../../adapters/report-adapter');
7
+
8
+ class FridayReportAdapter extends ReportAdapter {
9
+ constructor(config = {}) {
10
+ super('friday-report', config);
11
+
12
+ // Register MCP tool mappings
13
+ this.registerTool('listBuilds', 'listJenkinsBuilds');
14
+ this.registerTool('getBuildInfo', 'getJenkinsBuild');
15
+ this.registerTool('getBuildText', 'getJenkinsBuildText');
16
+ this.registerTool('replayBuild', 'replayJenkinsBuild');
17
+ this.registerTool('stopBuild', 'stopJenkinsBuild');
18
+ this.registerTool('listJobs', 'listJenkinsJobs');
19
+ this.registerTool('getJobDetails', 'getJenkinsJobDetails');
20
+ this.registerTool('getJobNames', 'getJenkinsJobNames');
21
+ this.registerTool('getViews', 'getJenkinsView');
22
+ this.registerTool('buildCounts', 'getJenkinsBuildCounts');
23
+ this.registerTool('getLastJobBuild', 'getLastJobBuild');
24
+ this.registerTool('buildJenkinsJob', 'buildJenkinsJob');
25
+
26
+ // Jacoco coverage tools
27
+ this.registerTool('listJacoco', 'listJacoco');
28
+ this.registerTool('listJacocoUnit', 'listJacocoUnit');
29
+ this.registerTool('createJacocoReport', 'creatJacocoReport');
30
+ this.registerTool('createUnitReport', 'creatUnitReport');
31
+
32
+ // Git tools
33
+ this.registerTool('getBranches', 'getBranches');
34
+ this.registerTool('getCommits', 'getCommits');
35
+ this.registerTool('getSingleCommits', 'getSingleCommits');
36
+ }
37
+
38
+ get mcpServer() {
39
+ return 'friday-auto-report';
40
+ }
41
+
42
+ async listBuilds(params) {
43
+ return {
44
+ mcpServer: this.mcpServer,
45
+ tool: this.resolveTool('listBuilds'),
46
+ params: params || {}
47
+ };
48
+ }
49
+
50
+ async getBuildInfo(buildId) {
51
+ return {
52
+ mcpServer: this.mcpServer,
53
+ tool: this.resolveTool('getBuildInfo'),
54
+ params: { id: buildId }
55
+ };
56
+ }
57
+
58
+ async listJacocoReports(params) {
59
+ return {
60
+ mcpServer: this.mcpServer,
61
+ tool: this.resolveTool('listJacoco'),
62
+ params: params || {}
63
+ };
64
+ }
65
+
66
+ async listUnitReports(params) {
67
+ return {
68
+ mcpServer: this.mcpServer,
69
+ tool: this.resolveTool('listJacocoUnit'),
70
+ params: params || {}
71
+ };
72
+ }
73
+
74
+ async getJobDetails(jobName) {
75
+ return {
76
+ mcpServer: this.mcpServer,
77
+ tool: this.resolveTool('getJobDetails'),
78
+ params: { jobName }
79
+ };
80
+ }
81
+ }
82
+
83
+ module.exports = FridayReportAdapter;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * YApi API Documentation Adapter
3
+ * Wraps the aomi-yapi-mcp MCP server for YApi platform management
4
+ */
5
+
6
+ const ApiDocAdapter = require('../../adapters/api-doc-adapter');
7
+
8
+ class YapiAdapter extends ApiDocAdapter {
9
+ constructor(config = {}) {
10
+ super('yapi', config);
11
+
12
+ // Register MCP tool mappings
13
+ this.registerTool('searchApis', 'yapi_search_apis');
14
+ this.registerTool('getCategories', 'yapi_get_categories');
15
+ this.registerTool('saveApi', 'yapi_save_api');
16
+ this.registerTool('getApiDesc', 'yapi_get_api_desc');
17
+ this.registerTool('importSwagger', 'yapi_import_swagger');
18
+ this.registerTool('exportProject', 'yapi_export_project');
19
+ this.registerTool('listProjects', 'yapi_list_projects');
20
+ this.registerTool('createCategory', 'yapi_create_category');
21
+ this.registerTool('deleteInterface', 'yapi_delete_interface');
22
+ this.registerTool('copyInterface', 'yapi_copy_interface');
23
+ this.registerTool('refreshCache', 'yapi_refresh_cache');
24
+ }
25
+
26
+ get mcpServer() {
27
+ return 'aomi-yapi-mcp';
28
+ }
29
+
30
+ async searchApis(params) {
31
+ return {
32
+ mcpServer: this.mcpServer,
33
+ tool: this.resolveTool('searchApis'),
34
+ params
35
+ };
36
+ }
37
+
38
+ async getCategories(projectId) {
39
+ return {
40
+ mcpServer: this.mcpServer,
41
+ tool: this.resolveTool('getCategories'),
42
+ params: { projectId }
43
+ };
44
+ }
45
+
46
+ async saveApi(apiData) {
47
+ return {
48
+ mcpServer: this.mcpServer,
49
+ tool: this.resolveTool('saveApi'),
50
+ params: apiData
51
+ };
52
+ }
53
+
54
+ async importSwagger(projectId, catId, swaggerData) {
55
+ return {
56
+ mcpServer: this.mcpServer,
57
+ tool: this.resolveTool('importSwagger'),
58
+ params: { projectId, catId, swaggerData }
59
+ };
60
+ }
61
+
62
+ async exportProject(projectId, type = 'swagger') {
63
+ return {
64
+ mcpServer: this.mcpServer,
65
+ tool: this.resolveTool('exportProject'),
66
+ params: { projectId, type }
67
+ };
68
+ }
69
+
70
+ async listProjects() {
71
+ return {
72
+ mcpServer: this.mcpServer,
73
+ tool: this.resolveTool('listProjects'),
74
+ params: {}
75
+ };
76
+ }
77
+ }
78
+
79
+ module.exports = YapiAdapter;