Skip to content

Commit cb39a40

Browse files
authored
Add DHI disclaimer and logs (#41)
* add disclaimers and logs * update tools
1 parent 2f1972d commit cb39a40

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"format:fix": "prettier --write \"**/*.+(ts|json)\"",
1414
"format:check": "prettier --check \"**/*.+(ts|json)\"",
1515
"format": "npm run format:fix",
16-
"list-tools:check": "node dist/scripts/toolsList.js check-tools-list",
17-
"list-tools:update": "node dist/scripts/toolsList.js update-tools-list",
16+
"list-tools:check": "npm run build && node dist/scripts/toolsList.js check-tools-list",
17+
"list-tools:update": "npm run build && node dist/scripts/toolsList.js update-tools-list",
1818
"list-tools": "npm run list-tools:check && npm run list-tools:update"
1919
},
2020
"keywords": [

src/scout.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import { ScoutClient } from './scout/client';
1919
import fetch, { RequestInfo, RequestInit } from 'node-fetch';
2020
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2121
import z from 'zod';
22+
import { logger } from './logger';
23+
24+
const DHI_DISCLAIMER = `Docker Hardened Images are available for organizations entitled to DHIs.If you're interested in accessing Docker Hardened Images, please visit:
25+
https://www.docker.com/products/hardened-images/`;
2226

2327
export class ScoutAPI extends Asset {
2428
private scoutClient: ScoutClient;
@@ -59,7 +63,7 @@ export class ScoutAPI extends Asset {
5963
'docker-hardened-images',
6064
{
6165
description:
62-
'Docker Hardened Images (DHI) API. This API is used to query for mirrored DHIs in the namespace. It lists all the secure, minimal, production-ready images available to get near-zero CVEs and enterprise-grade SLA.',
66+
'Docker Hardened Images (DHI) API. This API is used to query for mirrored DHIs in the namespace. It lists all the secure, minimal, production ready images available to get near-zero CVEs and enterprise-grade SLA.',
6367
inputSchema: z.object({
6468
namespace: z
6569
.string()
@@ -72,6 +76,7 @@ export class ScoutAPI extends Asset {
7276
},
7377
},
7478
async ({ namespace }) => {
79+
logger.info(`Querying for mirrored DHI images for organization: ${namespace}`);
7580
const { data, errors } = await this.scoutClient.query({
7681
dhiListMirroredRepositories: {
7782
__args: {
@@ -91,16 +96,51 @@ export class ScoutAPI extends Asset {
9196
},
9297
});
9398
if (errors) {
99+
logger.error(
100+
`Error querying for mirrored DHI images: ${JSON.stringify(errors)}`
101+
);
94102
return {
95-
content: [{ type: 'text', text: JSON.stringify(errors, null, 2) }],
103+
content: [
104+
{ type: 'text', text: JSON.stringify(errors, null, 2) },
105+
{
106+
type: 'text',
107+
text: DHI_DISCLAIMER,
108+
},
109+
],
96110
isError: true,
97111
};
98112
}
113+
if (data.dhiListMirroredRepositories.mirroredRepositories.length === 0) {
114+
logger.info(`No mirrored DHI images found for organization: ${namespace}`);
115+
return {
116+
content: [
117+
{
118+
type: 'text',
119+
text: `There are no mirrored DHI images for the organization '${namespace}'. Could you try again by providing a different organization entitled to DHIs?`,
120+
},
121+
{
122+
type: 'text',
123+
text: DHI_DISCLAIMER,
124+
},
125+
],
126+
};
127+
}
128+
logger.info(
129+
`Found ${data.dhiListMirroredRepositories.mirroredRepositories.length} mirrored DHI images for organization: ${namespace}`
130+
);
99131
return {
100132
content: [
101133
{
102134
type: 'text',
103-
text: JSON.stringify(data, null, 2),
135+
text: `Here are the mirrored DHI images for the organization '${namespace}':\n\n${JSON.stringify(
136+
data.dhiListMirroredRepositories.mirroredRepositories,
137+
null,
138+
2
139+
)}`,
140+
},
141+
{
142+
type: 'text',
143+
text: DHI_DISCLAIMER,
104144
},
105145
],
106146
};

tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3753,7 +3753,7 @@
37533753
},
37543754
{
37553755
"name": "docker-hardened-images",
3756-
"description": "Docker Hardened Images (DHI) API. This API is used to query for mirrored DHIs in the namespace. It lists all the secure, minimal, production-ready images available to get near-zero CVEs and enterprise-grade SLA.",
3756+
"description": "Docker Hardened Images (DHI) API. This API is used to query for mirrored DHIs in the namespace. It lists all the secure, minimal, production ready images available to get near-zero CVEs and enterprise-grade SLA.",
37573757
"inputSchema": {
37583758
"type": "object",
37593759
"properties": {

0 commit comments

Comments
 (0)