Skip to content

Commit e734ad7

Browse files
authored
fix: json mcp loading (#8002)
1 parent 60ed7b8 commit e734ad7

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

core/context/mcp/json/loadJsonMcpConfigs.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,24 @@ export async function loadJsonMcpConfigs(
111111
),
112112
);
113113
}
114-
if (claudeCodeFileParsed.data.projects) {
115-
const projectServers = Object.values(
116-
claudeCodeFileParsed.data.projects,
117-
).map((v) => v.mcpServers);
118-
for (const mcpServers of projectServers) {
119-
if (mcpServers) {
120-
validJsonConfigs.push(
121-
...Object.entries(mcpServers).map(([name, mcpJson]) => ({
122-
name,
123-
mcpJson,
124-
uri,
125-
})),
126-
);
127-
}
114+
const projectServers = Object.values(
115+
claudeCodeFileParsed.data.projects,
116+
).map((v) => v.mcpServers);
117+
for (const mcpServers of projectServers) {
118+
if (mcpServers) {
119+
validJsonConfigs.push(
120+
...Object.entries(mcpServers).map(([name, mcpJson]) => ({
121+
name,
122+
mcpJson,
123+
uri,
124+
})),
125+
);
128126
}
129127
}
130128
} else {
131129
const claudeDesktopFileParsed =
132130
claudeDesktopLikeConfigFileSchema.safeParse(json);
133-
if (
134-
claudeDesktopFileParsed.success &&
135-
claudeDesktopFileParsed.data.mcpServers
136-
) {
131+
if (claudeDesktopFileParsed.success) {
137132
validJsonConfigs.push(
138133
...Object.entries(claudeDesktopFileParsed.data.mcpServers).map(
139134
([name, mcpJson]) => ({

packages/config-yaml/src/schemas/mcp/json.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,20 @@ export const mcpServersRecordSchema = z.record(
3131
export type McpServersJsonConfigRecord = z.infer<typeof mcpServersRecordSchema>;
3232

3333
export const claudeDesktopLikeConfigFileSchema = z.object({
34-
mcpServers: mcpServersRecordSchema.optional(),
34+
mcpServers: mcpServersRecordSchema,
3535
});
3636
export type McpServersJsonConfigFile = z.infer<
3737
typeof claudeDesktopLikeConfigFileSchema
3838
>;
3939

4040
export const claudeCodeLikeConfigFileSchema = z.object({
4141
mcpServers: mcpServersRecordSchema.optional(),
42-
projects: z
43-
.record(
44-
z.string(),
45-
z.object({
46-
mcpServers: mcpServersRecordSchema.optional(),
47-
}),
48-
)
49-
.optional(),
42+
projects: z.record(
43+
z.string(),
44+
z.object({
45+
mcpServers: mcpServersRecordSchema.optional(),
46+
}),
47+
),
5048
});
5149
export type claudeCodeLikeConfigFileSchema = z.infer<
5250
typeof claudeCodeLikeConfigFileSchema

0 commit comments

Comments
 (0)