• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoughtspot / mcp-server / 16061224324

03 Jul 2025 09:52PM UTC coverage: 88.438% (+0.7%) from 87.716%
16061224324

Pull #32

github

web-flow
Merge 00b1c638d into f2d580300
Pull Request #32: Handle cases where third party cookie is blocked by browsers

97 of 112 branches covered (86.61%)

Branch coverage included in aggregate %.

23 of 23 new or added lines in 2 files covered. (100.0%)

339 of 381 relevant lines covered (88.98%)

62.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/servers/api-server.ts
1
import { Hono } from 'hono'
2
import type { Props } from '../utils';
3
import {
4
    createLiveboard,
5
    getAnswerForQuestion,
6
    getDataSources,
7
    getRelevantQuestions
8
} from '../thoughtspot/thoughtspot-service';
9
import { getThoughtSpotClient } from '../thoughtspot/thoughtspot-client';
10

11
const apiServer = new Hono<{ Bindings: Env & { props: Props } }>()
31✔
12

13
apiServer.post("/api/tools/relevant-questions", async (c) => {
31✔
14
    const { props } = c.executionCtx;
32✔
15
    const { query, datasourceIds, additionalContext } = await c.req.json();
32✔
16
    const client = getThoughtSpotClient(props.instanceUrl, props.accessToken);
24✔
17
    const questions = await getRelevantQuestions(query, datasourceIds, additionalContext || '', client);
24✔
18
    return c.json(questions);
24✔
19
});
20

21
apiServer.post("/api/tools/get-answer", async (c) => {
31✔
22
    const { props } = c.executionCtx;
8✔
23
    const { question, datasourceId } = await c.req.json();
8✔
24
    const client = getThoughtSpotClient(props.instanceUrl, props.accessToken);
8✔
25
    const answer = await getAnswerForQuestion(question, datasourceId, false, client);
8✔
26
    return c.json(answer);
8✔
27
});
28

29
apiServer.post("/api/tools/create-liveboard", async (c) => {
31✔
30
    const { props } = c.executionCtx;
16✔
31
    const { name, answers } = await c.req.json();
16✔
32
    const client = getThoughtSpotClient(props.instanceUrl, props.accessToken);
16✔
33
    const liveboardUrl = await createLiveboard(name, answers, client);
16✔
34
    return c.text(liveboardUrl);
8✔
35
});
36

37
apiServer.get("/api/resources/datasources", async (c) => {
31✔
38
    const { props } = c.executionCtx;
16✔
39
    const client = getThoughtSpotClient(props.instanceUrl, props.accessToken);
16✔
40
    const datasources = await getDataSources(client);
16✔
41
    return c.json(datasources);
8✔
42
});
43

44
apiServer.post("/api/rest/2.0/*", async (c) => {
31✔
45
    const { props } = c.executionCtx;
16✔
46
    const path = c.req.path;
16✔
47
    const method = c.req.method;
16✔
48
    const body = await c.req.json();
16✔
49
    return fetch(props.instanceUrl + path, {
16✔
50
        method,
51
        headers: {
52
            "Authorization": `Bearer ${props.accessToken}`,
53
            "Accept": "application/json",
54
            "Content-Type": "application/json",
55
            "User-Agent": "ThoughtSpot-ts-client",
56
        },
57
        body: JSON.stringify(body),
58
    });
59
});
60

61
apiServer.get("/api/rest/2.0/*", async (c) => {
31✔
62
    const { props } = c.executionCtx;
16✔
63
    const path = c.req.path;
16✔
64
    const method = c.req.method;
16✔
65
    return fetch(props.instanceUrl + path, {
16✔
66
        method,
67
        headers: {
68
            "Authorization": `Bearer ${props.accessToken}`,
69
            "Accept": "application/json",
70
            "User-Agent": "ThoughtSpot-ts-client",
71
        }
72
    });
73
});
74

75
export {
76
    apiServer,
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc