ChatCBI
Use this tool to interact with CB Insights' conversational AI by providing clear, specific queries. Maintain context by including the chat ID from previous interactions for continuous dialogue.
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 |
|---|---|---|---|
| chat_id | No | ||
| message | Yes |
Implementation Reference
- server.py:51-72 (handler)The handler function for the ChatCBI tool. It authenticates using get_auth_token, constructs a payload with the message and optional chat_id, and performs a POST request to the CB Insights /chatcbi endpoint, returning the raw response content.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:46-50 (registration)Registers the ChatCBI tool with MCP using the @mcp.tool decorator, specifying name, description, annotations, and output behavior.@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)Defines the input schema with parameters message (str) and optional chat_id (str), and output as unstructured dict ({}).def chat_with_cbi(message: str, chat_id: Optional[str] = None) -> {}:
- server.py:29-44 (helper)Helper function that retrieves the authentication token from the CB Insights API using client credentials.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)}")