@draftt-io/draftt-mcp 1.1.2 → 1.2.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 +23 -29
- package/dist/api/drafttClient.d.ts +2 -0
- package/dist/api/drafttClient.js +6 -0
- package/dist/api/drafttClient.js.map +1 -1
- package/dist/api/responseFormatter.d.ts +6 -6
- package/dist/api/responseFormatter.js +7 -160
- package/dist/api/responseFormatter.js.map +1 -1
- package/dist/handlers/policyHandler.d.ts +8 -0
- package/dist/handlers/policyHandler.js +16 -0
- package/dist/handlers/policyHandler.js.map +1 -1
- package/dist/index.js +23 -166
- package/dist/index.js.map +1 -1
- package/dist/models/policyK8sComponent.d.ts +12 -0
- package/dist/{interfaces/component.js → models/policyK8sComponent.js} +1 -1
- package/dist/models/policyK8sComponent.js.map +1 -0
- package/dist/schemas/componentSchema.d.ts +480 -470
- package/dist/schemas/componentSchema.js +202 -117
- package/dist/schemas/componentSchema.js.map +1 -1
- package/dist/schemas/drafttSchema.d.ts +10 -14
- package/dist/schemas/drafttSchema.js +6 -6
- package/dist/schemas/drafttSchema.js.map +1 -1
- package/dist/schemas/policySchema.d.ts +64 -233
- package/dist/schemas/policySchema.js +54 -54
- package/dist/schemas/policySchema.js.map +1 -1
- package/dist/server/serverFactory.d.ts +8 -0
- package/dist/server/serverFactory.js +122 -0
- package/dist/server/serverFactory.js.map +1 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +7 -8
- package/dist/drafttClient.d.ts +0 -17
- package/dist/drafttClient.js +0 -187
- package/dist/drafttClient.js.map +0 -1
- package/dist/helpers/constants.d.ts +0 -31
- package/dist/helpers/constants.js +0 -37
- package/dist/helpers/constants.js.map +0 -1
- package/dist/interfaces/component.d.ts +0 -60
- package/dist/interfaces/component.js.map +0 -1
- package/dist/interfaces/draftt.d.ts +0 -3
- package/dist/interfaces/draftt.js +0 -3
- package/dist/interfaces/draftt.js.map +0 -1
- package/dist/interfaces/policy.d.ts +0 -21
- package/dist/interfaces/policy.js +0 -3
- package/dist/interfaces/policy.js.map +0 -1
- package/dist/mcp-server-sse.d.ts +0 -2
- package/dist/mcp-server-sse.js +0 -151
- package/dist/mcp-server-sse.js.map +0 -1
- package/dist/tools.d.ts +0 -6
- package/dist/tools.js +0 -277
- package/dist/tools.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,9 +15,10 @@ This server connects agents to Draftt's component and policy management API thro
|
|
|
15
15
|
* `draftt_component_get`: Get a specific component by ID
|
|
16
16
|
* `draftt_policy_search`: Search for policies with various filters
|
|
17
17
|
* `draftt_policy_get`: Get a specific policy by ID
|
|
18
|
-
* `
|
|
19
|
-
* `
|
|
20
|
-
* `
|
|
18
|
+
* `draftt_policy_component_get`: Get a specific component within a policy
|
|
19
|
+
* `draftt_policy_component_query`: Advanced query for policy components with DrafttQL filtering
|
|
20
|
+
* `draftt_policy_k8s_component_query`: Advanced query for Kubernetes policy components with DrafttQL filtering
|
|
21
|
+
* `draftt_upgrade_guide(draftt)_get`: Get a draftt upgrade guide for k8s components
|
|
21
22
|
|
|
22
23
|
## Prerequisites
|
|
23
24
|
|
|
@@ -33,9 +34,6 @@ The server supports configuration through environment variables. Create a `.env`
|
|
|
33
34
|
DRAFTT_ACCESS_KEY=your_draftt_access_key_here
|
|
34
35
|
DRAFTT_API_BASE_URL=https://api.draftt.io/v1
|
|
35
36
|
|
|
36
|
-
# MCP Transport Configuration
|
|
37
|
-
MCP_TRANSPORT=stdio
|
|
38
|
-
|
|
39
37
|
# Debug Configuration
|
|
40
38
|
DEBUG=false
|
|
41
39
|
```
|
|
@@ -46,14 +44,16 @@ DEBUG=false
|
|
|
46
44
|
- `DRAFTT_API_BASE_URL`: Draftt API base URL (default: `https://api.draftt.io/v1`)
|
|
47
45
|
- `DEBUG`: Enable debug logging (default: `false`)
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
### CLI Flags
|
|
50
48
|
|
|
51
|
-
You can
|
|
49
|
+
You can also pass configuration via command-line flags:
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
- `--access-key`: Your Draftt API access key (alternative to `DRAFTT_ACCESS_KEY` env var)
|
|
52
|
+
- `--debug`: Enable debug logging (alternative to `DEBUG=true` env var)
|
|
53
|
+
|
|
54
|
+
## Installation & Setup
|
|
55
55
|
|
|
56
|
-
### Using npx
|
|
56
|
+
### Using npx (Recommended)
|
|
57
57
|
|
|
58
58
|
```json
|
|
59
59
|
{
|
|
@@ -109,7 +109,7 @@ The server provides human-readable summaries for component data instead of raw J
|
|
|
109
109
|
|
|
110
110
|
### Prerequisites
|
|
111
111
|
|
|
112
|
-
- Node.js
|
|
112
|
+
- Node.js 20+
|
|
113
113
|
- npm or yarn
|
|
114
114
|
|
|
115
115
|
### Setup
|
|
@@ -126,19 +126,11 @@ npm install
|
|
|
126
126
|
# Build the project
|
|
127
127
|
npm run build
|
|
128
128
|
|
|
129
|
-
#
|
|
130
|
-
npm run lint
|
|
131
|
-
npm run lint:fix
|
|
132
|
-
|
|
133
|
-
# Format code
|
|
134
|
-
npm run format
|
|
135
|
-
npm run format:check
|
|
136
|
-
|
|
137
|
-
# Test schema compilation
|
|
138
|
-
npm run test:schemas
|
|
139
|
-
|
|
140
|
-
# Start in development
|
|
129
|
+
# Start the server (requires built dist/)
|
|
141
130
|
npm start
|
|
131
|
+
|
|
132
|
+
# Start in development mode
|
|
133
|
+
npm run dev
|
|
142
134
|
```
|
|
143
135
|
|
|
144
136
|
### Project Structure
|
|
@@ -149,10 +141,12 @@ The server uses a modular architecture:
|
|
|
149
141
|
src/
|
|
150
142
|
├── api/ # API client layer with timeout support
|
|
151
143
|
├── handlers/ # Request handlers with enhanced formatting
|
|
152
|
-
├── models/
|
|
153
|
-
├── schemas/
|
|
154
|
-
├──
|
|
155
|
-
|
|
144
|
+
├── models/ # Data models/interfaces
|
|
145
|
+
├── schemas/ # Zod validation schemas
|
|
146
|
+
├── server/ # Server implementations
|
|
147
|
+
│ └── serverFactory.ts # MCP server factory with tool registration
|
|
148
|
+
├── utils/ # Utility functions
|
|
149
|
+
└── index.ts # Entry point
|
|
156
150
|
```
|
|
157
151
|
|
|
158
152
|
## Example Questions
|
|
@@ -183,4 +177,4 @@ MIT
|
|
|
183
177
|
* Verify your Draftt access key is valid
|
|
184
178
|
* Check docker/npx logs for error messages
|
|
185
179
|
* Verify network connectivity to the Draftt API
|
|
186
|
-
* Check the debug logs by setting `DEBUG=true`
|
|
180
|
+
* Check the debug logs by setting `DEBUG=true`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiClient, Logger } from "./client";
|
|
2
2
|
import { ComponentGetArgs, ComponentSearchArgs, PolicyComponentGetArgs, PolicyComponentQueryArgs } from "../models/component";
|
|
3
3
|
import { DrafttGetArgs, DrafttQueryArgs } from "../models/draftt";
|
|
4
|
+
import { PolicyK8sComponentQueryArgs } from "../models/policyK8sComponent";
|
|
4
5
|
import { PolicyGetArgs, PolicySearchArgs } from "../models/policy";
|
|
5
6
|
export declare class DrafttClient extends ApiClient {
|
|
6
7
|
private accessKey;
|
|
@@ -18,6 +19,7 @@ export declare class DrafttClient extends ApiClient {
|
|
|
18
19
|
policyComponentGet(args: PolicyComponentGetArgs): Promise<Record<string, unknown>>;
|
|
19
20
|
drafttGet(args: DrafttGetArgs): Promise<Record<string, unknown>>;
|
|
20
21
|
drafttQuery(args: DrafttQueryArgs): Promise<Record<string, unknown>>;
|
|
22
|
+
policyK8sComponentQuery(args: PolicyK8sComponentQueryArgs): Promise<Record<string, unknown>>;
|
|
21
23
|
private buildSearchBody;
|
|
22
24
|
private buildQueryBody;
|
|
23
25
|
}
|
package/dist/api/drafttClient.js
CHANGED
|
@@ -78,6 +78,12 @@ class DrafttClient extends client_1.ApiClient {
|
|
|
78
78
|
const requestBody = this.buildQueryBody(args);
|
|
79
79
|
return this.post(`/component/${args.componentId}/draftt/query`, requestBody);
|
|
80
80
|
}
|
|
81
|
+
async policyK8sComponentQuery(args) {
|
|
82
|
+
this.logger.debug("Policy k8s component query with args:", args);
|
|
83
|
+
const policyId = 3; // Hardcoded policy ID for k8s components
|
|
84
|
+
const requestBody = this.buildQueryBody(args);
|
|
85
|
+
return this.post(`/policy/${policyId}/k8sComponent/query`, requestBody);
|
|
86
|
+
}
|
|
81
87
|
buildSearchBody(args) {
|
|
82
88
|
const searchBody = {};
|
|
83
89
|
// Skip undefined values to keep the request payload clean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafttClient.js","sourceRoot":"","sources":["../../src/api/drafttClient.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;
|
|
1
|
+
{"version":3,"file":"drafttClient.js","sourceRoot":"","sources":["../../src/api/drafttClient.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAU7C,qCAAoC;AAEpC,MAAa,YAAa,SAAQ,kBAAS;IAGvC,YAAY,MAAc,EAAE,SAAkB,EAAE,OAAgB;QAC5D,MAAM,MAAM,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAE1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,0BAA0B,CAAC;QAE9E,KAAK,CAAC;YACF,OAAO;YACP,MAAM;YACN,OAAO,EAAE,OAAO,IAAI,KAAK;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;IAC5B,CAAC;IAES,UAAU;QAChB,OAAO;YACH,aAAa,EAAE,UAAU,IAAI,CAAC,SAAS,EAAE;YACzC,cAAc,EAAE,kBAAkB;YAClC,gBAAgB,EAAE,YAAY;SACjC,CAAC;IACN,CAAC;IAGD,KAAK,CAAC,YAAY,CAAC,IAAsB;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE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S,CAAC;IACrB,CAAC;CACJ;AAjID,oCAiIC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
export declare function formatSuccessResponse(data: any): {
|
|
2
|
+
content: {
|
|
3
|
+
type: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
7
|
export declare function formatErrorResponse(code: string, message: string, details?: any): {
|
|
8
8
|
content: {
|
|
9
9
|
type: string;
|
|
@@ -1,174 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatComponentSummary = formatComponentSummary;
|
|
4
|
-
exports.formatPolicyComponentSummary = formatPolicyComponentSummary;
|
|
5
3
|
exports.formatSuccessResponse = formatSuccessResponse;
|
|
6
4
|
exports.formatErrorResponse = formatErrorResponse;
|
|
7
|
-
function
|
|
8
|
-
if (!component || typeof component !== "object") {
|
|
9
|
-
return JSON.stringify(component, null, 2);
|
|
10
|
-
}
|
|
11
|
-
const summary = {
|
|
12
|
-
id: component.id || component.componentId,
|
|
13
|
-
name: component.name,
|
|
14
|
-
type: component.type,
|
|
15
|
-
technology: component.technology,
|
|
16
|
-
currentVersion: component.version || component.currentVersion,
|
|
17
|
-
region: component.region,
|
|
18
|
-
status: component.status,
|
|
19
|
-
tags: component.tags,
|
|
20
|
-
};
|
|
21
|
-
let formattedSummary = `## Component Summary\n`;
|
|
22
|
-
if (summary.name)
|
|
23
|
-
formattedSummary += `**Name:** ${summary.name}\n`;
|
|
24
|
-
if (summary.type)
|
|
25
|
-
formattedSummary += `**Type:** ${summary.type}\n`;
|
|
26
|
-
if (summary.technology)
|
|
27
|
-
formattedSummary += `**Technology:** ${summary.technology}\n`;
|
|
28
|
-
if (summary.currentVersion)
|
|
29
|
-
formattedSummary += `**Current Version:** ${summary.currentVersion}\n`;
|
|
30
|
-
if (summary.region)
|
|
31
|
-
formattedSummary += `**Region:** ${summary.region}\n`;
|
|
32
|
-
if (summary.status)
|
|
33
|
-
formattedSummary += `**Status:** ${summary.status}\n`;
|
|
34
|
-
if (summary.tags && Object.keys(summary.tags).length > 0) {
|
|
35
|
-
formattedSummary += `**Tags:** ${Object.entries(summary.tags)
|
|
36
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
37
|
-
.join(", ")}\n`;
|
|
38
|
-
}
|
|
39
|
-
return formattedSummary;
|
|
40
|
-
}
|
|
41
|
-
function formatPolicyComponentSummary(policyComponent) {
|
|
42
|
-
if (!policyComponent || typeof policyComponent !== "object") {
|
|
43
|
-
return JSON.stringify(policyComponent, null, 2);
|
|
44
|
-
}
|
|
45
|
-
const summary = {
|
|
46
|
-
id: policyComponent.id || policyComponent.componentId,
|
|
47
|
-
name: policyComponent.name,
|
|
48
|
-
type: policyComponent.type,
|
|
49
|
-
technology: policyComponent.technology,
|
|
50
|
-
currentVersion: policyComponent.version || policyComponent.currentVersion,
|
|
51
|
-
region: policyComponent.region,
|
|
52
|
-
isCompliant: policyComponent.isCompliant,
|
|
53
|
-
recommendedVersion: policyComponent.recommendedVersion,
|
|
54
|
-
requiredVersion: policyComponent.requiredVersion,
|
|
55
|
-
desiredVersion: policyComponent.desiredVersion,
|
|
56
|
-
dueDate: policyComponent.dueDate,
|
|
57
|
-
urgency: policyComponent.urgency,
|
|
58
|
-
priority: policyComponent.priority,
|
|
59
|
-
tags: policyComponent.tags,
|
|
60
|
-
};
|
|
61
|
-
let formattedSummary = `## Policy Component Summary\n`;
|
|
62
|
-
if (summary.name)
|
|
63
|
-
formattedSummary += `**Component:** ${summary.name}\n`;
|
|
64
|
-
if (summary.type)
|
|
65
|
-
formattedSummary += `**Type:** ${summary.type}\n`;
|
|
66
|
-
if (summary.technology)
|
|
67
|
-
formattedSummary += `**Technology:** ${summary.technology}\n`;
|
|
68
|
-
if (summary.currentVersion)
|
|
69
|
-
formattedSummary += `**Current Version:** ${summary.currentVersion}\n`;
|
|
70
|
-
if (summary.isCompliant !== undefined) {
|
|
71
|
-
formattedSummary += `**Compliance Status:** ${summary.isCompliant ? "✅ Compliant" : "❌ Non-Compliant"}\n`;
|
|
72
|
-
}
|
|
73
|
-
if (summary.recommendedVersion)
|
|
74
|
-
formattedSummary += `**Recommended Version:** ${summary.recommendedVersion}\n`;
|
|
75
|
-
if (summary.requiredVersion)
|
|
76
|
-
formattedSummary += `**Required Version:** ${summary.requiredVersion}\n`;
|
|
77
|
-
if (summary.desiredVersion)
|
|
78
|
-
formattedSummary += `**Desired Version:** ${summary.desiredVersion}\n`;
|
|
79
|
-
if (summary.dueDate)
|
|
80
|
-
formattedSummary += `**Due Date:** ${summary.dueDate}\n`;
|
|
81
|
-
if (summary.urgency !== undefined)
|
|
82
|
-
formattedSummary += `**Urgency:** ${summary.urgency}\n`;
|
|
83
|
-
if (summary.priority !== undefined)
|
|
84
|
-
formattedSummary += `**Priority:** ${summary.priority}\n`;
|
|
85
|
-
if (summary.region)
|
|
86
|
-
formattedSummary += `**Region:** ${summary.region}\n`;
|
|
87
|
-
return formattedSummary;
|
|
88
|
-
}
|
|
89
|
-
function detectLargeJsonBlob(data) {
|
|
90
|
-
const jsonString = JSON.stringify(data);
|
|
91
|
-
return jsonString.length > 1000 || (Array.isArray(data) && data.length > 5);
|
|
92
|
-
}
|
|
93
|
-
function shouldSummarize(data, toolName) {
|
|
94
|
-
if (!toolName)
|
|
95
|
-
return false;
|
|
96
|
-
return (toolName.includes("component") &&
|
|
97
|
-
(detectLargeJsonBlob(data) || (typeof data === "object" && data !== null)));
|
|
98
|
-
}
|
|
99
|
-
function formatSuccessResponse(data, options) {
|
|
100
|
-
const { useSummary = true, toolName } = options || {};
|
|
101
|
-
if (!useSummary || !shouldSummarize(data, toolName)) {
|
|
102
|
-
return {
|
|
103
|
-
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (Array.isArray(data)) {
|
|
107
|
-
if (toolName?.includes("component_search") ||
|
|
108
|
-
toolName?.includes("policy_component_search")) {
|
|
109
|
-
const summaries = data
|
|
110
|
-
.map((item, index) => {
|
|
111
|
-
if (toolName.includes("policy_component")) {
|
|
112
|
-
return `### Component ${index + 1}\n${formatPolicyComponentSummary(item)}`;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return `### Component ${index + 1}\n${formatComponentSummary(item)}`;
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
.join("\n---\n");
|
|
119
|
-
const totalCount = data.length;
|
|
120
|
-
const header = `# Search Results (${totalCount} found)\n\n`;
|
|
121
|
-
return {
|
|
122
|
-
content: [
|
|
123
|
-
{
|
|
124
|
-
type: "text",
|
|
125
|
-
text: header +
|
|
126
|
-
summaries +
|
|
127
|
-
`\n\n*Note: Use raw JSON format if you need complete details.*`,
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else if (typeof data === "object" && data !== null) {
|
|
134
|
-
if (toolName?.includes("component_get")) {
|
|
135
|
-
return {
|
|
136
|
-
content: [
|
|
137
|
-
{
|
|
138
|
-
type: "text",
|
|
139
|
-
text: formatComponentSummary(data) +
|
|
140
|
-
`\n\n*Use raw JSON format if you need complete details.*`,
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
else if (toolName?.includes("policy_component_get")) {
|
|
146
|
-
return {
|
|
147
|
-
content: [
|
|
148
|
-
{
|
|
149
|
-
type: "text",
|
|
150
|
-
text: formatPolicyComponentSummary(data) +
|
|
151
|
-
`\n\n*Use raw JSON format if you need complete details.*`,
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
5
|
+
function formatSuccessResponse(data) {
|
|
157
6
|
return {
|
|
158
|
-
content: [{ type: "text", text: JSON.stringify(data
|
|
7
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
159
8
|
};
|
|
160
9
|
}
|
|
161
10
|
function formatErrorResponse(code, message, details) {
|
|
162
11
|
return {
|
|
163
|
-
content: [
|
|
164
|
-
{
|
|
12
|
+
content: [{
|
|
165
13
|
type: "text",
|
|
166
14
|
text: JSON.stringify({
|
|
167
|
-
error: { code, message, details }
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
isError: true,
|
|
15
|
+
error: { code, message, details }
|
|
16
|
+
})
|
|
17
|
+
}],
|
|
18
|
+
isError: true
|
|
172
19
|
};
|
|
173
20
|
}
|
|
174
21
|
//# sourceMappingURL=responseFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../src/api/responseFormatter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../src/api/responseFormatter.ts"],"names":[],"mappings":";;AAAA,sDAIC;AAED,kDAUC;AAhBD,SAAgB,qBAAqB,CAAC,IAAS;IAC3C,OAAO;QACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;KAC1D,CAAC;AACN,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,OAAe,EAAE,OAAa;IAC5E,OAAO;QACH,OAAO,EAAE,CAAC;gBACN,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACjB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;iBACpC,CAAC;aACL,CAAC;QACF,OAAO,EAAE,IAAI;KAChB,CAAC;AACN,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DrafttClient } from "../api/drafttClient";
|
|
2
2
|
import { PolicyComponentGetArgs, PolicyComponentQueryArgs } from "../models/component";
|
|
3
3
|
import { PolicyGetArgs, PolicySearchArgs } from "../models/policy";
|
|
4
|
+
import { PolicyK8sComponentQueryArgs } from "../models/policyK8sComponent";
|
|
4
5
|
export declare class PolicyHandler {
|
|
5
6
|
private client;
|
|
6
7
|
constructor(client: DrafttClient);
|
|
@@ -32,4 +33,11 @@ export declare class PolicyHandler {
|
|
|
32
33
|
text: string;
|
|
33
34
|
}[];
|
|
34
35
|
}>;
|
|
36
|
+
k8sComponentQuery(args: PolicyK8sComponentQueryArgs): Promise<{
|
|
37
|
+
isError?: boolean | undefined;
|
|
38
|
+
content: {
|
|
39
|
+
type: "text";
|
|
40
|
+
text: string;
|
|
41
|
+
}[];
|
|
42
|
+
}>;
|
|
35
43
|
}
|
|
@@ -84,6 +84,22 @@ class PolicyHandler {
|
|
|
84
84
|
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during policy component get: ${errorMessage}` } }, true);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
async k8sComponentQuery(args) {
|
|
88
|
+
const logger = (0, logger_1.getLogger)();
|
|
89
|
+
try {
|
|
90
|
+
logger.debug("Processing policy k8s component query with args:", args);
|
|
91
|
+
const result = await this.client.policyK8sComponentQuery(args);
|
|
92
|
+
return (0, json_1.createSafeResponse)(result);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
logger.error("Error in policy k8s component query:", error);
|
|
96
|
+
if (error instanceof client_1.ApiError) {
|
|
97
|
+
return (0, json_1.createSafeResponse)({ error: { code: error.code, message: error.message, details: error.details } }, true);
|
|
98
|
+
}
|
|
99
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
100
|
+
return (0, json_1.createSafeResponse)({ error: { code: "INTERNAL_ERROR", message: `Unexpected error during policy k8s component query: ${errorMessage}` } }, true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
87
103
|
}
|
|
88
104
|
exports.PolicyHandler = PolicyHandler;
|
|
89
105
|
//# sourceMappingURL=policyHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policyHandler.js","sourceRoot":"","sources":["../../src/handlers/policyHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;
|
|
1
|
+
{"version":3,"file":"policyHandler.js","sourceRoot":"","sources":["../../src/handlers/policyHandler.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AAIzC,4CAA4C;AAC5C,wCAAmD;AAEnD,MAAa,aAAa;IACtB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,MAAM,CAAC,IAAsB;QAC/B,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAE3B,IAAI,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,IAAI,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpD,OAAO,IAAA,yBAAkB,EAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAC/C,IAAI,KAAK,YAAY,iBAAQ,EAAE,CAAC;gBAC5B,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAC/E,IAAI,CACP,CAAC;YACN,CAAC;YACD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,g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,YAAY,EAAE,EAAE,EAAE,EAC/G,IAAI,CACP,CAAC;QACN,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAiC;QACrD,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAE3B,IAAI,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,kDAAkD,EAAE,IAAI,CAAC,CAAC;YAEvE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;YAC/D,OAAO,IAAA,yBAAkB,EAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC5D,IAAI,KAAK,YAAY,iBAAQ,EAAE,CAAC;gBAC5B,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAC/E,IAAI,CACP,CAAC;YACN,CAAC;YACD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,IAAA,yBAAkB,EACrB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,uDAAuD,YAAY,EAAE,EAAE,EAAE,EACrH,IAAI,CACP,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAvJD,sCAuJC"}
|
package/dist/index.js
CHANGED
|
@@ -5,181 +5,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
require("dotenv/config");
|
|
8
|
-
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
9
8
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
10
9
|
const minimist_1 = __importDefault(require("minimist"));
|
|
11
|
-
const drafttClient_1 = require("./api/drafttClient");
|
|
12
|
-
const componentHandler_1 = require("./handlers/componentHandler");
|
|
13
|
-
const policyHandler_1 = require("./handlers/policyHandler");
|
|
14
|
-
const drafttHandler_1 = require("./handlers/drafttHandler");
|
|
15
10
|
const logger_1 = require("./utils/logger");
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const drafttSchema_1 = require("./schemas/drafttSchema");
|
|
19
|
-
async function main() {
|
|
11
|
+
const serverFactory_1 = require("./server/serverFactory");
|
|
12
|
+
function parseConfig() {
|
|
20
13
|
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
21
|
-
const accessKey = argv[
|
|
22
|
-
const debug = argv[
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!accessKey) {
|
|
27
|
-
|
|
28
|
-
throw new Error("Missing access-key. Please provide one via --access-key or DRAFTT_ACCESS_KEY environment variable");
|
|
14
|
+
const accessKey = argv['access-key'] || process.env.DRAFTT_ACCESS_KEY;
|
|
15
|
+
const debug = argv['debug'] || process.env.DEBUG === 'true' || false;
|
|
16
|
+
return { accessKey, debug };
|
|
17
|
+
}
|
|
18
|
+
function validateConfig(config) {
|
|
19
|
+
if (!config.accessKey) {
|
|
20
|
+
throw new Error('Missing access-key. Provide via --access-key or DRAFTT_ACCESS_KEY environment variable');
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const drafttHandler = new drafttHandler_1.DrafttHandler(drafttClient);
|
|
36
|
-
// Create MCP server
|
|
37
|
-
const server = new mcp_js_1.McpServer({
|
|
38
|
-
name: "Draftt MCP Server",
|
|
39
|
-
version: "1.0.0",
|
|
40
|
-
});
|
|
41
|
-
// Register tools
|
|
42
|
-
server.tool("draftt_component_search", "Search and filter components in Draftt, component is a cloud asset with version, technology, type, etc. For example: EKS cluster, AWS Lambda, Azure Function, etc.", componentSchema_1.componentSearchSchema.shape, async (args) => {
|
|
43
|
-
try {
|
|
44
|
-
const validatedArgs = componentSchema_1.componentSearchSchema.parse(args);
|
|
45
|
-
const result = await componentHandler.search(validatedArgs);
|
|
46
|
-
return {
|
|
47
|
-
content: result.content
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
logger.error("Error in draftt_component_search:", error);
|
|
52
|
-
return {
|
|
53
|
-
content: [{
|
|
54
|
-
type: "text",
|
|
55
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
56
|
-
}]
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
server.tool("draftt_component_get", "Get a detailed information about a component in Draftt where you can get all the data about a component like: name, version, technology, type, etc.", componentSchema_1.componentGetSchema.shape, async (args) => {
|
|
61
|
-
try {
|
|
62
|
-
const validatedArgs = componentSchema_1.componentGetSchema.parse(args);
|
|
63
|
-
const result = await componentHandler.get(validatedArgs);
|
|
64
|
-
return {
|
|
65
|
-
content: result.content
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
logger.error("Error in draftt_component_get:", error);
|
|
70
|
-
return {
|
|
71
|
-
content: [{
|
|
72
|
-
type: "text",
|
|
73
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
74
|
-
}]
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
server.tool("draftt_policy_search", "Search for policies in Draftt(currently: EOL and Latest and Greatest), we're using policies for assessing specific rules for components, for example, a policy might indicate that a component reached end of life and needs to be updated.", policySchema_1.policySearchSchema.shape, async (args) => {
|
|
79
|
-
try {
|
|
80
|
-
const validatedArgs = policySchema_1.policySearchSchema.parse(args);
|
|
81
|
-
const result = await policyHandler.search(validatedArgs);
|
|
82
|
-
return {
|
|
83
|
-
content: result.content
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
logger.error("Error in draftt_policy_search:", error);
|
|
88
|
-
return {
|
|
89
|
-
content: [{
|
|
90
|
-
type: "text",
|
|
91
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
92
|
-
}]
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
server.tool("draftt_policy_get", "Get a detailed information about a policy in Draftt", policySchema_1.policyGetSchema.shape, async (args) => {
|
|
97
|
-
try {
|
|
98
|
-
const validatedArgs = policySchema_1.policyGetSchema.parse(args);
|
|
99
|
-
const result = await policyHandler.get(validatedArgs);
|
|
100
|
-
return {
|
|
101
|
-
content: result.content
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
logger.error("Error in draftt_policy_get:", error);
|
|
106
|
-
return {
|
|
107
|
-
content: [{
|
|
108
|
-
type: "text",
|
|
109
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
110
|
-
}]
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
server.tool("draftt_policy_component_get", "Get a analyzed information about a component meeting a draftt policy, for example: when an EKS cluster will reach end of life, what is the next version to upgrade to, etc.", componentSchema_1.policyComponentGetSchema.shape, async (args) => {
|
|
115
|
-
try {
|
|
116
|
-
const validatedArgs = componentSchema_1.policyComponentGetSchema.parse(args);
|
|
117
|
-
const result = await policyHandler.componentGet(validatedArgs);
|
|
118
|
-
return {
|
|
119
|
-
content: result.content
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
logger.error("Error in draftt_policy_component_get:", error);
|
|
124
|
-
return {
|
|
125
|
-
content: [{
|
|
126
|
-
type: "text",
|
|
127
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
128
|
-
}]
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
server.tool("draftt_policy_component_query", "Advanced query for policy components with rich filtering using operators like $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists. Supports tag filtering, pagination, field selection, and cost analysis. Policy components describe how components match specific policies (e.g., EOL status, compliance requirements).", componentSchema_1.policyComponentQuerySchema.shape, async (args) => {
|
|
133
|
-
try {
|
|
134
|
-
const validatedArgs = componentSchema_1.policyComponentQuerySchema.parse(args);
|
|
135
|
-
const result = await policyHandler.componentQuery(validatedArgs);
|
|
136
|
-
return {
|
|
137
|
-
content: result.content
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
logger.error("Error in draftt_policy_component_query:", error);
|
|
142
|
-
return {
|
|
143
|
-
content: [{
|
|
144
|
-
type: "text",
|
|
145
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
146
|
-
}]
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
server.tool("draftt_upgrade_guide(draftt)_get", "Get a draftt which in this context represents an upgrade guide. currently for a k8s components only, draftt is a step by step guide for upgrading a k8s component from one version to another, it includes couple of sections (nodes,images, API, etc.), we generating it for a components that integrated to our platform", drafttSchema_1.drafttQuerySchema.shape, async (args) => {
|
|
151
|
-
try {
|
|
152
|
-
const validatedArgs = drafttSchema_1.drafttQuerySchema.parse(args);
|
|
153
|
-
const result = await drafttHandler.query(validatedArgs);
|
|
154
|
-
return {
|
|
155
|
-
content: result.content
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
logger.error("Error in draftt_query:", error);
|
|
160
|
-
return {
|
|
161
|
-
content: [{
|
|
162
|
-
type: "text",
|
|
163
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
|
|
164
|
-
}]
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
// Connect to transport
|
|
22
|
+
}
|
|
23
|
+
async function startServer(config) {
|
|
24
|
+
const logger = (0, logger_1.setupLogger)(config.debug);
|
|
25
|
+
logger.info('Starting Draftt MCP Server (stdio transport)...');
|
|
26
|
+
const server = (0, serverFactory_1.createMcpServer)(logger, config.accessKey);
|
|
169
27
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
170
|
-
logger.info(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
28
|
+
logger.info('Connecting server to stdio transport...');
|
|
29
|
+
await server.connect(transport);
|
|
30
|
+
logger.info('Server connected to stdio transport');
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
const config = parseConfig();
|
|
34
|
+
validateConfig(config);
|
|
35
|
+
await startServer(config);
|
|
179
36
|
}
|
|
180
37
|
main().catch((error) => {
|
|
181
38
|
const logger = (0, logger_1.getLogger)();
|
|
182
|
-
logger.error(
|
|
39
|
+
logger.error('Fatal error in main():', error);
|
|
183
40
|
process.exit(1);
|
|
184
41
|
});
|
|
185
42
|
//# sourceMappingURL=index.js.map
|