Skip to content

Commit da652f6

Browse files
committed
Error out MCP server calls
1 parent 7a69a23 commit da652f6

1 file changed

Lines changed: 42 additions & 39 deletions

File tree

src/servers/mcp-server.ts

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -242,56 +242,59 @@ export class MCPServer extends BaseMCPServer {
242242
@WithSpan('call-get-relevant-questions')
243243
async callGetRelevantQuestions(request: z.infer<typeof CallToolRequestSchema>) {
244244
const { query, datasourceIds: sourceIds, additionalContext } = GetRelevantQuestionsSchema.parse(request.params.arguments);
245-
console.log("[DEBUG] Getting relevant questions for datasource: ", sourceIds);
245+
throw new McpServerError({ message: "Invalid call get relevant questions" }, 400);
246+
// console.log("[DEBUG] Getting relevant questions for datasource: ", sourceIds);
246247

247-
const relevantQuestions = await this.getThoughtSpotService().getRelevantQuestions(
248-
query,
249-
sourceIds!,
250-
additionalContext ?? ""
251-
);
248+
// const relevantQuestions = await this.getThoughtSpotService().getRelevantQuestions(
249+
// query,
250+
// sourceIds!,
251+
// additionalContext ?? ""
252+
// );
252253

253-
if (relevantQuestions.error) {
254-
console.error("Error getting relevant questions: ", relevantQuestions.error);
254+
// if (relevantQuestions.error) {
255+
// console.error("Error getting relevant questions: ", relevantQuestions.error);
255256

256-
const structuredContent = { questions: [{ question: query, datasourceId: sourceIds?.[0] ?? '' }] };
257-
const span = this.initSpanWithCommonAttributes();
258-
span?.setStatus({ code: SpanStatusCode.ERROR, message: "Relevant questions failed, sending back the query as it is" });
259-
span?.setAttribute("datasource_ids", sourceIds?.join(",") ?? "");
260-
span?.setAttribute("error", relevantQuestions.error.message);
261-
return {
262-
content: [{
263-
type: "text",
264-
text: JSON.stringify(structuredContent),
265-
}],
266-
structuredContent,
267-
};
268-
}
269-
270-
if (relevantQuestions.questions.length === 0) {
271-
return this.createSuccessResponse("No relevant questions found");
272-
}
273-
274-
return this.createStructuredContentSuccessResponse({ questions: relevantQuestions.questions }, "Relevant questions found");
257+
// const structuredContent = { questions: [{ question: query, datasourceId: sourceIds?.[0] ?? '' }] };
258+
// const span = this.initSpanWithCommonAttributes();
259+
// span?.setStatus({ code: SpanStatusCode.ERROR, message: "Relevant questions failed, sending back the query as it is" });
260+
// span?.setAttribute("datasource_ids", sourceIds?.join(",") ?? "");
261+
// span?.setAttribute("error", relevantQuestions.error.message);
262+
// return {
263+
// content: [{
264+
// type: "text",
265+
// text: JSON.stringify(structuredContent),
266+
// }],
267+
// structuredContent,
268+
// };
269+
// }
270+
271+
// if (relevantQuestions.questions.length === 0) {
272+
// return this.createSuccessResponse("No relevant questions found");
273+
// }
274+
275+
// return this.createStructuredContentSuccessResponse({ questions: relevantQuestions.questions }, "Relevant questions found");
275276
}
276277

277278
@WithSpan('call-get-answer')
278279
async callGetAnswer(request: z.infer<typeof CallToolRequestSchema>) {
279280
const { question, datasourceId: sourceId } = GetAnswerSchema.parse(request.params.arguments);
281+
throw new McpServerError({ message: "invalid call get answer" }, 500);
280282

281-
const answer = await this.getThoughtSpotService().getAnswerForQuestion(question, sourceId, false);
282283

283-
if (answer.error) {
284-
return this.createErrorResponse(answer.error.message, `Error getting answer ${answer.error.message}`);
285-
}
284+
// const answer = await this.getThoughtSpotService().getAnswerForQuestion(question, sourceId, false);
285+
286+
// if (answer.error) {
287+
// return this.createErrorResponse(answer.error.message, `Error getting answer ${answer.error.message}`);
288+
// }
286289

287-
return this.createStructuredContentSuccessResponse({
288-
data: answer.data,
289-
question: answer.question,
290-
session_identifier: answer.session_identifier,
291-
generation_number: answer.generation_number,
292-
frame_url: answer.frame_url,
293-
fields_info: "data: The csv data as an answer to the question\n session_identifier: The session identifier for the answer, use for liveboard creation\n generation_number: The generation number for the answer, use for liveboard creation\n frame_url: A url which can be used to view the answer in an iframe in the browser\n",
294-
}, "Answer created successfully");
290+
// return this.createStructuredContentSuccessResponse({
291+
// data: answer.data,
292+
// question: answer.question,
293+
// session_identifier: answer.session_identifier,
294+
// generation_number: answer.generation_number,
295+
// frame_url: answer.frame_url,
296+
// fields_info: "data: The csv data as an answer to the question\n session_identifier: The session identifier for the answer, use for liveboard creation\n generation_number: The generation number for the answer, use for liveboard creation\n frame_url: A url which can be used to view the answer in an iframe in the browser\n",
297+
// }, "Answer created successfully");
295298
}
296299

297300
@WithSpan('call-create-liveboard')

0 commit comments

Comments
 (0)