Skip to content

Commit 7d8637a

Browse files
committed
feat(mcp): add prompts
1 parent 356fc86 commit 7d8637a

File tree

3 files changed

+78
-46
lines changed

3 files changed

+78
-46
lines changed

src/index.ts

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ import {
4343
handleGeneralError,
4444
} from "./utils/util.js";
4545

46-
import {
47-
aws_global_resource_id,
48-
gcp_global_resource_id,
49-
} from "./utils/filterFields.js";
46+
import { prompts } from "./utils/prompts.js";
5047
import {
5148
listTicketsTool,
5249
handleListTicketsRequest,
@@ -102,48 +99,10 @@ function createServer() {
10299
// Handle prompts listing
103100
server.setRequestHandler(ListPromptsRequestSchema, async () => {
104101
return {
105-
prompts: [
106-
{
107-
text: `Filter fields explanation: ${gcp_global_resource_id}\n\n ${aws_global_resource_id}\n\n`,
108-
name: "Filter Fields Reference",
109-
},
110-
{
111-
text: `Create a document (Artifacts) with a table to display the report results. include insights and recommendations if possible. (Do not generate code, only a document)`,
112-
name: "Generate Report Document",
113-
},
114-
{
115-
text: `Before running a query, always check the filter fields explanation and dimensions.`,
116-
name: "Query Best Practice",
117-
},
118-
{
119-
text: `Do not generate code, only a document.`,
120-
name: "Document Output Reminder",
121-
},
122-
{
123-
text: `To create a cost report, first check if you need specific dimensions with:\nlist_dimensions(filter: "type:fixed")\n\nThen check if there is similar reports with list_reports and get_report_results. when you understand the structure Then run a query like:\nrun_query({\n config: {\n dataSource: "billing",\n metric: { type: "basic", value: "cost" },\n timeRange: { mode: "last", amount: 1, unit: "month", includeCurrent: true },\n group: [{ id: "service_description", type: "fixed", limit: { metric: { type: "basic", value: "cost" }, sort: "desc", value: 10 } }]\n }\n})`,
124-
name: "Generate Report Command",
125-
},
126-
{
127-
text: `Create a document (Artifacts) with a table to display the list of anomalies. Include the following columns: ID, Type, Status, Severity, Created At, and Description. Add insights and recommendations if available. (Do not generate code, only a document)`,
128-
name: "Generate Anomalies Document",
129-
},
130-
{
131-
text: `Use the list_dimensions tool to explore available dimensions. Select dimensions that best match your reporting needs. Combine multiple dimensions for more granular analysis, and always review the filter fields reference for optimal filtering.`,
132-
name: "Dimension Usage Guidance",
133-
},
134-
{
135-
text: `Before creating a ticket, ask the user if the ticket body is clear and if they want to add more details.`,
136-
name: "Create Ticket",
137-
},
138-
{
139-
text: `Create a document (Artifacts) with a table to display invoice details. Include the following columns: Invoice ID, Invoice Date, Due Date, Status, Total Amount, Balance Amount, Currency, and URL. For line items, create a separate table with columns: Description, Details, Price, Quantity, Type, and Currency. Add any relevant payment status or due date alerts. (Do not generate code, only a document)`,
140-
name: "Generate Invoice Details Document",
141-
},
142-
{
143-
text: `Tools results should use the Document artifact type if possible. You must never use the code artifact type or to analyze the results of a tool with code/javascript.`,
144-
name: "DoiT MCP Server tools output",
145-
},
146-
],
102+
prompts: prompts.map((prompt) => ({
103+
text: prompt.text,
104+
name: prompt.name,
105+
})),
147106
};
148107
});
149108

src/utils/prompts.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {
2+
aws_global_resource_id,
3+
gcp_global_resource_id,
4+
} from "./filterFields.js";
5+
6+
export const prompts = [
7+
{
8+
name: "Filter Fields Reference",
9+
description: "Filter fields explanation for GCP and AWS resources",
10+
text: `Filter fields explanation: ${gcp_global_resource_id}\n\n ${aws_global_resource_id}\n\n`,
11+
},
12+
{
13+
name: "Generate Report Document",
14+
description: "Generate a document with report results table",
15+
text: `Create a document (Artifacts) with a table to display the report results. include insights and recommendations if possible. (Do not generate code, only a document)`,
16+
},
17+
{
18+
name: "Query Best Practice",
19+
description: "Best practice reminder for running queries",
20+
text: `Before running a query, always check the filter fields explanation and dimensions.`,
21+
},
22+
{
23+
name: "Document Output Reminder",
24+
description: "Reminder to generate documents not code",
25+
text: `Do not generate code, only a document.`,
26+
},
27+
{
28+
name: "Generate Report Command",
29+
description: "Template for generating cost reports",
30+
text: `To create a cost report, first check if you need specific dimensions with:\nlist_dimensions(filter: "type:fixed")\n\nThen check if there is similar reports with list_reports and get_report_results. when you understand the structure Then run a query like:\nrun_query({\n config: {\n dataSource: "billing",\n metric: { type: "basic", value: "cost" },\n timeRange: { mode: "last", amount: 1, unit: "month", includeCurrent: true },\n group: [{ id: "service_description", type: "fixed", limit: { metric: { type: "basic", value: "cost" }, sort: "desc", value: 10 } }]\n }\n})`,
31+
},
32+
{
33+
name: "Generate Anomalies Document",
34+
description: "Generate a document with anomalies table",
35+
text: `Create a document (Artifacts) with a table to display the list of anomalies. Include the following columns: ID, Type, Status, Severity, Created At, and Description. Add insights and recommendations if available. (Do not generate code, only a document)`,
36+
},
37+
{
38+
name: "Dimension Usage Guidance",
39+
description: "Guidance for using dimensions effectively",
40+
text: `Use the list_dimensions tool to explore available dimensions. Select dimensions that best match your reporting needs. Combine multiple dimensions for more granular analysis, and always review the filter fields reference for optimal filtering.`,
41+
},
42+
{
43+
name: "Create Ticket",
44+
description: "Best practice for creating support tickets",
45+
text: `Before creating a ticket, ask the user if the ticket body is clear and if they want to add more details.`,
46+
},
47+
{
48+
name: "Generate Invoice Details Document",
49+
description: "Generate a document with invoice details table",
50+
text: `Create a document (Artifacts) with a table to display invoice details. Include the following columns: Invoice ID, Invoice Date, Due Date, Status, Total Amount, Balance Amount, Currency, and URL. For line items, create a separate table with columns: Description, Details, Price, Quantity, Type, and Currency. Add any relevant payment status or due date alerts. (Do not generate code, only a document)`,
51+
},
52+
{
53+
name: "DoiT MCP Server tools output",
54+
description: "Guidance for tool output formatting",
55+
text: `Tools results should use the Document artifact type if possible. You must never use the code artifact type or to analyze the results of a tool with code/javascript.`,
56+
},
57+
];

sse/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
handleGeneralError,
6868
zodSchemaToMcpTool,
6969
} from "../../src/utils/util.js";
70+
import { prompts } from "../../src/utils/prompts.js";
7071

7172
type Props = {
7273
bearerToken: string;
@@ -146,6 +147,21 @@ export class DoitMCP extends McpAgent<Env, State, Props> {
146147
process.env.CUSTOMER_CONTEXT = this.props.customerContext;
147148
}
148149

150+
// Register prompts
151+
prompts.forEach((prompt) => {
152+
this.server.prompt(prompt.name, prompt.description, async () => ({
153+
messages: [
154+
{
155+
role: "user",
156+
content: {
157+
type: "text",
158+
text: prompt.text,
159+
},
160+
},
161+
],
162+
}));
163+
});
164+
149165
// Cloud Incidents tools
150166
this.server.tool(
151167
cloudIncidentsTool.name,

0 commit comments

Comments
 (0)