ChatCBI
Query CB Insights' conversational AI to analyze business intelligence data through specific, clear questions, maintaining context across interactions.
Instructions
When using this tool, provide clear, specific queries for the best results. You can continue conversations with ChatCBI by including the chat ID from previous interaction.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | ||
| chat_id | No |
Implementation Reference
- server.py:46-72 (handler)The ChatCBI tool handler, decorated with @mcp.tool, which authenticates, constructs the API request to /chatcbi endpoint, and returns the response content.@mcp.tool(name="ChatCBI", description="When using this tool, provide clear, specific queries for the best results. You can continue conversations with ChatCBI by including the chat ID from previous interaction.", annotations=ToolAnnotations(title="Chat with CBI", readOnlyHint=True, openWorldHint=True), structured_output=False, ) def chat_with_cbi(message: str, chat_id: Optional[str] = None) -> {}: token = get_auth_token() url = f"{API_BASE}/chatcbi" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } payload = {"message": message} if chat_id: payload["chatID"] = chat_id with httpx.Client() as client: try: response = client.post(url, headers=headers, json=payload, timeout=TIMEOUT) response.raise_for_status() return response.content except Exception as e: raise Exception(e) return {}
- server.py:29-44 (helper)Helper function to obtain authentication token from CB Insights API, used by the ChatCBI handler.def get_auth_token() -> str: url = f"{API_BASE}/authorize" payload = { "clientId": CLIENT_ID, "clientSecret": CLIENT_SECRET } with httpx.Client() as client: try: response = client.post(url, json=payload, timeout=30.0) response.raise_for_status() return response.json()["token"] except Exception as e: raise Exception(f"Failed to authenticate: {str(e)}")
- server.py:46-50 (registration)Registration of the ChatCBI tool via @mcp.tool decorator, specifying name, description, annotations, and output settings.@mcp.tool(name="ChatCBI", description="When using this tool, provide clear, specific queries for the best results. You can continue conversations with ChatCBI by including the chat ID from previous interaction.", annotations=ToolAnnotations(title="Chat with CBI", readOnlyHint=True, openWorldHint=True), structured_output=False, )
- server.py:51-51 (schema)Function signature defining input schema: message (str, required), chat_id (Optional[str]), output as dict.def chat_with_cbi(message: str, chat_id: Optional[str] = None) -> {}: