@@ -8,103 +8,103 @@ import pkgJson from "../package.json";
88import { loadEnv , log } from "./utils" ;
99
1010async function main ( ) {
11- const notifier = updateNotifier ( { pkg : pkgJson } ) ;
12- if ( notifier . update ) {
13- log ( "a new version is available" , {
14- current : notifier . update . current ,
15- latest : notifier . update . latest ,
16- } ) ;
17- }
11+ const notifier = updateNotifier ( { pkg : pkgJson } ) ;
12+ if ( notifier . update ) {
13+ log ( "a new version is available" , {
14+ current : notifier . update . current ,
15+ latest : notifier . update . latest ,
16+ } ) ;
17+ }
1818
19- const envResult = loadEnv ( ) ;
20- if ( ! envResult . ok ) {
21- const errors = envResult . error . flatten ( ) ;
22- log ( "missing or malformed environment variables" , errors . fieldErrors ) ;
23- process . exit ( 1 ) ;
24- }
19+ const envResult = loadEnv ( ) ;
20+ if ( ! envResult . ok ) {
21+ const errors = envResult . error . flatten ( ) ;
22+ log ( "missing or malformed environment variables" , errors . fieldErrors ) ;
23+ process . exit ( 1 ) ;
24+ }
2525
26- const { ROVER_HOST , ROVER_API_KEY } = envResult . data ;
27- const SSE_URL = `${ ROVER_HOST } /mcp/sse` ;
26+ const { ROVER_HOST , ROVER_API_KEY } = envResult . data ;
27+ const SSE_URL = `${ ROVER_HOST } /mcp/sse` ;
2828
29- const getCommonHeaders = ( ) => ( {
30- authorization : `Bearer ${ ROVER_API_KEY } ` ,
31- } ) ;
29+ const getCommonHeaders = ( ) => ( {
30+ authorization : `Bearer ${ ROVER_API_KEY } ` ,
31+ } ) ;
3232
33- const createClientTransport = ( ) => {
34- return new SSEClientTransport ( new URL ( SSE_URL ) , {
35- eventSourceInit : {
36- fetch ( url , init ) {
37- return fetch ( url , {
38- ...init ,
39- headers : {
40- ...init ?. headers ,
41- ...getCommonHeaders ( ) ,
42- } ,
43- } ) ;
44- } ,
45- } ,
46- requestInit : {
47- headers : getCommonHeaders ( ) ,
48- } ,
49- } ) ;
50- } ;
51- const client = new Client ( {
52- name : "rover-mcp-proxy" ,
53- version : pkgJson . version ,
54- } ) ;
33+ const createClientTransport = ( ) => {
34+ return new SSEClientTransport ( new URL ( SSE_URL ) , {
35+ eventSourceInit : {
36+ fetch ( url , init ) {
37+ return fetch ( url , {
38+ ...init ,
39+ headers : {
40+ ...init ?. headers ,
41+ ...getCommonHeaders ( ) ,
42+ } ,
43+ } ) ;
44+ } ,
45+ } ,
46+ requestInit : {
47+ headers : getCommonHeaders ( ) ,
48+ } ,
49+ } ) ;
50+ } ;
51+ const client = new Client ( {
52+ name : "rover-mcp-proxy" ,
53+ version : pkgJson . version ,
54+ } ) ;
5555
56- log ( "connecting to Rover" , { sse : SSE_URL } ) ;
57- try {
58- await client . connect ( createClientTransport ( ) ) ;
59- } catch ( error ) {
60- log ( "failed to connect" , {
61- error : error instanceof Error ? error . message : String ( error ) ,
62- } ) ;
63- process . exit ( 1 ) ;
64- }
56+ log ( "connecting to Rover" , { sse : SSE_URL } ) ;
57+ try {
58+ await client . connect ( createClientTransport ( ) ) ;
59+ } catch ( error ) {
60+ log ( "failed to connect" , {
61+ error : error instanceof Error ? error . message : String ( error ) ,
62+ } ) ;
63+ process . exit ( 1 ) ;
64+ }
6565
66- const serverInfo = client . getServerVersion ( ) ;
67- if ( ! serverInfo ) {
68- log ( "connected but server info missing" ) ;
69- process . exit ( 1 ) ;
70- }
66+ const serverInfo = client . getServerVersion ( ) ;
67+ if ( ! serverInfo ) {
68+ log ( "connected but server info missing" ) ;
69+ process . exit ( 1 ) ;
70+ }
7171
72- const serverCapabilities = client . getServerCapabilities ( ) ;
73- if ( ! serverCapabilities ) {
74- log ( "connected but server capabilities missing" ) ;
75- process . exit ( 1 ) ;
76- }
72+ const serverCapabilities = client . getServerCapabilities ( ) ;
73+ if ( ! serverCapabilities ) {
74+ log ( "connected but server capabilities missing" ) ;
75+ process . exit ( 1 ) ;
76+ }
7777
78- log ( "connected" , {
79- info : serverInfo ,
80- capabilities : serverCapabilities ,
81- } ) ;
78+ log ( "connected" , {
79+ info : serverInfo ,
80+ capabilities : serverCapabilities ,
81+ } ) ;
8282
83- const serverTransport = new StdioServerTransport ( ) ;
84- const server = new McpServer (
85- {
86- name : serverInfo . name ,
87- version : serverInfo . version ,
88- } ,
89- {
90- capabilities : serverCapabilities ,
91- } ,
92- ) ;
93- await server . connect ( serverTransport ) ;
83+ const serverTransport = new StdioServerTransport ( ) ;
84+ const server = new McpServer (
85+ {
86+ name : serverInfo . name ,
87+ version : serverInfo . version ,
88+ } ,
89+ {
90+ capabilities : serverCapabilities ,
91+ } ,
92+ ) ;
93+ await server . connect ( serverTransport ) ;
9494
95- log ( "starting proxy" ) ;
96- try {
97- await proxyServer ( {
98- server : server . server ,
99- client : client ,
100- serverCapabilities,
101- } ) ;
102- } catch ( error ) {
103- log ( "failed to run proxy" , {
104- error : error instanceof Error ? error . message : String ( error ) ,
105- } ) ;
106- process . exit ( 1 ) ;
107- }
95+ log ( "starting proxy" ) ;
96+ try {
97+ await proxyServer ( {
98+ server : server . server ,
99+ client : client ,
100+ serverCapabilities,
101+ } ) ;
102+ } catch ( error ) {
103+ log ( "failed to run proxy" , {
104+ error : error instanceof Error ? error . message : String ( error ) ,
105+ } ) ;
106+ process . exit ( 1 ) ;
107+ }
108108}
109109
110110main ( ) ;
0 commit comments