fix: validate config secrets present
This commit is contained in:
parent
9aa7fc53b8
commit
97b93c44fa
1 changed files with 22 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ import {
|
|||
import { getErrorString } from "../util/error.js";
|
||||
import { logger } from "../util/logger.js";
|
||||
|
||||
import { TEMPLATE_VAR_REGEX } from "@continuedev/config-yaml";
|
||||
import { BaseService, ServiceWithDependencies } from "./BaseService.js";
|
||||
import { serviceContainer } from "./ServiceContainer.js";
|
||||
import {
|
||||
|
|
@ -249,6 +250,8 @@ export class MCPService
|
|||
this.updateState();
|
||||
|
||||
try {
|
||||
this.validateConfigSecrets(serverConfig);
|
||||
|
||||
const client = await this.getConnectedClient(serverConfig);
|
||||
|
||||
connection.client = client;
|
||||
|
|
@ -352,6 +355,25 @@ export class MCPService
|
|||
this.updateState();
|
||||
}
|
||||
|
||||
public validateConfigSecrets(serverConfig: MCPServerConfig): void {
|
||||
const configString = JSON.stringify(serverConfig);
|
||||
const unresolvedSecrets: string[] = [];
|
||||
|
||||
let match;
|
||||
const regex = new RegExp(TEMPLATE_VAR_REGEX);
|
||||
while ((match = regex.exec(configString)) !== null) {
|
||||
const fullPath = match[1];
|
||||
const secretName = fullPath.split(/[./]+/).pop() || fullPath;
|
||||
unresolvedSecrets.push(secretName);
|
||||
}
|
||||
|
||||
if (unresolvedSecrets.length > 0) {
|
||||
throw new Error(
|
||||
`${serverConfig.name} MCP Server has unresolved secrets: ${unresolvedSecrets.join(", ")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown a single connection
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue