Skip to content

Commit 4d5a7dc

Browse files
committed
added code snippets and tags
1 parent 9ed6a99 commit 4d5a7dc

25 files changed

Lines changed: 857 additions & 49 deletions

File tree

mcp/node-openai/README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<!-- search-meta
2+
tags: [MCP, OpenAI, TypeScript, NodeJS, tool-calling, Azure-OpenAI, ThoughtSpot-MCP]
3+
apis: [ThoughtSpotMCPServer, OpenAIResponsesAPI, MCPTool]
4+
questions:
5+
- How do I connect OpenAI to ThoughtSpot using MCP?
6+
- How do I use ThoughtSpot as a tool in an OpenAI Responses API agent?
7+
- How do I set up ThoughtSpot MCP server with Node.js and OpenAI?
8+
- How do I query ThoughtSpot data from a Node.js OpenAI application?
9+
- How do I use Azure OpenAI with ThoughtSpot MCP server?
10+
-->
11+
112
# OpenAI Responses API with ThoughtSpot MCP Server
213

314
This example demonstrates how to use the OpenAI TypeScript/Node.js SDK with the ThoughtSpot MCP (Model Context Protocol) server. It shows how to integrate ThoughtSpot's data analysis and visualization capabilities as a tool within OpenAI's Responses API.
@@ -6,6 +17,30 @@ This example demonstrates how to use the OpenAI TypeScript/Node.js SDK with the
617

718
The example makes an API call to OpenAI's Responses API, configuring the ThoughtSpot MCP server as an available tool. The AI can then interact with ThoughtSpot to perform data analysis tasks.
819

20+
## Key Usage
21+
22+
```typescript
23+
import OpenAI from "openai";
24+
25+
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
26+
27+
// Connect ThoughtSpot MCP as a tool provider
28+
const response = await client.responses.create({
29+
model: "gpt-4o",
30+
tools: [
31+
{
32+
type: "mcp",
33+
server_label: "thoughtspot",
34+
server_url: "https://mcp.thoughtspot.com/mcp",
35+
headers: { Authorization: `Bearer ${process.env.TS_TOKEN}` },
36+
},
37+
],
38+
input: "What was the revenue by region last quarter?",
39+
});
40+
41+
console.log(response.output_text);
42+
```
43+
944
## Prerequisites
1045

1146
- Node.js (v16 or higher recommended)
@@ -134,7 +169,4 @@ If you're behind a proxy, you may need to configure proxy settings in the OpenAI
134169

135170
## License
136171

137-
See the main repository LICENSE file for details.
138-
139-
140-
172+
See the main repository LICENSE file for details.

mcp/python-google-adk-trusted-auth/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<!-- search-meta
2+
tags: [MCP, Python, Google-ADK, trusted-auth, AI-agent, ThoughtSpot-MCP]
3+
apis: [ThoughtSpotMCPServer, GoogleADK, trustedAuth, MCPToolset]
4+
questions:
5+
- How do I connect a Google ADK agent to ThoughtSpot using MCP?
6+
- How do I use ThoughtSpot with Google AI Development Kit?
7+
- How do I set up trusted auth for ThoughtSpot MCP with Python?
8+
- How do I build a Google ADK agent that queries ThoughtSpot data?
9+
-->
10+
111
# Python Google ADK Trusted Auth MCP Client
212

313
This is a Google ADK (Agent Development Kit) agent that connects to ThoughtSpot via MCP (Model Context Protocol) to query and retrieve data from ThoughtSpot data models using ThoughtSpot AI capabilities.
@@ -24,7 +34,7 @@ cd mcp/python-google-adk-trusted-auth
2434
```bash
2535
# Copy the template
2636
cp env.template .env
27-
37+
2838
# Edit .env with your actual values
2939
TS_SECRET_KEY=your_thoughtspot_secret_key
3040
TS_HOST=your_thoughtspot_host_here
@@ -61,5 +71,4 @@ This project includes integration with the [ThoughtSpot trusted auth](https://de
6171
- Python 3.8+
6272
- Google ADK
6373
- ThoughtSpot MCP server access
64-
- Valid ThoughtSpot secret key
65-
74+
- Valid ThoughtSpot secret key

mcp/python-openai-mcp/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<!-- search-meta
2+
tags: [MCP, Python, OpenAI, chat-completions, AI-agent, ThoughtSpot-MCP]
3+
apis: [ThoughtSpotMCPServer, OpenAIPython, ChatCompletion, MCPClient]
4+
questions:
5+
- How do I use ThoughtSpot MCP with Python OpenAI SDK?
6+
- How do I connect a Python OpenAI agent to ThoughtSpot?
7+
- How do I query ThoughtSpot data from a Python OpenAI application?
8+
- How do I set up ThoughtSpot as an MCP tool in Python with OpenAI?
9+
-->
10+
111
# OpenAI Python API Example
212

313
This example demonstrates how to use the OpenAI Python library to make API calls to the chat completions endpoint.
@@ -99,5 +109,4 @@ response = client.chat.completions.create(
99109

100110
- [OpenAI API Documentation](https://platform.openai.com/docs/api-reference)
101111
- [OpenAI Python Library](https://github.com/openai/openai-python)
102-
- [Chat Completions Guide](https://platform.openai.com/docs/guides/chat-completions)
103-
112+
- [Chat Completions Guide](https://platform.openai.com/docs/guides/chat-completions)

mcp/python-react-agent-simple-ui/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<!-- search-meta
2+
tags: [MCP, Python, React, FastAPI, SSE, streaming, OpenAI, ThoughtSpot-MCP, full-stack]
3+
apis: [ThoughtSpotMCPServer, OpenAIResponsesAPI, FastAPI, SSE, MCPClient]
4+
questions:
5+
- How do I build a chat UI that connects to ThoughtSpot via MCP?
6+
- How do I stream ThoughtSpot MCP responses to a React frontend using SSE?
7+
- How do I build a full-stack ThoughtSpot AI chat application with Python and React?
8+
- How do I use Server-Sent Events with ThoughtSpot MCP in a FastAPI Python server?
9+
-->
10+
111
# Python Agent with Simple React UI
212

313
A full-stack example that pairs a **Python (FastAPI) agent** powered by the OpenAI Responses API and ThoughtSpot MCP server with a **React chat UI**.
@@ -226,4 +236,4 @@ init({
226236

227237
- [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses)
228238
- [ThoughtSpot Developer Docs](https://developers.thoughtspot.com)
229-
- [Model Context Protocol](https://modelcontextprotocol.io)
239+
- [Model Context Protocol](https://modelcontextprotocol.io)

mcp/simple-python-fast-mcp/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<!-- search-meta
2+
tags: [MCP, Python, FastMCP, tool-discovery, bearer-token, ThoughtSpot-MCP]
3+
apis: [ThoughtSpotMCPServer, FastMCP, bearerToken, listTools]
4+
questions:
5+
- How do I connect to ThoughtSpot MCP server using Python?
6+
- How do I discover available tools in ThoughtSpot MCP server?
7+
- How do I test ThoughtSpot MCP server connectivity in Python?
8+
- How do I use FastMCP to connect to ThoughtSpot?
9+
-->
10+
111
# Simple Python FastMCP Example
212

313
This example demonstrates how to use the FastMCP Python client to connect to ThoughtSpot's Model Context Protocol (MCP) server. It provides a basic implementation that shows how to authenticate, connect, and interact with the MCP server.
@@ -127,4 +137,4 @@ logging.basicConfig(level=logging.DEBUG)
127137

128138
## License
129139

130-
This example is provided as-is for educational purposes. Please refer to the main project license for usage terms.
140+
This example is provided as-is for educational purposes. Please refer to the main project license for usage terms.

mobile/flutter-sdk/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<!-- search-meta
2+
tags: [Flutter, mobile, Dart, LiveboardEmbed, custom-styles, host-events, embed-events, iOS, Android]
3+
apis: [ThoughtSpotFlutterSDK, LiveboardEmbed, HostEvent, EmbedEvent, cssVariables, trigger, on]
4+
questions:
5+
- How do I embed ThoughtSpot in a Flutter mobile app?
6+
- How do I use the ThoughtSpot Flutter SDK to embed a liveboard?
7+
- How do I apply custom styles to ThoughtSpot embed in Flutter?
8+
- How do I trigger host events in ThoughtSpot Flutter embed?
9+
- How do I handle embed events in a ThoughtSpot Flutter integration?
10+
-->
11+
112
# ThoughtSpot Flutter Embed Example
213

314
> This example uses the [ThoughtSpot Flutter Embed SDK](https://pub.dev/packages/flutter_embed_sdk) to integrate ThoughtSpot analytics into Flutter applications.
@@ -89,4 +100,4 @@ flutter run
89100

90101
- Flutter
91102
- Dart
92-
- Mobile/Web
103+
- Mobile/Web

rest-api/import-user-multiple-orgs/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
1+
<!-- search-meta
2+
tags: [REST-API, user-management, multi-org, TypeScript, NodeJS]
3+
apis: [createUser, assignUserToOrg, listOrgs, REST-API-v2]
4+
questions:
5+
- How do I create users in multiple ThoughtSpot organizations via REST API?
6+
- How do I provision users to specific orgs in ThoughtSpot?
7+
- How do I manage users across ThoughtSpot orgs using the REST API?
8+
- How do I bulk create users in ThoughtSpot with org assignment?
9+
-->
10+
111
# create-user-cross-org
212

313
This repository provides an example of how to create user in any org (not necessarily to be current logged in org) via tenant admin by using ThoughtSpot APIs. This API allows tenant admin to create user in any or multiple as well.
414

15+
## Key Usage
16+
17+
```typescript
18+
// Create a user and assign them to multiple ThoughtSpot orgs
19+
// POST /api/rest/2.0/users/create
20+
const user = await fetch(`${THOUGHTSPOT_HOST}/api/rest/2.0/users/create`, {
21+
method: "POST",
22+
headers: {
23+
"Content-Type": "application/json",
24+
Authorization: `Bearer ${bearerToken}`,
25+
},
26+
body: JSON.stringify({
27+
name: "new-user@example.com",
28+
display_name: "New User",
29+
password: "temporary-password",
30+
org_identifiers: ["org-id-1", "org-id-2"], // assign to multiple orgs
31+
}),
32+
});
33+
```
34+
535
## File Structure
636
rest-api/create-user-cross-org/
737
│── src/
@@ -36,4 +66,4 @@ $ npm run dev
3666

3767
- Typescript
3868
- NodeJS
39-
- Express
69+
- Express

rest-api/jwt-filter-rules/README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,50 @@
1+
<!-- search-meta
2+
tags: [JWT, trusted-auth, filter-rules, REST-API, TypeScript, NodeJS, row-level-security]
3+
apis: [getAuthToken, filterRules, parameterValues, REST-API-v2, auth-token-custom]
4+
questions:
5+
- How do I generate a JWT token with filter rules for ThoughtSpot?
6+
- How do I apply row-level security through JWT auth in ThoughtSpot?
7+
- How do I pass parameter values in a ThoughtSpot JWT token?
8+
- How do I restrict data access per user using JWT filter rules in ThoughtSpot?
9+
- How do I implement column-level security with ThoughtSpot trusted auth?
10+
-->
11+
112
# jwt-filter-rules
213

314
This repository provides an example of how to generate and use JWT authentication tokens with filter rules and parameter values for ThoughtSpot APIs. This API allows administrators to generate a token with a specific set of rules and column filtering conditions that are applied when a user session is created.
415

16+
## Key Usage
17+
18+
```typescript
19+
// POST /api/rest/2.0/auth/token/custom
20+
const response = await fetch(`${THOUGHTSPOT_HOST}/api/rest/2.0/auth/token/custom`, {
21+
method: "POST",
22+
headers: { "Content-Type": "application/json" },
23+
body: JSON.stringify({
24+
username: "your-username",
25+
validity_time_in_sec: 300,
26+
password: "your-password",
27+
auto_create: true,
28+
// Apply row-level security: restrict to rows where Color = 'sky'
29+
filter_rules: [
30+
{
31+
column_name: "Color",
32+
operator: "IN",
33+
values: ["sky"],
34+
},
35+
],
36+
// Pass parameter values for ThoughtSpot parameters
37+
parameter_values: [
38+
{
39+
name: "Secured",
40+
values: ["Default"],
41+
},
42+
],
43+
}),
44+
});
45+
const { token } = await response.json();
46+
```
47+
548
## File Structure
649
rest-api/jwt-filter-rules/
750
│── src/
@@ -36,4 +79,4 @@ $ npm run start
3679

3780
- Typescript
3881
- NodeJS
39-
- Express
82+
- Express

rest-api/node-simple-spotter-api/README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
1+
<!-- search-meta
2+
tags: [Spotter, REST-API, AI-conversation, TypeScript, NodeJS, CSV-export, rest-api-sdk]
3+
apis: [ThoughtSpotRestApi, createBearerAuthenticationConfig, createConversation, sendMessage, exportAnswerReport]
4+
questions:
5+
- How do I use ThoughtSpot Spotter REST API programmatically in Node.js?
6+
- How do I create an AI conversation with ThoughtSpot Spotter via REST API?
7+
- How do I export CSV data from a ThoughtSpot Spotter conversation?
8+
- How do I use the ThoughtSpot REST API SDK for Spotter in Node.js?
9+
- How do I query ThoughtSpot data using the Spotter API without the embed UI?
10+
-->
11+
112
# Node Simple Spotter API Examples
213

314
This folder contains two example implementations demonstrating how to interact with ThoughtSpot's Spotter AI API using Node.js and TypeScript. Both examples show how to create an AI conversation, send a natural language query, and export the results as CSV.
415

16+
## Key Usage
17+
18+
```typescript
19+
import { createBearerAuthenticationConfig, ThoughtSpotRestApi } from "@thoughtspot/rest-api-sdk";
20+
21+
const config = createBearerAuthenticationConfig(
22+
"https://your-instance.thoughtspot.cloud",
23+
async () => "your-bearer-token",
24+
);
25+
const client = new ThoughtSpotRestApi(config);
26+
27+
// 1. Create an AI conversation
28+
const conversation = await client.createConversation({
29+
metadata_identifier: "your-datasource-id",
30+
});
31+
32+
// 2. Ask a question
33+
const response = await client.sendMessage(
34+
conversation.conversation_identifier,
35+
{
36+
metadata_identifier: "your-datasource-id",
37+
message: "revenue by region",
38+
}
39+
);
40+
41+
// 3. Export results as CSV
42+
const csv = await client.exportAnswerReport({
43+
session_identifier: response[0].session_identifier,
44+
generation_number: response[0].generation_number,
45+
file_format: "CSV",
46+
});
47+
console.log(await csv.text());
48+
```
49+
550
## Files Overview
651

752
- **`with-sdk.ts`** - Uses the official ThoughtSpot REST API SDK (recommended approach)
@@ -22,7 +67,7 @@ This folder contains two example implementations demonstrating how to interact w
2267
```
2368

