fix: cubic feedback, lint, format
This commit is contained in:
parent
ac45506dd3
commit
f995a0e45f
7 changed files with 25 additions and 16 deletions
|
|
@ -189,6 +189,7 @@ class MCPConnection {
|
|||
);
|
||||
try {
|
||||
await this.client.connect(transport, {});
|
||||
this.transport = transport;
|
||||
} catch (error) {
|
||||
// Allow the case where for whatever reason is already connected
|
||||
if (
|
||||
|
|
@ -209,14 +210,17 @@ class MCPConnection {
|
|||
if (this.options.type === "sse") {
|
||||
const transport = this.constructSseTransport(this.options);
|
||||
await this.client.connect(transport, {});
|
||||
this.transport = transport;
|
||||
} else if (this.options.type === "streamable-http") {
|
||||
const transport = this.constructHttpTransport(this.options);
|
||||
await this.client.connect(transport, {});
|
||||
this.transport = transport;
|
||||
} else if (this.options.type === "websocket") {
|
||||
const transport = this.constructWebsocketTransport(
|
||||
this.options,
|
||||
);
|
||||
await this.client.connect(transport, {});
|
||||
this.transport = transport;
|
||||
} else {
|
||||
try {
|
||||
const transport = this.constructHttpTransport({
|
||||
|
|
@ -235,7 +239,7 @@ class MCPConnection {
|
|||
this.transport = transport;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`MCP config with no URL and type specified failed both sse and http connection: ${e instanceof Error ? e.message : String(e)}`,
|
||||
`MCP config with URL and no type specified failed both SSE and HTTP connection: ${e instanceof Error ? e.message : String(e)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ describe("MCPOauth", () => {
|
|||
},
|
||||
});
|
||||
|
||||
removeMCPAuth(mockMcpServerId, mockIde);
|
||||
removeMCPAuth(mockMcpServerUrl, mockIde);
|
||||
|
||||
const updatedStorage = globalContext.get("mcpOauthStorage");
|
||||
expect(updatedStorage).toEqual({
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ import { localPathToUri } from "../../../util/pathToUri";
|
|||
import { getUriPathBasename, joinPathsToUri } from "../../../util/uri";
|
||||
|
||||
/**
|
||||
* This method searches in both ~/.continue and workspace .continue
|
||||
* for all YAML/Markdown files in the specified subdirectory, for example .continue/assistants or .continue/prompts
|
||||
* Loads MCP configs from JSON files in ~/.continue/mcpServers and workspace .continue/mcpServers
|
||||
*/
|
||||
export async function loadJsonMcpConfigs(
|
||||
ide: IDE,
|
||||
|
|
@ -129,9 +128,15 @@ export async function loadJsonMcpConfigs(
|
|||
const yamlConfigs = validJsonConfigs.map((c) =>
|
||||
convertJsonMcpConfigToYamlMcpConfig(c.name, c.mcpJson),
|
||||
);
|
||||
const mcpServers = yamlConfigs.map((c) =>
|
||||
convertYamlMcpConfigToInternalMcpOptions(c.yamlConfig),
|
||||
);
|
||||
const mcpServers = yamlConfigs.map((c) => {
|
||||
errors.push(
|
||||
...c.warnings.map((warning) => ({
|
||||
fatal: false,
|
||||
message: warning,
|
||||
})),
|
||||
);
|
||||
return convertYamlMcpConfigToInternalMcpOptions(c.yamlConfig);
|
||||
});
|
||||
// Parse and convert files
|
||||
return {
|
||||
mcpServers,
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|||
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
||||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
|
||||
import { getErrorString } from "../util/error.js";
|
||||
import { logger } from "../util/logger.js";
|
||||
|
||||
import {
|
||||
HttpMcpServer,
|
||||
SseMcpServer,
|
||||
StdioMcpServer,
|
||||
} from "node_modules/@continuedev/config-yaml/dist/schemas/mcp/index.js";
|
||||
|
||||
import { getErrorString } from "../util/error.js";
|
||||
import { logger } from "../util/logger.js";
|
||||
|
||||
import { BaseService, ServiceWithDependencies } from "./BaseService.js";
|
||||
import { serviceContainer } from "./ServiceContainer.js";
|
||||
import {
|
||||
|
|
@ -376,7 +376,7 @@ export class MCPService
|
|||
try {
|
||||
const transport = this.constructHttpTransport(serverConfig);
|
||||
await client.connect(transport, {});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
logger.debug(
|
||||
"MCP Connection: http connection failed, falling back to sse connection",
|
||||
{
|
||||
|
|
@ -388,7 +388,7 @@ export class MCPService
|
|||
await client.connect(transport, {});
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`MCP config with no URL and type specified failed both sse and http connection: ${e instanceof Error ? e.message : String(e)}`,
|
||||
`MCP config with URL and no type specified failed both SSE and HTTP connection: ${e instanceof Error ? e.message : String(e)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({
|
|||
z.object({
|
||||
uses: defaultUsesSchema,
|
||||
with: z.record(z.string()).optional(),
|
||||
override: partialMcpServerSchema,
|
||||
override: partialMcpServerSchema.optional(),
|
||||
}),
|
||||
]),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const stdioMcpServerSchema = baseMcpServerSchema.extend({
|
|||
export type StdioMcpServer = z.infer<typeof stdioMcpServerSchema>;
|
||||
|
||||
const sseOrHttpMcpServerSchema = baseMcpServerSchema.extend({
|
||||
url: z.string(),
|
||||
url: z.string(), // .url() fails with e.g. IP addresses
|
||||
type: z.union([z.literal("sse"), z.literal("streamable-http")]).optional(),
|
||||
requestOptions: requestOptionsSchema.optional(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import z from "zod";
|
|||
// This is the schema for an entry in e.g. Claude Desktop, Claude code mcp config
|
||||
const httpOrSseMcpJsonSchema = z.object({
|
||||
type: z.union([z.literal("sse"), z.literal("http")]).optional(),
|
||||
url: z.string().url(),
|
||||
url: z.string(), // .url() fails with e.g. IP addresses
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
export type HttpMcpJsonConfig = z.infer<typeof httpOrSseMcpJsonSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue