Skip to content

Commit 9c9cb7d

Browse files
committed
fix spelling problem
1 parent e147eba commit 9c9cb7d

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/services/mcp/config/ConfigManager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { GlobalFileNames } from "../../../shared/globalFileNames"
99
import { fileExistsAtPath } from "../../../utils/fs"
1010
import { ServerConfig, McpServer, ConfigSource } from "../types"
1111
import { ConfigChangeEvent, ConfigChangeListener } from "./types"
12-
import { safeParseSeverConfig } from "./validation"
12+
import { safeParseServerConfig } from "./validation"
1313

1414
/**
1515
* Configuration Manager
@@ -92,7 +92,6 @@ export class ConfigManager {
9292
* @param error Error object
9393
*/
9494
private showErrorMessage(message: string, error: unknown): never {
95-
const errorMessage = error instanceof Error ? error.message : `${error}`
9695
console.error(`${message}:`, error)
9796
if (vscode.window && typeof vscode.window.showErrorMessage === "function") {
9897
vscode.window.showErrorMessage(message)
@@ -122,7 +121,7 @@ export class ConfigManager {
122121
public validateServerConfig(config: unknown, serverName?: string): ServerConfig {
123122
try {
124123
const configCopy = { ...(config as Record<string, unknown>) }
125-
const result = safeParseSeverConfig(configCopy)
124+
const result = safeParseServerConfig(configCopy)
126125
if (!result.success) {
127126
const errors = result.error.errors.map((err) => `${err.path.join(".")}: ${err.message}`).join(", ")
128127
throw new Error(t("common:errors.invalid_mcp_settings_validation", { errorMessages: errors }))

src/services/mcp/config/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ export const validateServerConfig = (config: unknown): ServerConfig => {
6464
* @param config The configuration object to validate
6565
* @returns The validation result
6666
*/
67-
export const safeParseSeverConfig = (config: unknown): z.SafeParseReturnType<unknown, ServerConfig> => {
67+
export const safeParseServerConfig = (config: unknown): z.SafeParseReturnType<unknown, ServerConfig> => {
6868
return createServerConfigSchema().safeParse(config)
6969
}

src/services/mcp/connection/ConnectionFactory.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ServerConfig, McpConnection, McpServer, ConfigSource } from "../types"
22
import { ConnectionHandler } from "./ConnectionHandler"
33
import { FileWatcher } from "./FileWatcher"
4-
import { ConfigManager } from "../config/ConfigManager"
4+
import { ConfigManager } from "../config"
55

66
/**
77
* Connection factory class
@@ -70,14 +70,25 @@ export class ConnectionFactory {
7070
}
7171

7272
// Prefer parameter callback, otherwise use the callback from factory constructor
73-
const statusChangeCb = onStatusChange
74-
? (server: McpServer) => {
75-
onStatusChange(server)
76-
if (this.onStatusChange) this.onStatusChange(server)
73+
let statusChangeCb: ((server: McpServer) => void) | undefined
74+
75+
if (onStatusChange) {
76+
// If parameter callback is provided, call both it and the factory callback if present
77+
statusChangeCb = (server: McpServer) => {
78+
onStatusChange(server)
79+
if (this.onStatusChange) {
80+
this.onStatusChange(server)
7781
}
78-
: this.onStatusChange
79-
? (server: McpServer) => this.onStatusChange && this.onStatusChange(server)
80-
: undefined
82+
}
83+
} else if (this.onStatusChange) {
84+
// If only factory callback is present, use that
85+
statusChangeCb = (server: McpServer) => {
86+
this.onStatusChange!(server)
87+
}
88+
} else {
89+
// No callbacks provided
90+
statusChangeCb = undefined
91+
}
8192

8293
// Use handler to create connection
8394
const connection = await handler.createConnection(name, patchedConfig, source, statusChangeCb)

0 commit comments

Comments
 (0)