2469
2. **Configure environment variables:**
25-
70+
2671
Create a `.env` file in this directory with the following variables:
2772
```bash
2873
THOUGHTSPOT_HOST=https://your-instance.thoughtspot.cloud
@@ -102,5 +147,4 @@ Ask the ThoughtSpot support to run the flag to remove the header from the export
102147

103148
- [ThoughtSpot REST API Documentation](https://developers.thoughtspot.com/docs/rest-apiv2-reference)
104149
- [ThoughtSpot REST API SDK](https://www.npmjs.com/package/@thoughtspot/rest-api-sdk)
105-
- [Spotter Tutorial](https://developers.thoughtspot.com/docs/tutorials/spotter/integrate-into-chatbot)
106-
150+
- [Spotter Tutorial](https://developers.thoughtspot.com/docs/tutorials/spotter/integrate-into-chatbot)

rest-api/typescript-sdk/express-example/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
1+
<!-- search-meta
2+
tags: [typescript-sdk, REST-API, Express, NodeJS, TypeScript, rest-api-sdk]
3+
apis: [ThoughtSpotRestApi, createBearerAuthenticationConfig, searchLiveboards, REST-API-v2]
4+
questions:
5+
- How do I use the ThoughtSpot REST API TypeScript SDK with Express?
6+
- How do I set up a Node.js Express server with the ThoughtSpot REST API SDK?
7+
- How do I authenticate with ThoughtSpot REST API SDK in Node.js?
8+
- How do I fetch liveboards using the ThoughtSpot TypeScript REST API SDK?
9+
-->
10+
111
# express-example - Typescript SDK
212

313
This example demonstrates how to use the @thoughtspot/rest-api-sdk with Express.js in a TypeScript environment.
414

15+
## Key Usage
16+
17+
```typescript
18+
import { createBearerAuthenticationConfig, ThoughtSpotRestApi } from "@thoughtspot/rest-api-sdk";
19+
import express from "express";
20+
21+
const config = createBearerAuthenticationConfig(
22+
"https://your-instance.thoughtspot.cloud",
23+
async () => "your-bearer-token",
24+
);
25+
const tsClient = new ThoughtSpotRestApi(config);
26+
27+
const app = express();
28+
29+
app.get("/liveboards", async (req, res) => {
30+
const liveboards = await tsClient.searchLiveboards({});
31+
res.json(liveboards);
32+
});
33+
34+
app.listen(3000);
35+
```
36+
537
## Demo
638

739
Open in [Codesandbox](https://githubbox.com/thoughtspot/developer-examples/tree/main/rest-api/typescript-sdk/express-example)
@@ -35,4 +67,4 @@ $ npm run start
3567

3668
- Typescript
3769
- NodeJS
38-
- Express
70+
- Express

0 commit comments

Comments
 (0)