Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add env option to MCP #3600

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/context/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ export interface StdioOptions {
type: "stdio";
command: string;
args: string[];
env?: Record<string, string>;
}

export interface WebSocketOptions {
Expand Down
2 changes: 0 additions & 2 deletions core/indexing/docs/DocsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions extensions/vscode/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
12 changes: 6 additions & 6 deletions gui/src/components/dialogs/AddDocsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -146,7 +146,7 @@ function AddDocsDialog() {

// Optimistic status update
dispatch(
setConfig({
updateConfig({
...config,
docs: [
...(config.docs?.filter(
Expand Down
14 changes: 12 additions & 2 deletions gui/src/redux/slices/configSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export const configSlice = createSlice({
state.config = config;
state.defaultModelTitle = defaultModelTitle;
},
updateConfig: (
state,
{ payload: config }: PayloadAction<BrowserSerializedContinueConfig>,
) => {
state.config = config;
},
setConfigError: (
state,
{ payload: error }: PayloadAction<ConfigValidationError[] | undefined>,
Expand Down Expand Up @@ -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,
Expand Down
Loading