11import { v1 } from "@docker/extension-api-client-types" ;
2- import { parse , stringify } from "yaml" ;
3- import { BUSYBOX } from "../Constants" ;
4- import { getUser , writeToMount } from "../utils/Files" ;
5- import { mergeDeep } from "../MergeDeep" ;
2+ import { stringify } from "yaml" ;
63import { MCPClient , SAMPLE_MCP_CONFIG } from "./MCPTypes" ;
74
85class ContinueDotDev implements MCPClient {
@@ -19,112 +16,20 @@ class ContinueDotDev implements MCPClient {
1916 linux : "$HOME/.continue/config.yaml" ,
2017 win32 : "$USERPROFILE\\.continue\\config.yaml" ,
2118 } ;
22- readConfig = async ( client : v1 . DockerDesktopClient ) => {
23- const platform = client . host
24- . platform as keyof typeof this . expectedConfigPath ;
25- const configPath = this . expectedConfigPath [ platform ] . replace (
26- "$USER" ,
27- await getUser ( client )
28- ) ;
29- try {
30- const result = await client . docker . cli . exec ( "run" , [
31- "--rm" ,
32- "--mount" ,
33- `type=bind,source=${ configPath } ,target=/continue/config.yaml` ,
34- BUSYBOX ,
35- "/bin/cat" ,
36- "/continue/config.yaml" ,
37- ] ) ;
38- return {
39- content : result . stdout ,
40- path : configPath ,
41- } ;
42- } catch ( e ) {
43- return {
44- content : null ,
45- path : configPath ,
46- } ;
47- }
48- } ;
4919 connect = async ( client : v1 . DockerDesktopClient ) => {
50- const config = await this . readConfig ( client ) ;
51- let continueConfig = null ;
52- try {
53- continueConfig = parse ( config . content || "" ) as typeof SAMPLE_MCP_CONFIG ;
54- if ( continueConfig . mcpServers ?. MCP_DOCKER ) {
55- client . desktopUI . toast . warning (
56- "Continue.dev MCP server already connected."
57- ) ;
58- return ;
59- }
60- } catch ( e ) {
61- continueConfig = mergeDeep ( { } , SAMPLE_MCP_CONFIG ) ;
62- }
63- const payload = mergeDeep ( continueConfig , SAMPLE_MCP_CONFIG ) ;
6420 try {
65- await writeToMount (
66- client ,
67- `type=bind,source=${ config . path } ,target=/continue/config.yaml` ,
68- "/continue/config.yaml" ,
69- stringify ( payload )
70- ) ;
21+ await client . extension . host ?. cli . exec ( "host-binary" , [ "client" , "connect" , "--global" , "continue" ] ) ;
7122 } catch ( e ) {
72- if ( ( e as any ) . stderr ) {
73- client . desktopUI . toast . error ( ( e as any ) . stderr ) ;
74- } else {
75- client . desktopUI . toast . error ( ( e as Error ) . message ) ;
76- }
23+ client . desktopUI . toast . error ( "Unable to connect Continue.dev" ) ;
7724 }
7825 } ;
7926 disconnect = async ( client : v1 . DockerDesktopClient ) => {
80- const config = await this . readConfig ( client ) ;
81- if ( ! config . content ) {
82- client . desktopUI . toast . error ( "No config found" ) ;
83- return ;
84- }
85- let continueConfig = null ;
86- try {
87- continueConfig = parse ( config . content ) as typeof SAMPLE_MCP_CONFIG ;
88- if ( ! continueConfig . mcpServers ?. MCP_DOCKER ) {
89- client . desktopUI . toast . error (
90- "Docker MCP Server not connected to Continue.dev"
91- ) ;
92- return ;
93- }
94- } catch ( e ) {
95- client . desktopUI . toast . error (
96- "Failed to disconnect. Invalid Continue.dev config found at " +
97- config . path
98- ) ;
99- return ;
100- }
101- const payload = {
102- ...continueConfig ,
103- mcpServers : Object . fromEntries (
104- Object . entries ( continueConfig . mcpServers ) . filter (
105- ( [ key ] ) => key !== "MCP_DOCKER"
106- )
107- ) ,
108- } ;
10927 try {
110- await writeToMount (
111- client ,
112- `type=bind,source=${ config . path } ,target=/continue/config.yaml` ,
113- "/continue/config.yaml" ,
114- stringify ( payload )
115- ) ;
28+ await client . extension . host ?. cli . exec ( "host-binary" , [ "client" , "disconnect" , "--global" , "continue" ] ) ;
11629 } catch ( e ) {
117- if ( ( e as any ) . stderr ) {
118- client . desktopUI . toast . error ( ( e as any ) . stderr ) ;
119- } else {
120- client . desktopUI . toast . error ( ( e as Error ) . message ) ;
121- }
30+ client . desktopUI . toast . error ( "Unable to disconnect Continue.dev" ) ;
12231 }
12332 } ;
124- validateConfig = ( content : string ) => {
125- const config = JSON . parse ( content || "{}" ) as typeof SAMPLE_MCP_CONFIG ;
126- return ! ! config . mcpServers ?. MCP_DOCKER ;
127- } ;
12833}
12934
13035export default new ContinueDotDev ( ) ;
0 commit comments