Skip to content

Commit de899a7

Browse files
committed
Add missing api tools for auth
1 parent 19592ef commit de899a7

2 files changed

Lines changed: 146 additions & 0 deletions

File tree

src/server.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ import {
104104
modulesWithVersionsToolDefinitions,
105105
modulesToolNames,
106106
} from "./tools/modules-tool-definitions.js";
107+
import {
108+
GetTokenSchema,
109+
GetAllServiceAccountsSchema,
110+
CreateServiceAccountSchema,
111+
DeleteServiceAccountSchema,
112+
authToolDefinitions,
113+
authToolNames,
114+
} from "./tools/auth-tool-definitions.js";
107115

108116
const RUN_PROCESS_TOOL_NAME_PREFIX = "yc_";
109117
const RUN_PROCESS_TOOL_TAG = "mcp-tool";
@@ -295,6 +303,7 @@ class YepCodeMcpServer extends Server {
295303
if (this.tools.includes(API_TOOL_TAGS.FULL)) {
296304
tools.push(...processesWithVersionsToolDefinitions);
297305
tools.push(...modulesWithVersionsToolDefinitions);
306+
tools.push(...authToolDefinitions);
298307
}
299308
if (this.tools.includes(RUN_CODE_TOOL_TAG)) {
300309
const envVars = await this.yepCodeEnv.getEnvVars();
@@ -1215,6 +1224,53 @@ class YepCodeMcpServer extends Server {
12151224
}
12161225
);
12171226

1227+
case authToolNames.getToken:
1228+
return this.handleToolRequest(
1229+
GetTokenSchema,
1230+
request,
1231+
async (data) => {
1232+
const token = await this.yepCodeApi.getToken(data.apiToken);
1233+
return token;
1234+
}
1235+
);
1236+
1237+
case authToolNames.getAllServiceAccounts:
1238+
return this.handleToolRequest(
1239+
GetAllServiceAccountsSchema,
1240+
request,
1241+
async () => {
1242+
const serviceAccounts =
1243+
await this.yepCodeApi.getAllServiceAccounts();
1244+
return serviceAccounts;
1245+
}
1246+
);
1247+
1248+
case authToolNames.createServiceAccount:
1249+
return this.handleToolRequest(
1250+
CreateServiceAccountSchema,
1251+
request,
1252+
async (data) => {
1253+
const serviceAccount = await this.yepCodeApi.createServiceAccount(
1254+
{
1255+
name: data.name,
1256+
}
1257+
);
1258+
return serviceAccount;
1259+
}
1260+
);
1261+
1262+
case authToolNames.deleteServiceAccount:
1263+
return this.handleToolRequest(
1264+
DeleteServiceAccountSchema,
1265+
request,
1266+
async (data) => {
1267+
await this.yepCodeApi.deleteServiceAccount(data.id);
1268+
return {
1269+
result: `Service account ${data.id} deleted successfully`,
1270+
};
1271+
}
1272+
);
1273+
12181274
default:
12191275
this.logger.error(`Unknown tool requested: ${request.params.name}`);
12201276
throw new McpError(

src/tools/auth-tool-definitions.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { z } from "zod";
2+
3+
// Schema for getting a token
4+
export const GetTokenSchema = z.object({
5+
apiToken: z.string().describe("API token"),
6+
});
7+
8+
// Schema for getting all service accounts
9+
export const GetAllServiceAccountsSchema = z.object({});
10+
11+
// Schema for creating a service account
12+
export const CreateServiceAccountSchema = z.object({
13+
name: z.string().describe("Service account name"),
14+
});
15+
16+
// Schema for deleting a service account
17+
export const DeleteServiceAccountSchema = z.object({
18+
id: z
19+
.string()
20+
.describe("Unique identifier (UUID) of the service account to delete"),
21+
});
22+
23+
// Tool names
24+
export const authToolNames = {
25+
getToken: "get_token",
26+
getAllServiceAccounts: "get_all_service_accounts",
27+
createServiceAccount: "create_service_account",
28+
deleteServiceAccount: "delete_service_account",
29+
} as const;
30+
31+
// Tool definitions
32+
export const authToolDefinitions = [
33+
{
34+
name: authToolNames.getToken,
35+
title: "Get Token",
36+
description: "Gets an authentication token using an API token.",
37+
inputSchema: {
38+
type: "object",
39+
properties: {
40+
apiToken: {
41+
type: "string",
42+
description: "API token",
43+
},
44+
},
45+
required: ["apiToken"],
46+
},
47+
},
48+
{
49+
name: authToolNames.getAllServiceAccounts,
50+
title: "Get All Service Accounts",
51+
description: "Retrieves a list of all service accounts.",
52+
inputSchema: {
53+
type: "object",
54+
properties: {},
55+
},
56+
},
57+
{
58+
name: authToolNames.createServiceAccount,
59+
title: "Create Service Account",
60+
description: "Creates a new service account.",
61+
inputSchema: {
62+
type: "object",
63+
properties: {
64+
name: {
65+
type: "string",
66+
description: "Service account name",
67+
example: "my-service-account",
68+
},
69+
},
70+
required: ["name"],
71+
},
72+
},
73+
{
74+
name: authToolNames.deleteServiceAccount,
75+
title: "Delete Service Account",
76+
description:
77+
"Permanently deletes a service account. This action cannot be undone.",
78+
inputSchema: {
79+
type: "object",
80+
properties: {
81+
id: {
82+
type: "string",
83+
description:
84+
"Unique identifier (UUID) of the service account to delete",
85+
},
86+
},
87+
required: ["id"],
88+
},
89+
},
90+
];

0 commit comments

Comments
 (0)