Create custom MCP server for HubSpot - without code | Pylar Blog

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?

Step-by-Step Walkthrough

Step 1: Connect HubSpot to Pylar

  1. In Pylar, go to Connections -> HubSpot.
  2. Click "Connect" and authorize Pylar via OAuth.
  3. 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

  1. Select your view (hot_leads) in the right sidebar.
  2. Click "Create MCP Tool" and choose "Create with AI".
  3. Type a prompt: "Create a tool that finds hot leads with high page views and open deals."
  4. 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)

Step 4: Publish & Connect

  1. Click "Publish" in the right sidebar.
  2. Click "Generate Token".
  3. 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?"

  1. Use n8n's HTTP Request node.
  2. POST to https://api.pylar.ai/mcp/v1/server/YOUR_SERVER_ID/tools/call.
  3. Header: Authorization: Bearer YOUR_TOKEN.
  4. 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.

2. Sales Pipeline Assistant

Goal: Give sales reps instant visibility into their pipeline.

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.