From f2820feca92490a4eff42aa6773dec2f6de471bd Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 13:45:24 -0500 Subject: [PATCH 1/2] add env option to MCP --- core/context/mcp/index.ts | 1 + core/index.d.ts | 1 + extensions/vscode/config_schema.json | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/core/context/mcp/index.ts b/core/context/mcp/index.ts index e214b1e026..26be2f471c 100644 --- a/core/context/mcp/index.ts +++ b/core/context/mcp/index.ts @@ -72,6 +72,7 @@ class MCPConnection { return new StdioClientTransport({ command: options.transport.command, args: options.transport.args, + env: options.transport.env, }); case "websocket": return new WebSocketClientTransport(new URL(options.transport.url)); diff --git a/core/index.d.ts b/core/index.d.ts index d916a19f11..2d7622895d 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -940,6 +940,7 @@ export interface StdioOptions { type: "stdio"; command: string; args: string[]; + env?: Record; } export interface WebSocketOptions { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c9df4e9769..c0ffddd3ae 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3151,6 +3151,13 @@ "items": { "type": "string" } + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Environment variables to pass to the command" } }, "required": ["type", "command", "args"] From efd3b7bf715f16cd29f2825e0e3d84f871829e63 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 13:55:06 -0500 Subject: [PATCH 2/2] fix merge conflicts --- core/indexing/docs/DocsService.ts | 2 -- gui/src/components/dialogs/AddDocsDialog.tsx | 12 ++++++------ gui/src/redux/slices/configSlice.ts | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 3d9cb0fd7c..1696466dc2 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -18,8 +18,6 @@ import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbed import { FromCoreProtocol, ToCoreProtocol } from "../../protocol"; import { IMessenger } from "../../protocol/messenger"; import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon"; -import { IMessenger } from "../../protocol/messenger"; -import { GlobalContext } from "../../util/GlobalContext"; import { editConfigJson, getDocsSqlitePath, diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index f816369c8d..01f9244255 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -5,19 +5,19 @@ import { PlusIcon, } from "@heroicons/react/24/outline"; import { IndexingStatus, PackageDocsResult, SiteIndexingConfig } from "core"; +import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; import { usePostHog } from "posthog-js/react"; import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDispatch } from "react-redux"; import { Input, SecondaryButton } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { updateConfig } from "../../redux/slices/configSlice"; +import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; -import { ToolTip } from "../gui/Tooltip"; import FileIcon from "../FileIcon"; +import { ToolTip } from "../gui/Tooltip"; import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; -import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; -import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; -import { useAppSelector } from "../../redux/hooks"; -import { setConfig } from "../../redux/slices/configSlice"; function AddDocsDialog() { const config = useAppSelector((store) => store.config.config); @@ -146,7 +146,7 @@ function AddDocsDialog() { // Optimistic status update dispatch( - setConfig({ + updateConfig({ ...config, docs: [ ...(config.docs?.filter( diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index 35e530e474..99401fe05d 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -55,6 +55,12 @@ export const configSlice = createSlice({ state.config = config; state.defaultModelTitle = defaultModelTitle; }, + updateConfig: ( + state, + { payload: config }: PayloadAction, + ) => { + state.config = config; + }, setConfigError: ( state, { payload: error }: PayloadAction, @@ -93,8 +99,12 @@ export const configSlice = createSlice({ }, }); -export const { setDefaultModel, setConfigResult, setConfigError } = - configSlice.actions; +export const { + setDefaultModel, + updateConfig, + setConfigResult, + setConfigError, +} = configSlice.actions; export const { selectDefaultModel,