@@ -5,6 +5,8 @@ import type { PythinkerApiConfig } from '../config';
55import { buildRestUrl , buildWsUrl } from '../config' ;
66import type {
77 AppConfig ,
8+ AppMcpServerDefinition ,
9+ AppMcpServerInput ,
810 AppMessage ,
911 AppMessageRole ,
1012 AppModel ,
@@ -151,6 +153,17 @@ interface WireMcpServer {
151153 status : 'connected' | 'connecting' | 'disconnected' | 'error' ;
152154 tool_count : number ;
153155 last_error ?: string ;
156+ editable : boolean ;
157+ definition ?: WireMcpServerDefinition ;
158+ }
159+
160+ interface WireMcpServerDefinition {
161+ transport : 'stdio' | 'http' | 'sse' ;
162+ command ?: string ;
163+ args ?: string [ ] ;
164+ env ?: Record < string , string > ;
165+ url ?: string ;
166+ headers ?: Record < string , string > ;
154167}
155168
156169interface WirePlugin {
@@ -175,6 +188,28 @@ interface WireAgentProfile {
175188 when_to_use ?: string ;
176189}
177190
191+ function toAppMcpDefinition ( definition : WireMcpServerDefinition ) : AppMcpServerDefinition {
192+ return {
193+ transport : definition . transport ,
194+ command : definition . command ,
195+ args : definition . args ,
196+ env : definition . env ,
197+ url : definition . url ,
198+ headers : definition . headers ,
199+ } ;
200+ }
201+
202+ function toWireMcpDefinition ( input : AppMcpServerInput ) : WireMcpServerDefinition {
203+ return {
204+ transport : input . transport ,
205+ command : input . command ,
206+ args : input . args ,
207+ env : input . env ,
208+ url : input . url ,
209+ headers : input . headers ,
210+ } ;
211+ }
212+
178213interface WireArchiveResult {
179214 archived : true ;
180215}
@@ -791,9 +826,34 @@ export class DaemonPythinkerWebApi implements PythinkerWebApi {
791826 status : server . status ,
792827 toolCount : server . tool_count ,
793828 lastError : server . last_error ,
829+ editable : server . editable ,
830+ definition : server . definition === undefined ? undefined : toAppMcpDefinition ( server . definition ) ,
794831 } ) ) ;
795832 }
796833
834+ async createConnector ( input : AppMcpServerInput ) : Promise < { created : true } > {
835+ return this . http . post < { created : true } > ( '/mcp/servers' , {
836+ mcp_server_id : input . name ,
837+ config : toWireMcpDefinition ( input ) ,
838+ } ) ;
839+ }
840+
841+ async updateConnector (
842+ connectorId : string ,
843+ input : AppMcpServerInput ,
844+ ) : Promise < { updated : true } > {
845+ return this . http . put < { updated : true } > (
846+ `/mcp/servers/${ encodeURIComponent ( connectorId ) } ` ,
847+ { config : toWireMcpDefinition ( input ) } ,
848+ ) ;
849+ }
850+
851+ async removeConnector ( connectorId : string ) : Promise < { deleted : true } > {
852+ return this . http . delete < { deleted : true } > (
853+ `/mcp/servers/${ encodeURIComponent ( connectorId ) } ` ,
854+ ) ;
855+ }
856+
797857 async listPlugins ( ) : Promise < AppPlugin [ ] > {
798858 const data = await this . http . get < { plugins : WirePlugin [ ] } > ( '/plugins' ) ;
799859 return ( data . plugins ?? [ ] ) . map ( ( plugin ) => ( {
0 commit comments