11import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
2+ import axios from "axios" ;
23import { getServiceIdentifier , getVisRequestServer } from "./env" ;
34
45/**
@@ -15,19 +16,20 @@ export async function generateChartUrl(
1516) : Promise < string > {
1617 const url = getVisRequestServer ( ) ;
1718
18- const response = await fetch ( url , {
19- method : "POST" ,
20- headers : {
21- "Content-Type" : "application/json" ,
22- } ,
23- body : JSON . stringify ( {
19+ const response = await axios . post (
20+ url ,
21+ {
2422 type,
2523 ...options ,
2624 source : "mcp-server-chart" ,
27- } ) ,
28- } ) ;
29-
30- const { success, errorMessage, resultObj } = await response . json ( ) ;
25+ } ,
26+ {
27+ headers : {
28+ "Content-Type" : "application/json" ,
29+ } ,
30+ } ,
31+ ) ;
32+ const { success, errorMessage, resultObj } = response . data ;
3133
3234 if ( ! success ) {
3335 throw new Error ( errorMessage ) ;
@@ -57,20 +59,21 @@ export async function generateMap(
5759) : Promise < ResponseResult > {
5860 const url = getVisRequestServer ( ) ;
5961
60- const response = await fetch ( url , {
61- method : "POST" ,
62- headers : {
63- "Content-Type" : "application/json" ,
64- } ,
65- body : JSON . stringify ( {
66- source : "mcp-server-chart" ,
62+ const response = await axios . post (
63+ url ,
64+ {
6765 serviceId : getServiceIdentifier ( ) ,
6866 tool,
6967 input,
70- } ) ,
71- } ) ;
72-
73- const { success, errorMessage, resultObj } = await response . json ( ) ;
68+ source : "mcp-server-chart" ,
69+ } ,
70+ {
71+ headers : {
72+ "Content-Type" : "application/json" ,
73+ } ,
74+ } ,
75+ ) ;
76+ const { success, errorMessage, resultObj } = response . data ;
7477
7578 if ( ! success ) {
7679 throw new Error ( errorMessage ) ;
0 commit comments