Usaid - Does MCP bearer url "https://agent.thou...
# dev-help
u
Does MCP bearer url "https://agent.thoughtspot.app/bearer/mcp" supports the calling of tools like ping, getanswer,etc. ?
s
yes, it should!
u
But then why it is returning with no tools discovered?
Is there anything regarding the user having access to data source in thoughspot?
q
@shikharts_67242 Can you help here
s
How are you using this bearer url?
u
Summary: I’m not calling any other URL; all MCP JSON-RPC traffic goes to https://agent.thoughtspot.app/bearer/mcp I send: Authorization: Bearer x-ts-host: rowan.thoughtspot.cloud Mcp-Session-Id: for tools/list and tools/call JSON-RPC body with method = "initialize", "tools/list", etc.
CODE APPROACH: In clustering/mcp_utils.py I load that and use it as the single endpoint for all MCP JSON-RPC calls (initialize, tools/list, tools/call): import os import uuid import requests from dotenv import load_dotenv load_dotenv() TS_HOST = os.getenv("TS_HOST") TS_USERNAME = os.getenv("TS_USERNAME") TS_SECRET_KEY = os.getenv("TS_SECRET_KEY") TOKEN_VALIDITY = int(os.getenv("TOKEN_VALIDITY", "300")) MCP_URL = os.getenv("MCP_URL", "https://agent.thoughtspot.app/bearer/mcp") All MCP calls go through this helper, which POSTs to MCP_URL: def _mcp_call(method: str, params: dict | None, token: str, session_id: str | None, rpc_id: int): headers = { "Authorization": f"Bearer {token}", # TS_AUTH_TOKEN from /auth/token/full "x-ts-host": TS_HOST, # e.g. rowan.thoughtspot.cloud "Content-Type": "application/json", "Accept": "application/json, text/event-stream", } if session_id: headers["Mcp-Session-Id"] = session_id payload = { "jsonrpc": "2.0", "id": str(rpc_id), "method": method, # "initialize", "tools/list", "tools/call" "params": params or {} } return requests.post(MCP_URL, headers=headers, json=payload, timeout=45) Then I call it like this: def ask_thoughtspot_via_mcp(user_question: str) -> dict: # 1) Get TS_AUTH_TOKEN via /api/rest/2.0/auth/token/full token = generate_ts_token() # 2) initialize (no session header) init_payload = { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "rowan-hybrid-bot", "version": "1.0.0"}, } r1 = _mcp_call("initialize", init_payload, token, None, rpc_id=1) # 3) tools/list (new session id, sent in Mcp-Session-Id header) session_id = str(uuid.uuid4()) r2 = _mcp_call("tools/list", {}, token, session_id, rpc_id=2) # (later) tools/call with same session_id…
s
What response do you get with this? The code does look okay to me.