Create custom MCP server for HubSpot - without code
Hoshang Mehta
Create custom MCP server for HubSpot - without code
HubSpot is the backbone of your marketing and sales operations. It holds your contacts, deals, email campaigns, and engagement metrics. But when you try to build an AI agent that can answer questions like "Which leads opened our last email?" or "Show me all deals stuck in the demo stage," you hit a wall.
The HubSpot API is powerful but complex. You need to handle OAuth, pagination, rate limits, and nested JSON responses. Building a custom backend just to expose a few queries to your agent is overkill.
Pylar solves this.
Pylar syncs your HubSpot data to a SQL-queryable warehouse and lets you build MCP (Model Context Protocol) tools with simple prompts—no code required.
Why Pylar for HubSpot?
- No API Wrangling: Pylar handles OAuth, syncing, and schema mapping. You just write SQL.
- Unified Data: Join HubSpot contacts with your Stripe revenue data or Snowflake analytics in a single view.
- Real-Time Sync: Your data stays fresh. Pylar syncs automatically.
Step-by-Step Walkthrough
Step 1: Connect HubSpot to Pylar
- In Pylar, go to Connections -> HubSpot.
- Click "Connect" and authorize Pylar via OAuth.
- Pylar will begin syncing your HubSpot data (contacts, deals, companies, emails, etc.) to its internal warehouse.

You'll receive an email when the sync is complete. This usually takes a few minutes.
Step 2: Create a Sandboxed View
Let's say you want an agent to help your sales team identify hot leads.
In Pylar's SQL IDE, create a view:
-- view: hot_leads
SELECT
c.email,
c.firstname,
c.lastname,
c.hs_lead_status,
c.hs_analytics_num_page_views,
d.dealname,
d.dealstage,
d.amount
FROM hubspot.contacts c
LEFT JOIN hubspot.deals d ON c.email = d.contact_email
WHERE c.hs_lead_status = 'OPEN'
AND c.hs_analytics_num_page_views > 10

This view surfaces leads who are actively browsing your site and have open deals.
Step 3: Auto-Build the MCP Tool
- Select your view (
hot_leads) in the right sidebar. - Click "Create MCP Tool" and choose "Create with AI".
- Type a prompt: "Create a tool that finds hot leads with high page views and open deals."
- Pylar generates the tool configuration:
- Name:
get_hot_leads - Description: "Returns leads with high engagement and active deals."
- Parameters: None (or optionally
min_page_views)
- Name:

Step 4: Publish & Connect
- Click "Publish" in the right sidebar.
- Click "Generate Token".
- Copy your MCP HTTP Stream URL (
https://mcp.publish.pylar.ai/mcp) and Authorization Bearer Token.

Connect to Slack Bot (via n8n): You can now build a Slack bot that lets your sales team ask: "Who are our hottest leads right now?"
- Use n8n's HTTP Request node.
- POST to
https://api.pylar.ai/mcp/v1/server/YOUR_SERVER_ID/tools/call. - Header:
Authorization: Bearer YOUR_TOKEN. - Body:
{"name": "get_hot_leads", "arguments": {}}.
Advanced Use Cases for HubSpot Agents
1. Marketing Campaign Performance Bot
Goal: Let your marketing team ask "How did our last email campaign perform?" without logging into HubSpot.
- View: Join
email_campaignswithemail_events(opens, clicks). - Tool Prompt: "Create a tool that summarizes email campaign performance by campaign ID."
- User Query: "Show me the open rate for the 'Q4 Product Launch' email."
2. Sales Pipeline Assistant
Goal: Give sales reps instant visibility into their pipeline.
- View:
dealsfiltered byowner_emailanddealstage. - Tool Prompt: "Create a tool that shows all deals in a specific stage for a given sales rep."
- User Query: "What deals does Sarah have in the 'Negotiation' stage?"
Conclusion
HubSpot is a powerful CRM, but giving AI agents direct access to it has always been complex—requiring API integrations, authentication handling, and custom code. With Pylar, you can transform your HubSpot CRM into an AI-ready data source in under 2 minutes—no coding required.
By connecting Pylar to your HubSpot account, creating sandboxed views that protect sensitive customer data, and auto-generating MCP tools with natural language, you unlock the full potential of your CRM for AI agents while maintaining complete security and governance.
Whether you're building an email campaign performance analyzer, a sales pipeline assistant, or any other CRM-powered AI application, Pylar gives you the governance layer you need. Your views act as security boundaries, and with support for all standard and custom HubSpot properties, you can query your CRM data just like any SQL database.
Stop wrestling with the HubSpot API. Start building AI agents that understand your CRM today.
Start building your HubSpot MCP server for free at pylar.ai.
