Daeda MCP - get_raw_sql

get_raw_sql

Execute SELECT queries against your CRM data.

Description

The get_raw_sql tool runs SQL queries against your local HubSpot database. Only SELECT queries are allowed - your CRM data can never be modified.

Parameters

Parameter
Type
Required
Description
sql
string
Yes
SQL query to execute (SELECT only)

Database Schema

The local database contains:
Table
Description
contacts
All contacts with email and full properties as JSON
companies
All companies with domain and full properties as JSON
deals
All deals with name and full properties as JSON
contact_company
Contact to company associations
deal_contact
Deal to contact associations
deal_company
Deal to company associations

Querying Properties

All HubSpot properties are stored as JSON. Use json_extract() to query them:
SELECT
json_extract(properties, '$.firstname') as first_name,
json_extract(properties, '$.lastname') as last_name,
email
FROM contacts
WHERE json_extract(properties, '$.lifecyclestage') = 'customer'
LIMIT 10

Example Queries

Deals closing this month over $50k:
SELECT dealname,
json_extract(properties, '$.amount') as amount,
json_extract(properties, '$.closedate') as close_date
FROM deals
WHERE json_extract(properties, '$.amount') > 50000
AND json_extract(properties, '$.closedate') LIKE '2026-02%'
Contacts at healthcare companies:
SELECT c.email,
json_extract(c.properties, '$.firstname') as name,
json_extract(co.properties, '$.name') as company
FROM contacts c
JOIN contact_company cc ON <c.id> = cc.contact_id
JOIN companies co ON cc.company_id = <co.id>
WHERE json_extract(co.properties, '$.industry') = 'Healthcare'
Deals with no associated contacts:
SELECT d.dealname
FROM deals d
LEFT JOIN deal_contact dc ON <d.id> = dc.deal_id
WHERE dc.contact_id IS NULL
Pipeline value by deal stage:
SELECT json_extract(properties, '$.dealstage') as stage,
COUNT(*) as deal_count,
SUM(json_extract(properties, '$.amount')) as total_value
FROM deals
GROUP BY stage

Security

  • Only SELECT queries are allowed
  • Dangerous keywords (INSERT, UPDATE, DELETE, DROP, etc.) are blocked
  • Results limited to 1,000 rows by default
  • Query timeout: 30 seconds